Date: Thu, 28 Mar 2024 13:58:23 +0000 (UTC) Message-ID: <784306463.5387.1711634303161@ip-10-0-1-161.ec2.internal> Subject: Exported From Confluence MIME-Version: 1.0 Content-Type: multipart/related; boundary="----=_Part_5386_1666344536.1711634303157" ------=_Part_5386_1666344536.1711634303157 Content-Type: text/html; charset=UTF-8 Content-Transfer-Encoding: quoted-printable Content-Location: file:///C:/exported.html
Cont= ents
This article is part of a series:
Part 1 =
- Creating Custom Service Monitors in Uptime Infrastructure Monitor
=
Part 2 - Creating Custom Service Monitors with Retained =
Data Collection
Part 3 - Creating Plugin Servi=
ce Monitors in Uptime Infrastructure Monitor
Custom service monitors with retained data tracking expand on the basic = Custom service monitor by allowing you to retain and graph historical trend= ing information returned from your custom script. This enables you to store= up to 10 custom application or business metrics per monitor within Uptime = Infrastructure Monitor just like system performance metrics returned by the= Uptime Infrastructure Monitor agent. This article builds on the scripts an= d knowledge that were developed in a previous article. Take some time to re= view the previous article before continuing.
Example graph produced using a custom service monitor w=
ith retained data.
To use a custom script with retained data with Uptime Infrastructure Mon= itor, you must change the output format produced by your script. All of the= rules found in a regular custom service monitor still apply with a few sli= ght modifications, as detailed below:
> check_temp.sh
10.5
99
Using the check_temp.sh s= cript as a basis for this example, you can easily change the script to fit = within the context of a custom service monitor with retained data. To do th= is, you must make the following changes to the script:
Previous Format - For a regular custom service=
monitor.
> ./check_temp.sh test-agent 9998 temp 60 80
WARNING - temperature is 64.5 on test-agent
> ./check_temp.sh test-agent 9998 rh 25 30
CRITICAL - humidity is 32.8 on test-agent
New Format - For a custom service monitor with retained performance=
data.
> ./check_temp.sh test-agent 9998
64.5
32.8
To produce the output listed above, you must edit the script so that it = looks like the following example:
#!/bin/= sh # This script takes the following arguments: # check_temp.sh hostname port # Example execution: # ./check_temp.sh my-agent 9998 # This script can be placed anywhere on the monitoring station system as lo= ng as it is # executable by the uptime user. #First, collect our arguments AGENT=3D$1 PORT=3D$2 TMPFILE=3D/tmp/$$.temp # now use the info above to contact our agent, store the output in a file f= or parsing `echo -n rexec secretpassword /opt/uptime-agent/my-scripts/show_temp.sh my-= arguments | /usr/local/uptime/bin/netcat $AGENT $PORT > $TMPFILE`
Note
`echo -= n /opt/uptime-agent/my-scripts/show_temp.sh my-arguments | /usr/local/uptim= e/scripts/agentcmd -p $PORT $AGENT rexec secretpassword > $TMPFILE`
For more information see = Using the agentcmd utility.
# we ha= ve the output from the agent. If it is ERR that means there was a problem r= unning the script on the agent `grep ERR $TMPFILE` if [ $? -eq 0 ] then echo "Could not execute agent side script!"=20 # by exiting with a 2 we are forcing a CRIT service outage exit 2 fi # in this script we don't need to check thresholds or determine which infor= mation to check # we just need to reformat the agent side script output slightly so that on= ly numerical info is displayed # we do this by trimming off the first word returned on each line from the = agent, leaving just the numbers # and printing that to screen, Uptime Infrastructure Monitor will handle th= e rest awk '{print $2}' $TMPFILE exit 0
Next, add your custom service monitor with retained performance metrics = to the Uptime Infrastructure Monitor Web interface using the same process t= hat you would use to add a standard custom service monitor to Uptime Infras= tructure Monitor. The Custom with R= etained Data monitor option is found in the List Other Monitors section of the Add New Service Instance page.
The Custom with Retained Data service monitor template has the foll= owing monitor-specific settings:
Option Name | Description | Example |
Script Name | The script name is the = path to your monitoring station script, this is the script that Uptime Infr= astructure Monitor will execute when running this service monitor. Be sure = to use the complete path wherever possible and that the path is to a locall= y mounted volume. For Windows script paths you must use UNIX style director= y separators (/ instead of ) and also place double quotes around the entire= script name | UNIX/Linux Example: /usr/local/uptime/check_temp.sh Windows Example: "C:/my scripts/check_temp.bat" |
Arguments | These are the arguments= that you would like Uptime Infrastructure Monitor to pass into your monito= ring station script. No arguments are required but please be aware that Upt= ime Infrastructure Monitor will automatically include the selected hostname= as the first argument to your script. | temp 60 80 |
Variable 1-10 Warning= td> | This is the warning thr= eshold used against the output returned from your monitoring station script= . This is a numeric comparison. You must select both a comparison method an= d a threshold value to enable the warning level threshold | Output contains: "warni= ng" |
Variable 1-10 Critical<= /td> | This is the critical th= reshold used against the output returned from your monitoring station scrip= t. This is a numeric comparison. You must select both a comparison method a= nd a threshold value to enable the critical level threshold | Output contains: "criti= cal" |
Retained Data Tracking<= /td> | This check box determin= es if Uptime Infrastructure Monitor will not only check the variable for th= reshold violations but will also retain the returned values for graphing at= a later time. In most cases you should check this box, without it data for= the indicated variable will not be retained for graphing. | N/A |
Based on the settings used in the example monitoring station script, con= figure the monitor with the following setting:
Example monitor configuration
The image below illustrates a sample monitor configuration. This service= monitor will indicate a WARN or CRIT whenever the monit= oring station custom script returns WARNING or CRITIC= AL in its output.