I have an array which checks a file for the OID's and the Name of each. when the array is done i get a list of Raids i have and it displays the result
BUT i want to get a graph so i wanted to display at the end of the msg the results as such, | Drive1=0;;; Drive2=0;;; Drive3=0
0 = OK 1=Warn 3 =Crit
Here's my code, i hacked it up from other plugins i have found.
Code: Select all
$host = $argv[1];
$warn = $argv[2];
$crit = $argv[3];
$type = $argv[4];
$oid_file = "/usr/lib64/nagios/plugins/oid/host_oid_$type.txt";
exec("cat $oid_file | grep ':' | cut -d':' -f2", $oid);
exec("cat $oid_file | grep ':' | cut -d':' -f1", $oid_name);
//print_r($oid);
//print_r($oid_name);
$msg = "";
$status = 0;
for ($i=0; $i<sizeof($oid); $i++){
$passing_oid=$oid[$i];
$passing_name=$oid_name[$i];
$state = "";
exec("snmpget -v 2c -c public $host $passing_oid | cut -d':' -f4 | sed -e 's/^[ ]*//'", $state);
//print_r($passing_oid);
$current_drivestate = str_replace('"','',$state[0]);
if ($current_drivestate == $crit){
$aux = "($current_drivestate)";
if ($status < 2)
$status = 2;
}
else if ($current_drivestate == $warn){
$aux = "($current_drivestate)";
if ($status < 1)
$status = 1;
}
else{
$aux = "($current_drivestate)";
}
//print_r($current_drivestate);
$msg .= "Status of $passing_name $result <br>";
//$msg .= "|$end_result";
}
Status of RaidArray (ok) <br>Status of Drive1 (ok) <br>Status of Drive2 (ok) <br>Status of Drive3 (ok) <br>Status of Drive4 (ok) <br>
BUT at the end of this i want to have | Drive1=0;;; Drive2= etc etc.. how could i accomplish this?