$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"); $oids = trim($oids); foreach (explode("\n", $oids) as $data) { $data = trim($data); if ($data) { list($index) = explode(" ", $data); $oid = ".1.3.6.1.4.1.9.9.13.1.3.1.3.{$index}"; $descr_oid = ".1.3.6.1.4.1.9.9.13.1.3.1.2.{$index}"; $descr = snmp_get($device, $descr_oid, "-Oqv", "CISCO-ENVMON-MIB"); $temp = snmp_get($device, $oid, "-Oqv", "CISCO-ENVMON-MIB"); 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); discover_temperature($valid_temp, $device, $oid, $index, "cisco", $descr, "1", NULL, NULL, $temp); $temp_exists[] = $device['device_id'] . " {$oid}"; } } } } $sql = "SELECT * FROM temperature AS T, devices AS D WHERE T.device_id = D.device_id AND D.device_id = '" . $device['device_id'] . "'"; if ($query = mysql_query($sql)) { while ($sensor = mysql_fetch_array($query)) { unset($exists); $i = 0; while ($i < count($temp_exists) && !$exists) { $thistemp = $sensor['device_id'] . " " . addslashes($sensor['temp_oid']); if ($temp_exists[$i] == $thistemp) { $exists = 1; }
<?php ## JunOSe Temperatures if ($device['os'] == "junose") { echo "JunOSe: "; $oids = snmpwalk_cache_multi_oid($device, "juniSystemTempValue", array(), "Juniper-System-MIB", "+" . $config['install_dir'] . "/mibs/junose"); if (is_array($oids[$device['device_id']])) { foreach ($oids[$device[device_id]] as $index => $entry) { if (is_numeric($entry['juniSystemTempValue']) && is_numeric($index) && $entry['juniSystemTempValue'] > "0") { $entPhysicalIndex = snmp_get($device, "juniSystemTempPhysicalIndex." . $index, "-Oqv", "Juniper-System-MIB", "+" . $config['install_dir'] . "/mibs/junose"); $descr = snmp_get($device, "entPhysicalDescr." . $entPhysicalIndex, "-Oqv", "ENTITY-MIB"); $descr = preg_replace("/^Juniper\\ [0-9a-zA-Z\\-]+/", "", $descr); ## Wipe out ugly Juniper crap. Why put vendor and model in here? Idiots! $descr = str_replace("temperature sensor on", "", trim($descr)); $oid = ".1.3.6.1.4.1.4874.2.2.2.1.9.4.1.3." . $index; $current = $entry['juniSystemTempValue']; discover_temperature($valid_temp, $device, $oid, $index, "junose", $descr, "1", NULL, NULL, $current); $temp_exists[] = $device['device_id'] . " {$oid}"; } } } }