RabbieBurns,
This looks like a php script that is run via shell to return exit codes. Nagios then interprets these exit codes as:
0 OK
1 WARNING
2 CRITICAL
anything else as Unknown
Having written custom checks before, Nagios is just looking for these exit codes to determine if the threshold you're defining is 0,1,2 and based on this return code, it knows what to do and what to display.
Here are the variables you need to pass:
function usage($msg)
{
print(basename($_SERVER["argv"][0]) . " v" . VERSION . " (" . VERDATE .")\n\n");
print(basename($_SERVER["argv"][0]) . " -H -c -w \n");
print(" -H Host to check (IP Address)\n");
print(" -c Critical toner threshold (percentage of remaining toner)\n");
print(" -w Warning toner threshold (percentage of remaining toner\n");
You'll want to set something up in commands.cfg like so:
define command{
command_name check_hp2600
command_line /usr/bin/php /usr/lib/nagios/plugins/check_hp_2600.php -H '$HOSTADDRESS$' -c 10 -w 20
}
As an example, I'm saying 10% toner left is critical, 20% left is warning and your php binary is located in /usr/bin/
Then you will want to define this check in your printer.cfg file (guessing this is where you have your printer hosts defined.
# check_hp2600 check
define service{
use generic-service
hostgroup hp2600_printers
service_description HP 2600 Toner Level
check_command check_hp2600
}
You just need to put all the hp2600 printers in their own hostgroup called hp2600_printers and the check should work. If you have problems, then try running the command from the Nagios server's shell:
/usr/bin/php /usr/lib/nagios/plugins/check_hp_2600.php -H -c 10 -w 20