Scripts with text output
As described in Use script monitors in SAM, SAM looks for two main things when a script return values for target servers:
- An exit code that indicates if the script ran successfully. That value is used to report the status of the monitor in the Orion Web Console. See Report status through exit codes in SAM script monitors.
- Script output consists of returned metrics that generate an output, which is then displayed in the Orion Web Console.
Scripts can also report additional details by sending text to the script’s standard output, such as informational text or error details. Depending on your needs, you can create different If/Then/Else statements for the statistic value that each have a different Message format so you know what your script is doing.
Want to see how other SolarWinds customers work with scripts? Visit the Server & Application Monitor forum in THWACK.
Note the following details about text output:
- There is a limit of ten Statistic and Message pairs per script. Each Statistic is a numeric value; each Message is readable text.
- Statistic and Message pairs can be placed anywhere in the script output.
- The Statistic and Message names you give must contain valid letters and/or numbers.
- Named pairs can be dynamically defined in the code, but SAM expects the output to remain consistent.
Additionally, the Message variable use the same value as your Statistic variable (for example,
Message.value2). If your Message.<name> does not match your Statistic.<name>, then SAM will throw an error.
A numeric value used to determine how the monitor compares to its set thresholds. This must be an integer value; negative numbers are supported.
An error or information message to be displayed in the monitor status details. Multi-line messages are supported. To use this functionality, print each line using a separate command.
# Script comment: This shows two pairs. Ten pairs are possible. Statistic.CPU: 31.08Message.CPU: svchost.exe cpu usage Statistic.RAM: 1234.56Message.RAM: svchost.exe ram usage