12.7. Monitoring
12.7.1. Getting Resource Availability Copy linkLink copied to clipboard!
Copy linkLink copied to clipboard!
Many operations should only occur if the target resource is running, such as deploying a new web application. Including an availability check in a larger script is helpful for controlling when state-dependent operations are run.
The script steps are:
- Search for the resource. In this case, the script just looks for any resource which matches the resource type (Linux platform), and uses the first match for the availability scan.
- Get the current availability status.
Example 12.23. Current Availability
The JBoss ON server returns the resource information, its current status, and the time what the current status began (meaning, if the server is up, the time the server started).
12.7.2. Getting Specific Metrics Copy linkLink copied to clipboard!
Copy linkLink copied to clipboard!
The monitoring information in JBoss ON is not a live reading. There are two reasons for that: scans are periodic, not streaming, and the information for baselines and averages are processed (aggregated).
The
findLiveData
method is a way to pull in the current, un-average, live reading of a given metric.
The script steps are:
- Search for the available metric definitions, based on the resource type and then filtered to a single metric. This example grabs the free memory metric for the Linux platform.
- Search for the resource.
- Get the current reading for the metric.
- Print the data to the terminal.
Example 12.24. Annotated Example
With this example, the current, live reading for the metric is printed to the screen.
Metric value for 10001 is [MeasurementDataNumeric[value=[6.3932239872E10], MeasurementData [MeasurementDataPK: timestamp=[Tue May 08 20:10:15 EDT 2012], scheduleId=[10002]]]]
Metric value for 10001 is [MeasurementDataNumeric[value=[6.3932239872E10], MeasurementData [MeasurementDataPK: timestamp=[Tue May 08 20:10:15 EDT 2012], scheduleId=[10002]]]]
12.7.3. Exporting Metric Data for a Resource Copy linkLink copied to clipboard!
Copy linkLink copied to clipboard!
Raw metrics data are only saved in the database for a week by default. After that, only the processed (aggregated) data are saved. It can be useful to export raw measurements to a CSV or text file so that long-term historical data can be preserved.
The script steps are:
- Search for the available metric definitions, based on the resource type. In this example, it is for the Linux platform.
- Search for the resource.
- Set a date range for the metric information. This is configured in seconds, relative to the time the script is run.
- Set up the file information to which to write the data.
- Iterate through all the metric definitions for the resource, and print the data to the given CSV file.
Example 12.25. Exporting All Metrics Definitions for a Linux Server
12.7.4. Getting Baseline Calculations Copy linkLink copied to clipboard!
Copy linkLink copied to clipboard!
Baselines are the normal operating ranges for a specific resource, based on its own performance.
Getting a baseline is really easy; all it requires is the resource ID.