Checking Software Version Script
Posted: Mon Aug 27, 2012 11:16 am
Hi Guys,, can you help me here. How come this wont work?
im passing the $sw via the command externally,
but everytime its always CRITICAL. i am trying to make it so IF my defined SW version is != to the Current one on the server then Warn, If its missing, then Critical, if it matches then its OK
exec("snmpget -v 2c -c public $host $oid | cut -d':' -f4 | sed -e 's/^[ ]*//'", $info);
$current_info = ($info[0]);
if ($current_info !== $sw){
$aux = "CRITICAL - $current_info | RPM=$current_info";
if ($status < 2)
$status = 2;
}
else if ($current_info > $sw){
$aux = "WARNING - $current_info | RPM=$current_info";
if ($status < 1)
$status = 1;
}
else{
$aux = "OK - $current_info | RPM=$current_info";
}
$msg .= "$aux $current_info[0]";
im passing the $sw via the command externally,
but everytime its always CRITICAL. i am trying to make it so IF my defined SW version is != to the Current one on the server then Warn, If its missing, then Critical, if it matches then its OK
exec("snmpget -v 2c -c public $host $oid | cut -d':' -f4 | sed -e 's/^[ ]*//'", $info);
$current_info = ($info[0]);
if ($current_info !== $sw){
$aux = "CRITICAL - $current_info | RPM=$current_info";
if ($status < 2)
$status = 2;
}
else if ($current_info > $sw){
$aux = "WARNING - $current_info | RPM=$current_info";
if ($status < 1)
$status = 1;
}
else{
$aux = "OK - $current_info | RPM=$current_info";
}
$msg .= "$aux $current_info[0]";