2009-09-07 11:07:59 +00:00
< ? php
2009-05-12 10:10:37 +00:00
$query = " SELECT * FROM entPhysical WHERE device_id = ' " . $device [ 'device_id' ] . " ' AND entPhysicalClass = 'sensor' " ;
$sensors = mysql_query ( $query );
while ( $sensor = mysql_fetch_array ( $sensors )) {
echo ( " Checking Entity Sensor " . $sensor [ 'entPhysicalName' ] . " - " . $sensor [ 'cempsensorName' ]);
$oid = $sensor [ 'entPhysicalIndex' ];
$sensor_cmd = $config [ 'snmpget' ] . " -m CISCO-ENTITY-SENSOR-MIB -O Uqnv - " . $device [ 'snmpver' ] . " -c " . $device [ 'community' ] . " " . $device [ 'hostname' ] . " : " . $device [ 'port' ];
$sensor_cmd .= " entSensorValue. $oid entSensorStatus. $oid " ;
$sensor_data = trim ( shell_exec ( $sensor_cmd ));
# echo("$sensor_data");
list ( $entSensorValue , $entSensorStatus ) = explode ( " \n " , $sensor_data );
2010-02-05 22:10:06 +00:00
$rrd = $config [ 'rrd_dir' ] . " / " . $device [ 'hostname' ] . " / " . safename ( " ces- " . $oid . " .rrd " );
2009-05-12 10:10:37 +00:00
if ( ! is_file ( $rrd )) {
` rrdtool create $rrd \
-- step 300 \
DS : value : GAUGE : 600 :- 1000 : U \
RRA : AVERAGE : 0.5 : 1 : 2304 \
RRA : AVERAGE : 0.5 : 6 : 1536 \
RRA : AVERAGE : 0.5 : 24 : 2268 \
RRA : AVERAGE : 0.5 : 288 : 1890 \
RRA : MAX : 0.5 : 1 : 2304 \
RRA : MAX : 0.5 : 6 : 1536 \
RRA : MAX : 0.5 : 24 : 2268 \
RRA : MAX : 0.5 : 288 : 1890 \
RRA : MIN : 0.5 : 1 : 2304 \
RRA : MIN : 0.5 : 6 : 1536 \
RRA : MIN : 0.5 : 24 : 2268 \
RRA : MIN : 0.5 : 288 : 1890 ` ;
}
$entSensorValue = entPhysical_scale ( $entSensorValue , $sensor [ 'entSensorScale' ]);
$updatecmd = $config [ 'rrdtool' ] . " update $rrd N: $entSensorValue " ;
shell_exec ( $updatecmd );
$update_query = " UPDATE `entPhysical` SET entSensorValue=' $entSensorValue ', entSensorStatus=' $entSensorStatus ' WHERE `entPhysical_id` = ' " . $sensor [ 'entPhysical_id' ] . " ' " ;
mysql_query ( $update_query );
echo ( $entSensorValue . " - " . $entSensorStatus . " \n " );
}
?>