2010-07-18 19:29:02 +00:00
< ? php
2010-07-29 18:25:11 +00:00
global $valid_sensor ;
2010-07-18 19:43:11 +00:00
echo ( " ENTITY-SENSOR " );
2010-07-18 19:29:02 +00:00
$oids = array ();
$oids = snmpwalk_cache_multi_oid ( $device , " entPhySensorType " , $oids , " ENTITY-SENSOR-MIB " );
$oids = snmpwalk_cache_multi_oid ( $device , " entPhySensorScale " , $oids , " ENTITY-SENSOR-MIB " );
2010-07-29 18:25:11 +00:00
2010-07-18 19:29:02 +00:00
$oids = snmpwalk_cache_multi_oid ( $device , " entPhySensorValue " , $oids , " ENTITY-SENSOR-MIB " );
if ( is_array ( $oids [ $device [ 'device_id' ]]))
{
2010-07-18 21:52:49 +00:00
foreach ( $oids [ $device [ 'device_id' ]] as $index => $entry )
2010-07-18 19:29:02 +00:00
{
#echo("[" . $entry['entPhySensorType'] . "|" . $entry['entPhySensorValue']. "|" . $index . "]");
if ( $entry [ 'entPhySensorType' ] == " celsius " && is_numeric ( $entry [ 'entPhySensorValue' ]) && is_numeric ( $index ) && $entry [ 'entPhySensorValue' ] > " 0 " && $entry [ 'entPhySensorValue' ] < " 1000 " )
{
$entPhysicalIndex = $index ;
$descr = snmp_get ( $device , " entPhysicalDescr. " . $index , " -Oqv " , " ENTITY-SENSOR-MIB " );
$oid = " .1.3.6.1.2.1.99.1.1.1.4. " . $index ;
$current = $entry [ 'entPhySensorValue' ];
2010-07-18 19:43:11 +00:00
#ENTITY-SENSOR-MIB::entPhySensorUnitsDisplay.11 = STRING: "C"
2010-07-18 19:29:02 +00:00
2010-07-18 19:43:11 +00:00
$descr = str_replace ( " temperature " , " " , $descr );
2010-07-29 18:25:11 +00:00
$descr = str_replace ( " temperature " , " " , $descr );
2010-07-18 19:43:11 +00:00
$descr = str_replace ( " sensor " , " " , $descr );
2010-07-29 18:25:11 +00:00
### FIXME this stuff is foul
2010-07-18 19:29:02 +00:00
if ( $entry [ 'entPhySensorScale' ] == " milli " ) { $divisor = " 1000 " ; } else { $divisor = " 1 " ; }
2010-07-29 18:25:11 +00:00
if ( $entry [ 'entPhySensorPrecision' ] == " 1 " ) { $multiplier = " 10 " ; } else { $multiplier = " 1 " ; }
2010-07-24 19:14:41 +00:00
if ( mysql_result ( mysql_query ( " SELECT COUNT(*) FROM `sensors` WHERE `device_id` = ' " . $device [ 'device_id' ] . " ' AND `sensor_class` = 'temperature' AND `sensor_type` = 'cisco-entity-sensor' AND `sensor_index` = ' " . $index . " ' " ), 0 ) == " 0 " )
## Check to make sure we've not already seen this sensor via cisco's entity sensor mib
{
2010-07-29 18:25:11 +00:00
discover_sensor ( $valid_sensor , 'temperature' , $device , $oid , $index , 'entity-sensor' , $descr , $divisor , $multiplier , NULL , NULL , NULL , NULL , $current );
2010-07-24 19:14:41 +00:00
}
2010-07-18 19:29:02 +00:00
}
}
}
?>