Next Topic

Previous Topic

Book Contents

Sample Plugin Monitor with Discrete Thresholds

This is an example of a sample atmosphere pressure monitor which uses discrete thresholds.

  1. Create a test type definition file: plugin/monitors/my_atmosphere.xml with the following contents.
<monitor type="atmosphere" plugintype="script">
<testtype>
<displayName>Atmospheric Pressure</displayName>
<displayCategory>application</displayCategory>
<subType>pressure</subType>
<units>psi</units>
<severity_ascends_with_value>discrete</severity_ascends_with_value>
<defaultWarningThreshold>2,5</defaultWarningThreshold>
<defaultCriticalThreshold>4,8-10,99</defaultCriticalThreshold>
<shadowWarningThreshold>2,5</shadowWarningThreshold>
<shadowCriticalThreshold>4,8-10,99</shadowCriticalThreshold>
<slaThreshold>8-10</slaThreshold>
<testInterval>60</testInterval>
</testtype>
<script type="atmosphere" subType="pressure">
	<rootScript>run.sh</rootScript>
	<parameters></parameters>
	<waitForTerminate>true</waitForTerminate>
	<timeout>15</timeout>
</script>
</monitor>


Note how the thresholds have been specified as discrete values. If the polled result is 2 or 5, the test is in a warning state. Critical is 4,8,9,10 and 99. Everything else is OK.

  1. Now create the monitor in the plugins/monitors/ directory under a directory with the same name as the test type, and name it as indicated in the test type definition above (plugins/monitors/atmosphere/run.sh)
#!/bin/sh
#if [ -f "/tmp/atmosphere.dat" ]; then
	cat /tmp/atmosphere.dat
else
	echo 0
fi
  1. Now restart the web application, and then provision the test:
    1. Log in as end user.
    2. Click on Administration > Devices > Tests.
    3. Click on Add New Standard Tests.
    4. Check Atmosphere.
    5. Enable the test, and make sure that discrete is selected as a severity option.
    6. Submit the form.
  2. To test this, enter values into /tmp/atmosphere.dat and you can see the test status change in each polling cycle:
echo 99 >/tmp/atmosphere.dat
echo 5 > /tmp/atmosphere.dat
echo 6 > /tmp/atmosphere.dat