#!/usr/bin/php # # 11-08-2016 # Author: Pablo Garcia # -P= -p= -w= -c=\n\n"; echo "Examples:\n\n"; echo "To get the queue usage for one host:\n"; echo "./get_queue_sm.php -H=X.Y.C.D -P=80 -p=ABCD -w=400 -c=600\n"; exit(3); } $mx_user = "admin"; $mx_namespace = "svcServerAdmin"; if ($argc > 0) { $indice = 0; $hay_error_parseo = 0; for($i=1;$i < $argc;$i++) { parse_str($argv[$i],$tmp); if($i == 1) { if(substr_count($argv[$i],"-H=") == 0) { $hay_error_parseo = 1; } else if(!is_string($tmp["-H"])) { $hay_error_parseo = 2; } $host_check = $tmp["-H"]; } else if($i == 2) { if(substr_count($argv[$i],"-P=") == 0) { $hay_error_parseo = 3; } else if(!is_string($tmp["-P"])) { $hay_error_parseo = 4; } $port_host = $tmp["-P"]; } else if($i == 3) { if(substr_count($argv[$i],"-p=") == 0) { $hay_error_parseo = 5; } else if(!is_string($tmp["-p"])) { $hay_error_parseo = 6; } $password_value = $tmp["-p"]; } else if($i == 4) { if(substr_count($argv[$i],"-w=") == 0) { $hay_error_parseo = 7; } else if(!is_numeric($tmp["-w"])) { $hay_error_parseo = 8; } $warning_value = intval($tmp["-w"]); } else if($i == 5) { if(substr_count($argv[$i],"-c=") == 0) { $hay_error_parseo = 9; } else if(!is_numeric($tmp["-c"])) { $hay_error_parseo = 10; } $critical_value = intval($tmp["-c"]); } } } if($hay_error_parseo != 0) { echo "Bad parameter (Error Code $hay_error_parseo)\n\n"; echo "Usage: check_queue_sm.php -H= -p= -w= -c=\n\n"; echo "Examples:\n\n"; echo "To get the queue usage for one host:\n"; echo "./get_queue_sm.php -H=X.Y.C.D -P=80 -p=ABCD -w=400 -c=600\n"; exit(3); } $host_name_real = gethostbyaddr($host_check); if($host_name_real == $host_check) { my_exit(3,"SERVER DOES NOT EXIST"); } $objeto_mx = new mx_wsdl($host_name_real,$port_host,$mx_user,$password_value,$mx_namespace); $spool_status = intval($objeto_mx->get_spool_status()); if($spool_status > $critical_value) { my_exit(2,"QUEUE $spool_status messages"); } else if($spool_status > $warning_value) { my_exit(1,"QUEUE $spool_status messages"); } else { my_exit(0,"QUEUE $spool_status messages"); } ?>