Now let's monitor this SNMP MIB with another SNMP monitoring script called netsnmp-exec.monitor. Copy this script from the chapter17 directory on the CD-ROM into the /usr/lib/mon/mon.d directory, and set the permissions of the file so Mon can execute it:
#cp /mnt/CDROM/chapter17/netsnmp-exec.monitor /usr/lib/mon/mon.d #chmod 755 /usr/lib/mon/mon.d/netsnmp-exec.monitor
Create a mon.cf service entry (underneath the existing watch clusternodes entry) that looks like this:
service custom-snmp-monitor-script description Checks the output of the custom SNMP script interval 5s monitor netsnmp-exec.monitor depend clusternodes:ping period wd {Su-Sa} alert mail.alert alert@yourdomain.com upalert mail.alert alert@yourdomain.com
(Of course, you would normally install this script on all of the cluster nodes and modify the /etc/snmp/snmpd.conf file on all of the cluster nodes.)
You can test this Mon configuration (once you've restarted Mon) by modifying the check-dns script again and changing the host to a bogus host. This should cause Mon to raise the alert you have specified (Mon will send an email to alert@yourdomain.com in this example).
You can have multiple custom monitoring scripts. Each additional script can be monitored individually with the netsnmp-exec.monitor script by passing it the -n argument followed by a number to represent which script to use from the snmpd.conf file. The default, if the -n argument is not used, is to check all scripts.
Note | You may also want to use the -t 10000 argument to specify a timeout value for the netsnmp-exec.monitor script in your mon.cf entry. |