2009-09-07 11:07:59 +00:00
|
|
|
<?php
|
2007-05-20 19:21:35 +00:00
|
|
|
$id = $device['device_id'];
|
2007-04-03 18:15:19 +00:00
|
|
|
$hostname = $device['hostname'];
|
|
|
|
$community = $device['community'];
|
|
|
|
$snmpver = $device['snmpver'];
|
2009-02-02 16:00:11 +00:00
|
|
|
$port = $device['port'];
|
2008-03-22 23:09:35 +00:00
|
|
|
|
|
|
|
echo("Temperatures : ");
|
2007-11-23 11:37:28 +00:00
|
|
|
|
2008-08-11 09:40:05 +00:00
|
|
|
## JunOS Temperatures
|
2010-01-14 17:16:10 +00:00
|
|
|
if($device['os'] == "junos") {
|
2008-08-11 09:40:05 +00:00
|
|
|
echo("JunOS ");
|
2009-04-24 15:04:45 +00:00
|
|
|
$oids = shell_exec($config['snmpwalk'] . " -m JUNIPER-MIB -$snmpver -CI -Osqn -c $community $hostname:$port 1.3.6.1.4.1.2636.3.1.13.1.7");
|
2008-08-11 09:40:05 +00:00
|
|
|
$oids = trim($oids);
|
|
|
|
foreach(explode("\n", $oids) as $data) {
|
|
|
|
$data = trim($data);
|
|
|
|
$data = substr($data, 29);
|
|
|
|
if($data) {
|
|
|
|
list($oid) = explode(" ", $data);
|
|
|
|
$temp_oid = "1.3.6.1.4.1.2636.3.1.13.1.7.$oid";
|
|
|
|
$descr_oid = "1.3.6.1.4.1.2636.3.1.13.1.5.$oid";
|
2009-04-24 15:04:45 +00:00
|
|
|
$descr = trim(shell_exec($config['snmpget'] . " -m JUNIPER-MIB -O qv -$snmpver -c $community $hostname:$port $descr_oid"));
|
|
|
|
$temp = trim(shell_exec($config['snmpget'] . " -m JUNIPER-MIB -O qv -$snmpver -c $community $hostname:$port $temp_oid"));
|
2008-08-11 09:40:05 +00:00
|
|
|
if(!strstr($descr, "No") && !strstr($temp, "No") && $descr != "" && $temp != "0") {
|
|
|
|
$descr = str_replace("\"", "", $descr);
|
|
|
|
$descr = str_replace("temperature", "", $descr);
|
|
|
|
$descr = str_replace("temp", "", $descr);
|
2010-02-08 00:31:47 +00:00
|
|
|
$descr = str_replace("sensor", "", $descr);
|
2008-08-11 09:40:05 +00:00
|
|
|
$descr = trim($descr);
|
|
|
|
if(mysql_result(mysql_query("SELECT count(temp_id) FROM `temperature` WHERE temp_oid = '$temp_oid' AND temp_host = '$id'"),0) == '0') {
|
2010-01-25 17:27:29 +00:00
|
|
|
$query = "INSERT INTO temperature (`temp_host`, `temp_oid`, `temp_descr`, `temp_limit`, `temp_current`) values ('$id', '$temp_oid', '$descr'," . ($config['defaults']['temp_limit'] ? $config['defaults']['temp_limit'] : '60') . ", '$temp')";
|
2008-08-11 09:40:05 +00:00
|
|
|
mysql_query($query);
|
|
|
|
echo("+");
|
2010-02-08 00:31:47 +00:00
|
|
|
} elseif (mysql_result(mysql_query("SELECT `temp_descr` FROM temperature WHERE `temp_host` = '$id' AND `temp_oid` = '$temp_oid'"), 0) != $descr) {
|
|
|
|
mysql_query("UPDATE temperature SET `temp_descr` = '$descr' WHERE `temp_host` = '$id' AND `temp_oid` = '$temp_oid'");
|
|
|
|
echo("U");
|
2008-08-11 09:40:05 +00:00
|
|
|
} else { echo("."); }
|
|
|
|
$temp_exists[] = "$id $temp_oid";
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2010-01-14 17:16:10 +00:00
|
|
|
## Papouch TME Temperatures
|
|
|
|
if($device['os'] == "papouch-tme") {
|
|
|
|
echo("Papouch TME ");
|
2010-01-14 17:18:28 +00:00
|
|
|
$descr = trim(shell_exec($config['snmpget'] . " -O qv -$snmpver -c $community $hostname:$port SNMPv2-SMI::enterprises.18248.1.1.3.0"));
|
2010-01-25 17:32:26 +00:00
|
|
|
$temp = trim(shell_exec($config['snmpget'] . " -O qv -$snmpver -c $community $hostname:$port SNMPv2-SMI::enterprises.18248.1.1.1.0")) / 10;
|
2010-01-14 17:16:10 +00:00
|
|
|
if(!strstr($descr, "No") && !strstr($temp, "No") && $descr != "" && $temp != "0")
|
|
|
|
{
|
2010-01-15 10:38:16 +00:00
|
|
|
$temp_oid = "SNMPv2-SMI::enterprises.18248.1.1.1.0";
|
2010-01-14 17:16:10 +00:00
|
|
|
$descr = trim(str_replace("\"", "", $descr));
|
|
|
|
if(mysql_result(mysql_query("SELECT count(temp_id) FROM `temperature` WHERE temp_oid = '$temp_oid' AND temp_host = '$id'"),0) == '0')
|
|
|
|
{
|
2010-01-25 17:27:29 +00:00
|
|
|
$query = "INSERT INTO temperature (`temp_host`, `temp_oid`, `temp_descr`, `temp_precision`, `temp_limit`, `temp_current`) values ('$id', '$temp_oid', '$descr',10," . ($config['defaults']['temp_limit'] ? $config['defaults']['temp_limit'] : '60') . ", '$temp')";
|
2010-01-14 17:16:10 +00:00
|
|
|
mysql_query($query);
|
|
|
|
echo("+");
|
2010-01-15 11:43:26 +00:00
|
|
|
} elseif (mysql_result(mysql_query("SELECT `temp_descr` FROM temperature WHERE `temp_host` = '$id' AND `temp_oid` = '$temp_oid'"), 0) != $descr) {
|
|
|
|
echo("U");
|
|
|
|
mysql_query("UPDATE temperature SET `temp_descr` = '$descr' WHERE `temp_host` = '$id' AND `temp_oid` = '$temp_oid'");
|
|
|
|
} else {
|
|
|
|
echo(".");
|
|
|
|
}
|
2010-01-14 17:16:10 +00:00
|
|
|
$temp_exists[] = "$id $temp_oid";
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2007-11-23 11:37:28 +00:00
|
|
|
## Begin Observer-Style
|
2010-01-15 10:33:12 +00:00
|
|
|
if($device['os'] == "linux") {
|
2009-04-24 15:04:45 +00:00
|
|
|
$oids = shell_exec($config['snmpwalk'] . " -$snmpver -m SNMPv2-SMI -Osqn -CI -c $community $hostname:$port .1.3.6.1.4.1.2021.7891 | sed s/.1.3.6.1.4.1.2021.7891.// | grep '.1.1 ' | grep -v '.101.' | cut -d'.' -f 1");
|
2007-11-23 11:37:28 +00:00
|
|
|
$oids = trim($oids);
|
2010-01-16 00:20:51 +00:00
|
|
|
if ($oids) echo("Observer-Style ");
|
2007-11-23 11:37:28 +00:00
|
|
|
foreach(explode("\n",$oids) as $oid) {
|
|
|
|
$oid = trim($oid);
|
|
|
|
if($oid != "") {
|
2009-04-24 15:04:45 +00:00
|
|
|
$descr_query = $config['snmpget'] . " -$snmpver -m SNMPv2-SMI -Osqn -c $community $hostname:$port .1.3.6.1.4.1.2021.7891.$oid.2.1 | sed s/.1.3.6.1.4.1.2021.7891.$oid.2.1\ //";
|
|
|
|
$descr = trim(str_replace("\"", "", shell_exec($descr_query)));
|
2007-11-23 11:37:28 +00:00
|
|
|
$fulloid = ".1.3.6.1.4.1.2021.7891.$oid.101.1";
|
|
|
|
if(!mysql_result(mysql_query("SELECT count(temp_id) FROM temperature WHERE `temp_host` = '$id' AND `temp_oid` = '$fulloid'"), 0)) {
|
2008-03-22 23:09:35 +00:00
|
|
|
echo("+");
|
2010-01-25 17:27:29 +00:00
|
|
|
mysql_query("INSERT INTO `temperature` (`temp_host`,`temp_oid`,`temp_descr`,`temp_limit`) VALUES ('$id', '$fulloid', '$descr'," . ($config['defaults']['temp_limit'] ? $config['defaults']['temp_limit'] : '60') . ")");
|
2008-03-22 23:09:35 +00:00
|
|
|
} elseif (mysql_result(mysql_query("SELECT `temp_descr` FROM temperature WHERE `temp_host` = '$id' AND `temp_oid` = '$fulloid'"), 0) != $descr) {
|
|
|
|
echo("U");
|
|
|
|
mysql_query("UPDATE temperature SET `temp_descr` = '$descr' WHERE `temp_host` = '$id' AND `temp_oid` = '$fulloid'");
|
|
|
|
} else {
|
|
|
|
echo(".");
|
2007-11-23 11:37:28 +00:00
|
|
|
}
|
|
|
|
$temp_exists[] = "$id $fulloid";
|
|
|
|
}
|
2007-06-06 16:43:08 +00:00
|
|
|
}
|
2007-11-23 11:37:28 +00:00
|
|
|
} ## End Observer-Style
|
|
|
|
|
|
|
|
## Dell Temperatures
|
2010-01-15 10:33:12 +00:00
|
|
|
if(strstr($device['hardware'], "dell")) {
|
2009-04-24 15:04:45 +00:00
|
|
|
$oids = shell_exec($config['snmpwalk'] . " -m MIB-Dell-10892 -$snmpver -CI -Osqn -c $community $hostname:$port .1.3.6.1.4.1.674.10892.1.700.20.1.8");
|
2007-11-23 11:37:28 +00:00
|
|
|
$oids = trim($oids);
|
2010-01-16 00:20:51 +00:00
|
|
|
if ($oids) echo("Dell OMSA ");
|
2007-11-23 11:37:28 +00:00
|
|
|
foreach(explode("\n",$oids) as $oid) {
|
|
|
|
$oid = substr(trim($oid), 36);
|
|
|
|
list($oid) = explode(" ", $oid);
|
|
|
|
if($oid != "") {
|
2009-04-24 15:04:45 +00:00
|
|
|
$descr_query = $config['snmpget'] . " -m MIB-Dell-10892 -$snmpver -Onvq -c $community $hostname:$port .1.3.6.1.4.1.674.10892.1.700.20.1.8.$oid";
|
|
|
|
$descr = trim(str_replace("\"", "", shell_exec($descr_query)));
|
2007-11-23 11:37:28 +00:00
|
|
|
$fulloid = ".1.3.6.1.4.1.674.10892.1.700.20.1.6.$oid";
|
|
|
|
if(!mysql_result(mysql_query("SELECT count(temp_id) FROM temperature WHERE `temp_host` = '$id' AND `temp_oid` = '$fulloid'"), 0)) {
|
2010-01-25 17:27:29 +00:00
|
|
|
mysql_query("INSERT INTO `temperature` (`temp_host`,`temp_oid`,`temp_descr`, `temp_precision`, `temp_limit`) VALUES ('$id', '$fulloid', '$descr', '10', " . ($config['defaults']['temp_limit'] ? $config['defaults']['temp_limit'] : '60') . ")");
|
2008-03-22 23:09:35 +00:00
|
|
|
echo("+");
|
|
|
|
} elseif (mysql_result(mysql_query("SELECT `temp_descr` FROM temperature WHERE `temp_host` = '$id' AND `temp_oid` = '$fulloid'"), 0) != $descr) {
|
|
|
|
mysql_query("UPDATE temperature SET `temp_descr` = '$descr' WHERE `temp_host` = '$id' AND `temp_oid` = '$fulloid'");
|
2009-04-24 15:04:45 +00:00
|
|
|
echo("UPDATE temperature SET `temp_descr` = '$descr' WHERE `temp_host` = '$id' AND `temp_oid` = '$fulloid'");
|
2008-03-22 23:09:35 +00:00
|
|
|
echo("U");
|
2007-11-23 11:37:28 +00:00
|
|
|
} else {
|
2008-03-22 23:09:35 +00:00
|
|
|
echo(".");
|
2007-11-23 11:37:28 +00:00
|
|
|
}
|
|
|
|
$temp_exists[] = "$id $fulloid";
|
|
|
|
}
|
|
|
|
}
|
2010-01-25 17:27:29 +00:00
|
|
|
} ## End Dell Sensors
|
2007-11-23 11:37:28 +00:00
|
|
|
|
2010-01-16 00:20:51 +00:00
|
|
|
## LMSensors Temperatures
|
|
|
|
if($device['os'] == "linux") {
|
|
|
|
$oids = shell_exec($config['snmpwalk'] . " -m LM-SENSORS-MIB -$snmpver -CI -Osqn -c $community $hostname:$port lmTempSensorsDevice");
|
2010-02-07 14:17:02 +00:00
|
|
|
if($debug) { echo($oids."\n"); }
|
2010-01-16 00:20:51 +00:00
|
|
|
$oids = trim($oids);
|
|
|
|
if ($oids) echo("LM-SENSORS ");
|
|
|
|
foreach(explode("\n", $oids) as $data) {
|
|
|
|
$data = trim($data);
|
|
|
|
if($data) {
|
2010-02-03 12:00:07 +00:00
|
|
|
list($oid,$descr) = explode(" ", $data,2);
|
2010-01-16 00:20:51 +00:00
|
|
|
if (substr($descr,0,5) == "temp-")
|
|
|
|
{
|
|
|
|
$split_oid = explode('.',$oid);
|
|
|
|
$temp_id = $split_oid[count($split_oid)-1];
|
|
|
|
$temp_oid = "1.3.6.1.4.1.2021.13.16.2.1.3.$temp_id";
|
2010-01-25 17:32:26 +00:00
|
|
|
$temp = trim(shell_exec($config['snmpget'] . " -m LM-SENSORS-MIB -O qv -$snmpver -c $community $hostname:$port $temp_oid")) / 1000;
|
2010-01-16 00:20:51 +00:00
|
|
|
$descr = str_ireplace("temp-", "", $descr);
|
|
|
|
$descr = trim($descr);
|
|
|
|
if(mysql_result(mysql_query("SELECT count(temp_id) FROM `temperature` WHERE temp_oid = '$temp_oid' AND temp_host = '$id'"),0) == '0') {
|
2010-01-25 17:27:29 +00:00
|
|
|
$query = "INSERT INTO temperature (`temp_host`, `temp_oid`, `temp_descr`, `temp_precision`, `temp_limit`, `temp_current`) values ('$id', '$temp_oid', '$descr',1000, " . ($config['defaults']['temp_limit'] ? $config['defaults']['temp_limit'] : '60') . ", '$temp')";
|
2010-01-16 00:20:51 +00:00
|
|
|
mysql_query($query);
|
|
|
|
echo("+");
|
|
|
|
} elseif (mysql_result(mysql_query("SELECT `temp_descr` FROM temperature WHERE `temp_host` = '$id' AND `temp_oid` = '$temp_oid'"), 0) != $descr) {
|
|
|
|
echo("U");
|
|
|
|
mysql_query("UPDATE temperature SET `temp_descr` = '$descr' WHERE `temp_host` = '$id' AND `temp_oid` = '$temp_oid'");
|
|
|
|
} else {
|
|
|
|
echo(".");
|
|
|
|
}
|
|
|
|
$temp_exists[] = "$id $temp_oid";
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
} ## End LMSensors Temperatures
|
|
|
|
|
2009-12-29 15:19:46 +00:00
|
|
|
## Supermicro Temperatures
|
|
|
|
if($device['os'] == "linux") {
|
|
|
|
$oids = shell_exec($config['snmpwalk'] . " -m SUPERMICRO-HEALTH-MIB -$snmpver -CI -Osqn -c $community $hostname:$port 1.3.6.1.4.1.10876.2.1.1.1.1.3 | sed s/1.3.6.1.4.1.10876.2.1.1.1.1.3.//g");
|
|
|
|
$oids = trim($oids);
|
2009-12-30 21:02:05 +00:00
|
|
|
if ($oids) echo("Supermicro ");
|
2009-12-29 15:19:46 +00:00
|
|
|
foreach(explode("\n", $oids) as $data) {
|
|
|
|
$data = trim($data);
|
|
|
|
if($data) {
|
|
|
|
list($oid,$type) = explode(" ", $data);
|
|
|
|
if ($type == 2)
|
|
|
|
{
|
|
|
|
$temp_oid = "1.3.6.1.4.1.10876.2.1.1.1.1.4$oid";
|
|
|
|
$descr_oid = "1.3.6.1.4.1.10876.2.1.1.1.1.2$oid";
|
2010-01-25 17:27:29 +00:00
|
|
|
$limit_oid = "1.3.6.1.4.1.10876.2.1.1.1.1.5$oid";
|
|
|
|
$descr = trim(shell_exec($config['snmpget'] . " -m SUPERMICRO-HEALTH-MIB -O qv -$snmpver -c $community $hostname:$port $descr_oid"));
|
|
|
|
$temp = trim(shell_exec($config['snmpget'] . " -m SUPERMICRO-HEALTH-MIB -O qv -$snmpver -c $community $hostname:$port $temp_oid"));
|
|
|
|
$limit = trim(shell_exec($config['snmpget'] . " -m SUPERMICRO-HEALTH-MIB -O qv -$snmpver -c $community $hostname:$port $limit_oid"));
|
2009-12-29 15:19:46 +00:00
|
|
|
$descr = str_ireplace("temperature", "", $descr);
|
|
|
|
$descr = trim($descr);
|
|
|
|
if(mysql_result(mysql_query("SELECT count(temp_id) FROM `temperature` WHERE temp_oid = '$temp_oid' AND temp_host = '$id'"),0) == '0') {
|
2010-01-25 17:27:29 +00:00
|
|
|
$query = "INSERT INTO temperature (`temp_host`, `temp_oid`, `temp_descr`, `temp_current`, `temp_limit`) values ('$id', '$temp_oid', '$descr', '$temp', '$limit')";
|
2009-12-29 15:19:46 +00:00
|
|
|
mysql_query($query);
|
|
|
|
echo("+");
|
|
|
|
} else { echo("."); }
|
|
|
|
$temp_exists[] = "$id $temp_oid";
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
} ## End Supermicro Temperatures
|
2007-11-23 11:37:28 +00:00
|
|
|
|
|
|
|
## Cisco Temperatures
|
2009-12-31 19:06:05 +00:00
|
|
|
if($device['os'] == "ios") {
|
2008-03-22 23:09:35 +00:00
|
|
|
echo("Cisco ");
|
2009-04-24 15:04:45 +00:00
|
|
|
$oids = shell_exec($config['snmpwalk'] . " -m CISCO-ENVMON-MIB -$snmpver -CI -Osqn -c $community $hostname:$port .1.3.6.1.4.1.9.9.13.1.3.1.2 | sed s/.1.3.6.1.4.1.9.9.13.1.3.1.2.//g");
|
2007-11-23 11:37:28 +00:00
|
|
|
$oids = trim($oids);
|
|
|
|
foreach(explode("\n", $oids) as $data) {
|
2008-03-22 23:09:35 +00:00
|
|
|
$data = trim($data);
|
|
|
|
if($data) {
|
2007-11-23 11:37:28 +00:00
|
|
|
list($oid) = explode(" ", $data);
|
|
|
|
$temp_oid = ".1.3.6.1.4.1.9.9.13.1.3.1.3.$oid";
|
|
|
|
$descr_oid = ".1.3.6.1.4.1.9.9.13.1.3.1.2.$oid";
|
2010-01-25 17:27:29 +00:00
|
|
|
$descr = trim(shell_exec($config['snmpget'] . " -m CISCO-ENVMON-MIB -O qv -$snmpver -c $community $hostname:$port $descr_oid"));
|
|
|
|
$temp = trim(shell_exec($config['snmpget'] . " -m CISCO-ENVMON-MIB -O qv -$snmpver -c $community $hostname:$port $temp_oid"));
|
2007-11-23 11:37:28 +00:00
|
|
|
if(!strstr($descr, "No") && !strstr($temp, "No") && $descr != "" ) {
|
|
|
|
$descr = str_replace("\"", "", $descr);
|
|
|
|
$descr = str_replace("temperature", "", $descr);
|
|
|
|
$descr = str_replace("temp", "", $descr);
|
|
|
|
$descr = trim($descr);
|
2009-12-29 15:19:46 +00:00
|
|
|
if(mysql_result(mysql_query("SELECT count(temp_id) FROM `temperature` WHERE temp_oid = '$temp_oid' AND temp_host = '$id'"),0) == '0') {
|
2010-01-25 17:27:29 +00:00
|
|
|
$query = "INSERT INTO temperature (`temp_host`, `temp_oid`, `temp_descr`, `temp_limit`, `temp_current`) values ('$id', '$temp_oid', '$descr', " . ($config['defaults']['temp_limit'] ? $config['defaults']['temp_limit'] : '60') . ", '$temp')";
|
2007-11-23 11:37:28 +00:00
|
|
|
mysql_query($query);
|
2008-03-22 23:09:35 +00:00
|
|
|
echo("+");
|
|
|
|
} else { echo("."); }
|
2007-11-23 11:37:28 +00:00
|
|
|
$temp_exists[] = "$id $temp_oid";
|
|
|
|
}
|
2008-03-22 23:09:35 +00:00
|
|
|
}
|
2007-11-23 11:37:28 +00:00
|
|
|
}
|
2008-08-11 09:40:05 +00:00
|
|
|
} ## End Cisco Temperatures
|
2008-03-22 23:09:35 +00:00
|
|
|
|
2007-06-06 16:43:08 +00:00
|
|
|
|
2007-11-23 11:37:28 +00:00
|
|
|
## Delete removed sensors
|
2007-06-06 16:43:08 +00:00
|
|
|
|
2008-03-22 23:09:35 +00:00
|
|
|
$sql = "SELECT * FROM temperature AS T, devices AS D WHERE T.temp_host = D.device_id AND D.device_id = '".$device['device_id']."'";
|
2007-05-20 19:21:35 +00:00
|
|
|
$query = mysql_query($sql);
|
|
|
|
|
|
|
|
while ($sensor = mysql_fetch_array($query)) {
|
|
|
|
unset($exists);
|
|
|
|
$i = 0;
|
|
|
|
while ($i < count($temp_exists) && !$exists) {
|
|
|
|
$thistemp = $sensor['temp_host'] . " " . $sensor['temp_oid'];
|
2007-06-06 09:23:41 +00:00
|
|
|
if ($temp_exists[$i] == $thistemp) { $exists = 1; }
|
2007-05-20 19:21:35 +00:00
|
|
|
$i++;
|
|
|
|
}
|
|
|
|
if(!$exists) {
|
2008-03-22 23:09:35 +00:00
|
|
|
echo("-");
|
2007-06-06 09:23:41 +00:00
|
|
|
mysql_query("DELETE FROM temperature WHERE temp_id = '" . $sensor['temp_id'] . "'");
|
2007-05-20 19:21:35 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2008-03-22 23:09:35 +00:00
|
|
|
unset($temp_exists); echo("\n");
|
2007-05-20 19:21:35 +00:00
|
|
|
|
2007-04-03 18:15:19 +00:00
|
|
|
|
2008-03-22 23:09:35 +00:00
|
|
|
?>
|