librenms/includes/polling/cisco-entity-sensors.inc.php
Adam Amstrong bfc9f845ce replacing <? with <?php
git-svn-id: http://www.observium.org/svn/observer/trunk@466 61d68cd4-352d-0410-923a-c4978735b2b8
2009-09-07 11:07:59 +00:00

53 lines
1.7 KiB
PHP
Executable File

<?php
$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);
$rrd = addslashes($config['rrd_dir'] . "/" . $device['hostname'] . "/ces-" . $oid . ".rrd");
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");
}
?>