To create a nagios plugin we need to keep in the mind the exit codes of the program/plugin which is interpreted by nagios to determine the status of the service.
1 2 3 4 5 | Return Code Status 0 OK. The service is functioning normally 1 WARNING. The service is about to reach to a critical state prior flagging it as CRITICAL 2 CRITICAL. The service is down 3 UNKNOWN. the plugin cannot determine the status of the service. |
So any plugins you make should have an exit status, depending on the checks performed, here we will create a python snmp plugin using the pysnp module, the script also uses the optparse module so that arguments can be passed to the command line. Based on my previous post to monitor mysql database using mysql-snmp NetSNMP agent, I used the python pysnmp module to poll the mysql mib on the remote mysql server.
First create the host,hostgroup and the service for checking mysql innodb transactions in nagios
1 2 3 4 5 6 7 8 | define host{ use linux-server ; Name of host template to use ; This host definition will inherit all variables that are defined ; in (or inherited by) the linux-server host template definition. host_name mysqlserver alias mysqlserver address 192.168.221.188 } |