Files
librenms/includes/polling/temperatures.inc.php
T
Adam Amstrong ad4160c2ea Foob
git-svn-id: http://www.observium.org/svn/observer/trunk@98 61d68cd4-352d-0410-923a-c4978735b2b8
2007-05-20 19:21:35 +00:00

36 lines
995 B
PHP
Executable File

<?
$query = "SELECT * FROM temperature WHERE temp_host = '" . $device['device_id'] . "'";
$temp_data = mysql_query($query);
while($temperature = mysql_fetch_array($temp_data)) {
$temp_cmd = "snmpget -O qv -" . $device['snmpver'] . " -c " . $device['community'] . " " . $device['hostname'] . " " . $temperature['temp_oid'];
echo($temp_cmd);
$temp = `$temp_cmd`;
$temprrd = "rrd/" . $device[hostname] . "-temp-" . str_replace(" ", "_",$temperature['temp_descr']) . ".rrd";
if (!is_file($temprrd)) {
`rrdtool create $temprrd \
--step 300 \
DS:temp:GAUGE:600:-273:1000 \
RRA:AVERAGE:0.5:1:1200 \
RRA:MIN:0.5:12:2400 \
RRA:MAX:0.5:12:2400 \
RRA:AVERAGE:0.5:12:2400`;
}
$temp = str_replace("\"", "", $temp);
if($temperature['temp_tenths']) { $temp = $temp / 10; }
echo("$temprrd, N:$temp");
`rrdtool update $temprrd N:$temp`;
mysql_query("UPDATE temperature SET temp_current = '$temp' WHERE temp_id = '$temperature[temp_id]'");
}
?>