Introduction
In addition to agent-based custom monitors, agentless monitoring are supported. Agentless monitors use the gateway to track the health and performance of the network, storage, and virtual resources as well as Platform as a Service (PaaS) cloud resources.
For agentless custom monitors, the gateway connects to a remote device using the following options:
- SSH for Linux devices
- PowerShell for Windows devices
- Remote Script Executor for Windows and Linux devices
Note
Supported only through Windows Gateway.
After connecting to the remote device, the gateway collects information and displays them as graphs or notifications according to the threshold.
Set up agentless custom monitors via Secure Shell (SSH) monitors
OpsRamp Remote Shell provides the provision to write the custom scripts using Bash, Perl, and Python to help monitor remote devices.
Setting up monitoring to use Remote Shell Monitors includes:
- Creating metrics.
- Creating a custom remote shell monitor with remote shell metrics.
- Creating a template with remote shell monitor.
- Assigning the template to a resource.
- Viewing graphs.
Prerequisites
- Remote System
- Resource has SSH support.
- Installation of one of the scripting languages, such as Bash, Python, and Perl.
- All the libraries of the installed script are available in the remote system.
- The custom script follows the predefined response format of OpsRamp.
- OpsRamp
- As of OpsRamp Gateway version 5.5.0, SSH monitoring is supported.
- Valid OpsRamp user credentials with permissions to create a metric, monitor and template.
- Access to remote device requires a single valid SSH credentials.
Step 1: Create metrics
You can create Custom Metrics using custom scripts.
To create custom Remote Shell metrics:
- From All Clients, select a client.
- Go to Setup > Monitoring > Metrics.
- From the METRICS screen, click + Add and provide the following:
- Collector Type: Select Application.
- Application Type: Select Remote Shell.
- Name: Provide a Name for the metric.
- OpsRamp recommends
<Prefix>.<Script Type>.<OS>.<Name>
as naming convention for the metric.
For examples:rshell.bash.linux.disk_utilization
,rshell.python.linux.cpu_utilization
, andrshell.perl.linux.memory_utilization
- OpsRamp recommends
- Tag: Refers to the user-defined tags for better filtering. For example, Application, Adapter, RemoteShell.
- Display Name: Refers to the display Name provided for the metric.
- Description: Refers to the purpose of the metric.
- Script: Provide the custom script in the Script text box. Refer to sample Bash script and JSON outputs for single and multiple datapoints to view the sample script.
- Data Point type: Select the required data point.
- Units: Select the required values for Units, Unit Multiplication Factor and Datapoint value conversion lists.
- Unit Multiplication Factor: Refers to the value chosen to multiply a value based on the chosen unit.
- Data Point Conversion: Refers to one of the following options:
- Value
- Enumerated Map
- Metric Processing: Refers to one of the following values for processing the Metric:
- Notification
- Graph
- Graph and Notification. To configure values for Graph and Notification, provide the details for the following parameters:
- Warning if value: Refers to the warning threshold value.
- Critical if value: Refers to the critical threshold value.
- Subject: Refers to the subject for the metric.
- Description: Refers to the description for the metric.
Important: The values for Subject and Description are populated by default. OpsRamp recommends not to change the values as that can result in the failure of alert generation.
- Click Save.
Step 2: Create monitor
The custom remote shell monitor is a collection of remote shell metrics. You can create a template using the remote shell monitor.
- Monitor only one bateway using remote shell.
- Monitor to have metrics of the same script type.
- Select the custom parameter path depending on the script type.
To create a custom remote shell monitor:
- From All Clients, select a client.
- Go to Setup > Monitor Management > Monitors.
- From Monitors, click + Add.
- From Create a Monitor, provide the following parameters.
- Monitor Scope: Refers to the scope for each monitor.
- Adaptor Type: Select Application.
- Application Type: Select Remote Shell.
- Name: Refers to the unique monitor name.
- Description: Refers to the details of the added monitors.
- Metrics: A metric is a measurement for a specific characteristic of the performance of a device.
To add metrics:
- From Metrics, click Add Metrics.
Note: A maximum of 20 metrics is recommended. Adding more number of metrics in a monitor can run into performance issues. - Search the desired metric and click Add Metrics. The metrics section displays the selected metric.
- From Metrics, click Add Metrics.
- Configuration Parameters: A configuration parameter is a user input to assist the metric collector.
To add parameters:- Provide Default Value for all the configuration parameters.
- Select the Configurable checkbox and click Add.
- Provide configuration parameters depending on your environment or devices.
You can view the default value for the respective name selected. For example, the following shows the configuration parameters for a script type.- bash:
rshell.bash.bin.path
- python:
rshell.python.bin.path
- perl:
rshell.perl.bin.path
- custom executor:
rshell.customexecutor.bin.path
- bash:
- Click Save.
Step 3: Create a template
A template is an instance of a monitor and applied to devices.
To create a template:
- From All Clients, select a client.
- Go to Setup > Monitoring > Templates.
- From the TEMPLATES screen, click + Add.
- From MONITOR TEMPLATE, provide the following parameters:
- Select Template Scope: Refers to the Template type.
- Collector Type: Select Gateway.
- Monitor Type: Select Monitors for G2 Templates.
- Applicable for: Select Device.
- Template Name: Refers to the name of the template.
- Description: Refers to the summary of the template.
- Generation: Refers to the generation that the template belongs to.
- Tags: Refers to the user-defined tags for better filtering. For example, Application, Adapter.
- Prerequisites: Refers to the essential things that you must consider while monitoring using the template. For example, check the SQL services while monitoring the SQL Parameters using the Windows templates.
- Status: Refers to the Active or End-of-life templates.
Note: Refers to the additional information that you want to add to the template. - Template Family Name: Refers to the category that applies to the application. For example, Windows Server, Storage Server, and Network Server.
- Deployment Type: Refers to one of the following methods to apply the template to the resources:
- Custom
- Optional
- Standard
- After providing the template details, MONITOR TEMPLATE displays the Monitors section.
Note: The user interface for the Monitors section varies with the option selected in the Collector Type. - Monitor: To add details in Monitors:
- From the Monitors section, click Add button.
- From the Monitor screen, provide the following parameters:
- Frequency: Refer to the frequency to execute the template.
- Monitor Definition: Refers to the monitor type.
- When to Alert: Select Breach of a Threshold.
- Select the Availability and Alert check-box to initiate monitoring.
- Click Save.
Step 4: Assign a template
To assign a template to a resource:
Creating credentials for the template:
- From All Clients, select a client.
- Go to Infrastructure > Resources.
- Select a resource, click Credentials, and +Add.
- From Create New Credentials, provide details for the following parameters and Save.
- Name
- Description.
- From the Type drop-down list, select SSH.
- Authentication Type
- Username
- Password
- Confirm Password.
- Port
- Connection Time Out (ms)
Important
Provide the details of the user having access to the remote device with SSH.
Assigning the template to a resource:
- Go to Infrastructure > Resources, select a resource, and click on the resource name to view details.
- Go to Monitors > Templates and click +Assign Templates.
- From Apply Templates, select the desired templates.
The selected Templates section displays the chosen templates. - Click Assign.
The template gets assigned to the selected device.
After assigning the template to a resource for monitoring, select Get Latest Metric Values to view the latest metric information.
Step 5: View graphs
OpsRamp Gateway monitors the remote system using the assigned templates and displays the results in a graphical format.
To view the monitoring graphs:
- Go to Infrastructure > Resources, select a required resource from the list of resources. Alternatively, use the search option to locate the resource.
- Click the resource name to view details.
- From the left pane, click Metrics.
The Metrics page displays graphs generated by all monitoring templates assigned to a device. - Search with the desired template name to filter the graphs.
Set up agentless custom monitors via PowerShell monitors
Windows PowerShell can help you to control and automate the administration of the Windows operating system and applications that run on Windows.
Prerequisites
- The PowerShell supports all versions of Windows devices.
- Supported types: WQL queries and PowerShell scripts
- Supported cmdlets: Get-WmiObject and Get-CimInstance
- The target device must have WinRm in Running State (Enabled).
- Target device must have User privileges.
- Set the PowerShell environment variable in the target device.
- PowerShell script works only on Windows Gateway.
- Place the PowerShell script in Windows Gateway.
Default path:
/OpsRamp/Gateway/scripts/wmi/monitoring/rpshellscripts
- The script must follow a predefined response format at the metric level.
- Arguments support for PowerShell script.
- No argument support for the metric level script.
Usage
- As of OpsRamp Gateway version 5.5.0, Powershell monitoring is supported.
- Valid OpsRamp user credentials with Create metric, monitor and template permissions.
- Access to the remote device requires a single valid Powershell credential.
Monitoring using PowerShell Monitors includes the following steps:
- Create Metrics
- Create a custom PowerShell monitor with PowerShell metrics
- Create a template with PowerShell monitor
- Assign the template to a device
- Get the latest metric value
- View Graphs
Step 1: Create custom metrics
Custom metrics can be created with custom scripts.
To create a custom remote shell metric:
- From All Clients, select a client.
- Go to Setup > Monitoring > Metrics.
- From METRIC, click + Add and provide the following:.
- Metric Scope: Refers to Partner Metric or Client Specific Metric.
- Adaptor Type: Select Application.
- Application Type: Select PowerShell.
- Name: Refers to a unique Name for the metric.
OpsRamp recommends<Prefix>.<Script Type>.<OS>.<Name>
as naming convention for the metric.
For Example:windows.system.cpu.utilization
,windows.system.disk.utilization
,windows.system.drive.freeSpace
, andwindows.system.memory.usage
. - Tag: Refers to the user-defined tags for better filtering. For example, Adapter, PowerShell.
- Display Name: Provide Display Name. For example, System Drive Free Space.
- Description: Provide the purpose of the metric.
- Script: Refers to the custom script in the Script text box. You can refer to sample script and JSON outputs to view the sample script provided in the Script section in the user interface.
- Data Point type: Refers to the value chosen to plot data in the graph.
- Units: Refers to the required values for Units. You can choose Units depending on the chosen Data Point Type.
- Unit Multiplication Factor: Refers to the value chosen to multiply a value based on the chosen unit.
- Data Point Conversion: Refers to one of the following options:
- Value
- Enumerated Map
- Metric Processing: Refers to one of the following values for processing the Metric:
- Notification
- Graph
- Graph and Notification.
- To configure values for Graph and Notification, provide the following:
- Warning if value: Refers to the warning threshold value.
- Critical if value: Refers to the critical threshold value.
- Subject: Refers to the subject for the metric.
- Description: Refers to the description for the metric.
Important
- The values for Subject and Description are populated by default.
- OpsRamp recommends not to change the values as that can result in the failure of alert generation.
- Click Save.
Step 2: Create monitor
Custom PowerShell monitor is a collection of PowerShell metrics. You can create a template using the PowerShell monitor.
Prerequisites:
- Monitor to have metrics of the same script type.
- Add the required custom parameters.
Note
You can monitor only one Gateway using PowerShell.To create a custom PowerShell monitor:
- Go to Setup > Monitoring > Monitors.
- From Monitors, click + Add.
CREATE A MONITOR screen appears. - From CREATE A MONITOR, provide the following parameters:
- Monitor Scope: Select either Partner Monitor or Client Specific Monitor.
- Type: Select Application.
- Application Type: Select PowerShell.
- Name: Provide a unique name for the metric.
- Description: Provide the purpose of creating the monitor.
- After providing the monitor details, navigate to the Metrics section.
- Metrics: To add Metrics:
- From Metrics, click Add Metrics.
Metrics screen appears. - Search the desired metric and click Add Metrics.
Metrics section displays the selected metric.
- From Metrics, click Add Metrics.
- After adding the metrics, navigate to Configuration Parameters.
- Configuration Parameters: To add configuration Parameters:
- Provide Default Value for all the configuration parameters.
- Select the Configurable checkbox.
- Click Add.
Configuration Parameters screen appears. - Provide Configuration Parameters depending on the selected script type. You can view the default value for the respective Name selected.
- Click Save.
Step 3: Create template
A template is an instance of a monitor and applied to devices.
To create a template:
- From All Clients, select a client.
- Go to Setup > Monitoring >Templates and click + Add.
- From MONITOR TEMPLATE, provide the following:
- Select Template Scope: Refers to the Template type.
- Collector Type: Select Gateway.
- Monitor Type: Select Monitors for G2 Templates.
- Applicable for: Select Device.
- Template Name: Refers to the name of the template.
- Description: Refers to the summary of the template.
- Generation: Refers to the generation that the template belongs to.
- Tags: Refers to the user-defined tags for better filtering.
- Prerequisites: Refers to the essential things that you must consider while monitoring using the template. For example, check the SQL services while monitoring the SQL Parameters using the Windows templates.
- Status: Refers to the Active or End-of-life templates.
Notes Refers to the additional information that you want to add to the template. - Template Family Name: Refers to the category that applies to the application. For example, Windows Server, Storage Server, and Network Server.
- Deployment Type: Refers to one of the following methods to apply the template to the resources:
- Custom
- Optional
- Standard
- After providing the template details, MONITOR TEMPLATE displays the Monitors section.
Note The user interface for the Monitors section varies with the option selected in the Collector Type. - Monitor: To add details in Monitors:
- From Monitors section, click Add button.
The monitor screen appears.- Frequency: Refers to the frequency to execute the template.
- Monitor Definition: Refers to the monitor type.
- When to Alert: Select Breach of a Threshold.
- Select Availability and Alert check-box to initiate monitoring.
- From Monitors section, click Add button.
- Click Save.
Step 4: Assign template
You need to create credentials to assign a template to a resource.
Prerequisite
Assign Credentials to access the required device and assign the template.
Creating credentials for the template
To create a credential:
- From All Clients, select a client.
- Go to Infrastructure > Resources, select a device.
Navigates to the device information page. - From the center pane, click Credentials > +Add.
- From Create New Credentials, provide the following:
- Name
- Description of the new credentials.
- From the Type drop-down list, select Windows.
- Username
- Password
- Confirm Password.
- Connection Time Out (ms)
- Click Save.
Assigning templates
To assign a template to a device:
- From the left pane, click Infrastructure.
The Infrastructure screen of the selected client appears. - From Resources tab, select a required resource from the list of resources. Alternatively, use the search option to locate the resource.
- Click the resource name to view details.
- From the left pane, click Monitors.
Templates tab appears. - From Templates tab, click +Assign Templates.
Apply Templates screen appears. - From Apply Templates, select the desired templates.
The selected Templates section displays the chosen templates. - Click Assign.
The template gets assigned to the selected device.
After assigning the template to a resource for monitoring, click Get Latest Metric Values to view the latest metric information.
Step 5: View graphs
OpsRamp Gateway monitors the remote system using the assigned templates and displays the results in a graphical format.
To view the monitoring graphs:
- From the left pane, click Infrastructure.
The Infrastructure screen of the selected client appears. - From Resources tab, select a required resource from the list of resources. Alternatively, use the search option to locate the resource.
- Click the resource name to view details.
- From the left pane, click Metrics.
The Metrics page displays graphs generated by all monitoring templates assigned to a device. - Search with the desired template name to filter the graphs.
Set up agentless custom monitors via Remote Script Executor monitors
Using Remote Script Executor, you can execute scripts on both Linux and Windows workstations with different script types.
Key highlights
- User-defined external arguments support to the script through custom attributes.
- Monitor Level script execution – Ability to pull more metrics in a single script execution.
- Ability to execute different types of scripts through custom script options apart from default options.
- Able to use Credentials attached to the device in the script using the dynamic macro’s support.
- The monitoring of Windows Workstations through Linux Gateway is not supported.
Prerequisite:
OpsRamp Gateway version 7.0.0 supports Remote Script Executor monitoring.
Monitoring using Remote Script Executor includes the following steps:
- Create Metrics
- Create a custom Remote Script Executor monitor and add the corresponding metrics of the same type
- Create a template with Remote Script Executor monitor
- Assign the template to a device
- Get the latest metric value
- View Graphs
Step 1: Create metrics
Metrics provide the metadata to correlate the script output and must match the metricsNames added to the Monitor.
- From All Clients, select a client.
- Go to Setup > Monitoring > Metrics.
METRICS screen appears. - From METRICS, click + Add and provide the following:
- Metric Scope: Select Partner Metric or Client Specific Metric
- Adaptor Type: Select Application.
- Application Type: Select Remote Script Executor.
- Name: Refers to the unique Name for the metric.
OpsRamp recommends<vendorname>.<application name>.<component>.<metric>
as naming convention for the metric. For example, apache.tomcat.webapps.count. - Tag Name: Refers to the user-defined tags for better filtering.
- Display Name: Provide Display Name. For example, System Drive Free Space.
- Description: Provide the purpose of the metric.
- Data Point type: Refers to the value chosen to plot data in the graph.
- Units: Refers to the required values for Units. You can choose Units depending on the chosen Data Point Type.
- Unit Multiplication Factor: Refers to the value chosen to multiply a value based on the chosen unit.
- Data Point Conversion: Refers to one of the following options:
- Value: To populate data via values.
- Enumerated Map: To populate alert and graph details after adding the states such as Up or Down. The screen displays an additional section where you can add the state descriptions and select Alerts and Graphs to populate data.
- Metric Processing: Refers to one of the following values for processing the Metric:
- Notification
- Graph
- Graph and Notification.
- To configure values for Graph and Notification:
- Warning if value: Refers to the warning threshold value.
- Critical if value: Refers to the critical threshold value.
- Subject: Refers to the subject for the metric.
- Description: Refers to the description for the metric.
- Click Save.
Step 2: Create monitor
Custom Remote Script Executor Monitor is a collection of Remote Script Executor metrics. You can create a template using the Remote Script Executor monitor.
Prerequisites:
Add the required custom parameters.
Macros in Remote Script Executor
Macros are implemented to address the passing of dynamic arguments to scripts. Use the following macros to make available native attributes and custom attribute defined on the resource, within the script:
Static macros
Using the Static Macros, OpsRamp overrides the values that you provide in the script.
Description of static macros
Macro | Description |
---|---|
${resource.ipaddress} | The IP address of the device |
${resource.mac} | Mac address of the device |
${resource.serialno} | Serial Number of the device |
${resource.make} | Make of the device |
${resource.model} | Model of the device. |
${resource.hostname} | The hostname of the device |
${resource.uniqueid} | UniqueId of the device |
${resource.os} | Operating System of the device |
Dynamic macros
Using Dynamic Macros, you can perform the following actions:
- Get custom attributes of the device – If you want to use an argument in any script, you can apply the custom attributes to the device.
Syntax: ${customattributes.customAttributekey}. For example, you have a custom Attribute on the device withKey: serviceName
andValue: oracledb
. During runtime, the Value: oracledb replaces the macro:${customattributes.serviceName}
in the script. - Get the credentials added to the device – You can use (macros) credentials in the script to avoid keeping the original username and password in plain text. The macros replace the original credentials when you execute the script.
Syntax:${credentials.CredentialName.credentialField}
. For example, you define a Credential set of Name JMXCred and added to a device. You can use the macro ${credentials.JMXCred.username} in your script. The macro replaces the original credentials in your script at runtime.
Script execution path for configuration parameters in Linux and Windows
Gateway | Target Platform | ||
---|---|---|---|
Script Type | Linux/SSH | Windows | |
Linux Gateway | Bash | bash -s | Not Applicable |
Powershell | Not Applicable | Not Applicable | |
Python | python - | Not Applicable | |
Perl | Perl - - | Not Applicable | |
Windows Gateway | Bash | bash -s | |
Powershell | Not Applicable | powershell.exe | |
Python | python - | python.exe | |
Perl | Perl - - | perl.exe |
If your runtime is not set as an environment variable, mention the absolute path of your runtime. For example, if Python is not set as an environment variable, provide the absolute path of Python such as /usr/lib/python
.
Create Monitor
To create a custom Remote Script Executor monitor:
- From All Clients, select a client.
- Go to Setup > Monitoring > Monitors.
MONITORS screen appears. - From Monitors, click + Add.
CREATE A MONITOR screen appears. - From CREATE A MONITOR, provide the details for the following parameters and click Save.
- Monitor Scope: Select either Partner Monitor or Client Specific Monitor.
- Type: Select Application.
- Application Type: Select Remote Script Executor.
- Name: Provide a unique name for the metric.
- Description: Provide the purpose of creating the monitor.
- Script: Refers to the custom script in the Script text box. You can refer to sample script and JSON output formats to view the sample script.
- Metrics: To add Metrics:
- From Metrics, click Add Metrics. Metrics screen appears.
- Search the desired metric and click Add Metrics. Metrics section displays the selected metric.
- After adding the metrics, navigate to Configuration Parameters.
- Configuration Parameters: To add configuration Parameters:
- Provide Default Value for all the configuration parameters.
- Select the Configurable checkbox.
- Click +Add.
Configuration Parameters screen appears. - Provide Configuration Parameters depending on the selected script type.
You can view the default value for the respective Name selected.
Note: If you select the Custom value in Configuration Parameters, add the configuration parameter:custom.script.execution.path
.
MONITORS screen displays the new monitor.
Step 3: Create template
A template is an instance of a monitor and is applied to devices.
To create a template:
- From All Clients, select a client.
- Go to Setup > Monitoring >Templates.
TEMPLATES screen appears. - Click + Add.
MONITOR TEMPLATE screen appears. - From MONITOR TEMPLATE, provide the details for the following parameters and click Save.
- Select Template Scope: Refers to the Template type.
- Collector Type: Select Gateway.
- Monitor Type: Select Monitors for G2 Templates.
- Applicable for: Select Device.
- Template Name: Refers to the name of the template.
- Description: Refers to the summary of the template.
- Generation: Refers to the generation that the template belongs to.
- Tags: Refers to the user-defined tags for better filtering.
- Prerequisites: Refers to the essential things that you must consider while monitoring using the template. For example, check the SQL services while monitoring the SQL Parameters using the Windows templates.
- Status: Refers to the Active or End-of-life templates.
- Notes: Refers to the additional information that you want to add to the template.
- Template Family Name: Refers to the category that applies to the application. For example, Windows Server, Storage Server, and Network Server.
- Deployment Type: Refers to one of the following methods to apply the template to the resources:
- Custom
- Optional
- Standard
- After providing the template details, MONITOR TEMPLATE displays the Monitors section.
Note: The user interface for the Monitors section varies with the option selected in the Collector Type.- Monitor: To add details in Monitors:
- From Monitors section, click Add.
The monitor screen appears. - Provide details for the following parameters:
- Frequency: Refer to the frequency to execute the template.
- Monitor Definition: Refers to the monitor type.
- When to Alert: Select Breach of a Threshold.
- Select Availability and Alert check-box to initiate monitoring.
TEMPLATES section displays the configured details.
Assign template to a device
You need to create credentials to assign a template to a device.
Prerequisite
Assign Credentials to access the required device and assign the template.
Creating credentials
Important
If the configuration parameter remote.server.operating system
is:
- Windows, you must consider Windows type credentials.
- LINUX or UNIX, you must consider SSH type credentials.
To create credentials:
- From All Clients, select a client.
- Go to Infrastructure > Resources.
- From the list of devices, select a device. Navigates to the device information page.
- From the center pane, click Credentials. Credentials screen appears.
- Click +Add.
Create new credential screen appears. - From Create new credential, provide details for the following parameters and click Save:
- Name: Refers to the name of the credential.
- Description: Refers to the description of the new credential.
- Type: Refers to the application type. Select Windows.
- Username: Refers to the username for the credential set.
- Password: Refers to the password that you set for the credential set.
- Confirm Password: Provide the same password.
- Port: Refers to the port used to connect to the application.
- Connection Time Out (ms): Refers to the time taken for the resource to connect to the application.
Credentials screen displays the new credentials
Assigning template
To assign a template to a device:
- From the left pane, click Infrastructure.
The Infrastructure screen of the selected client appears. - From Resources tab, select a required resource from the list of resources. Alternatively, use the search option to locate the resource.
- Click the resource name to view details.
- From the left pane, click Monitors.
Templates tab appears. - From Templates tab, click +Assign Templates. Apply Templates screen appears.
- From Apply Templates, select the desired templates.
The selected Templates section displays the chosen templates. - Click Assign.
The template gets assigned to the selected device.
After assigning the template to a resource for monitoring, you can click Get Latest Metric Values to view the latest metric information.
Viewing graphs
OpsRamp Gateway monitors the remote system using the assigned templates and displays the results in a graphical format.
To view the monitoring graphs:
- From the left pane, click Infrastructure.
The Infrastructure screen of the selected client appears. - From Resources tab, select a required resource from the list of resources. Alternatively, use the search option to locate the resource.
- Click the resource name to view details.
- From the left pane, click Metrics.
The Metrics page displays graphs generated by all monitoring templates assigned to a device. - Search with the desired template name to filter the graphs.
Troubleshooting
- The device is accessible to the Gateway
- The appropriate port is available from the remote server.
- Must not support the monitoring of Windows Workstations through Linux Gateway.
Sample: Bash scripts
In these samples:
- Datapoints are used for plotting graphs.
- Tokens are used for alert information.
system_load=`cat /proc/loadavg | awk '{print $2}'`
printf "{\n\"datapoints\":{\n\t\"System Load\" : %s\n},\n\"tokens\": {\n\t\"Current System Load\" : \"%s\"\n}\n}\n" "${system_load}" "${system_load}"
Bash single datapoint and token
This sample is JSON output for a single datapoint and token.
{
"datapoints":{
"System Load" : 1.60
},
"tokens": {
"Current System Load" : "1.60"
}
}
Bash multiple datapoints and tokens
This sample is JSON output for multiple datapoints and tokens.
{
"datapoints":{
"DiskC" : 50,
"DiskD" : 81
},
"tokens": {
"disk_utilization.total" : "DiskC : 40 GB, DiskD : 100 GB",
"disk_utilization.used" : "DiskC : 20 GB, DiskD : 50 GB"
}
}
Sample: PowerShell script
$Disk = Get-WMIObject Win32_Logicaldisk -filter "deviceid='C:'"
$DiskUtil = ((($Disk.Freespace /1Gb -as [float]) / ($Disk.Size / 1Gb -as [float]))*100) -as [int]
$TotalSpaceUtilized = 100 - $DiskUtil
write-host @" { "datapoints": { "DiskC": $TotalSpaceUtilized }}"@
PowerShell single instance
In this sample, JSON output is provided for a single instance.
{
"datapoints" : {
"DiskC" : 50,
"DiskD" : 81
}
}
PowerShell multiple instances
In this sample, JSON output is provided for a multiple instances.
{
"datapoints" : {
"DiskC" : 50,
"DiskD" : 81
}
"alerttokens": {
"disk_utilization.total" : "DiskC : 40 GB, DiskD : 100 GB",
"disk_utilization.used" : "DiskC : 20 GB, DiskD : 50 GB"
}
}
Sample: Remote script executor script
#!/bin/bash
CPU=$(top -bn1 | grep load | awk ‘{printf “%.2f\t\t\n”, $(NF-2)}’)
MEMORY=$(free -m | awk ‘NR==2{printf “%.2f\t\t”, $3*100/$2 }’)
DISK=`df -h | awk ‘$NF==”/”{ print $5}’ | sed ‘s/%//g’`
printf “{\”disk.utilization\” : %s , \”memory.utilization\” : %s , \”cpu.usage\” : %s}” “$DISK” “$MEMORY” “$CPU”
Output :
{“disk.utilization” : 23 , “memory.utilization” : 24.28 , “cpu.usage” : 0.64 }
standard JSON Output formats: Remote script executor script
Format 1
{
“Metric1”: 98,
“Metric2”: 70,
“Metric3”: 80
}
Format 2
{
“Metric1”: 98,
“Metric2”: “STATE”,
“Metric3”: 80
}
}
Format 3
{
"MetricName1": {
"components": {
"component1": 70,
"component2": 98
}
},
"MetricName2": {
"components": {
"component1": 77,
"component2": 98
}
}
}
Format 4
alertTokens: Using alertTokens, you can add more information to the alert Subject and Description.
{
"MetricName1": {
"components": {
"component1": "STATE",
"component2": 98
},
"alertTokens": {
"token1": "value",
"token2": "value2"
}
},
"MetricName2": {
"components": {
"component1": 77,
"component2": 98
},
"alertTokens": {
"token1": "value",
"token2": "value2"
}
}
}
Format 5
{
"MetricName1": 254,
"MetricName2": {
"components": {
"comp1": 90,
"comp2": 60
}
},
"MetricName3": {
"components": {
"component1": "STATE",
"component2": 98
},
"alertTokens": {
"token1": "value",
"token2": "value2"
}
}
}