Monitoring Agent internal test examples

When you add internal tests for Monitoring Agents to the sgagent.conf file, you can use the following examples as a guide.

Each test has an example configuration, which might differ from what you configure for your own environment.

swapfree

This example checks that there is at least 1500 kilobytes of free space on server 2. The test runs at one-hour intervals and sends an alert if the test fails.
test “swapfree test”
interval 1:00:00
host server2
action alert
command swapfree 1500

process_count

This example checks that there are a maximum of 2500 processes running on server2. The test runs at 60-second intervals and sends an alert if the test fails:
test process_count
interval 60
host server2
action alert
command prosesscount 2500

multi-ping

This example tests the connectivity of server2. The tester sends three ICMP Echo requests to the IP addresses 192.168.1.2 and 192.168.1.254, and waits 1000 milliseconds for a reply. The test runs at 30-second intervals. If the test fails, server2 is excluded from the Server Pool.
test “multi-ping test”
interval 30
host server2
action exclude
command multi-ping 3 1000 192.168.1.2 192.168.1.254

filesystem

This example checks that there is at least 1000 kilobytes of free space in the /var/tmp partition on server2. The test runs at 15-second intervals and sends an alert if the test fails.
test “free space in filesystem”
interval 15
host server2
action alert
command filesystem /var/tmp 1000

servicerunning

This example checks that the ntpd service is running. The test runs at 15-second intervals. If the test fails, the ntpd start script is run. If the test succeeds again within one minute of failing, recovery occurs and the server is returned to the OK state. Otherwise, the server is excluded from the Server Pool.
test “is ntp running -test”
interval 15
script /etc/init.d/ntpd start
action exclude
recovery 1:00
command servicerunning ntpd

ip-listening

This example checks that server2 is listening at the IP address 192.168.1.1. The test runs at 30-second intervals, and the server is excluded from the Server Pool if the test fails.
test ip-listening
interval 30
host server2
action exclude
command iplistening 192.168.1.1

port-listening

This example checks that server2 and server3 are listening on port 80. The test runs at 30-second intervals, and the server is excluded from the Server Pool if the test fails.
test port-listening
interval 30
host server2 server3
action exclude
command portlistening 80

httpanswer

This example checks that the server sends the contents of the file /web/file.html as a part of its response to a URL request for http://www.example.com/index.html on port 80. The request is attempted four times, and the tester waits 3500 milliseconds for a response before retrying. The test runs at 30-second intervals, and the server is excluded from the Server Pool if the test fails.
test http_answering
interval 30
action exclude
command httpanswer 4 3500 /www.example.com/index.html /web/file.html 80

networkinterface-up

This example checks that the eth0 interface is up. The test runs at 45-second intervals, and an alert is sent if the test fails.
test etc0_up
interval 45
action alert
command networkinterface-up eth0

networkinterface-linkstatus

This example checks that the eth0 interface is linked. The test runs at 45-second intervals, and an alert is sent if the test fails.
test “link status on eth0”
interval 45
action alert
command networkinterface-linkstatus eth0

file-exists

This example checks that the /important/index.html file exists. The test runs at 2-minute intervals, and an alert is sent if the test fails.
test “index -file exists”
interval 2:00
action alert
command file-exists /important/index.html