Rearrange polling scripts

git-svn-id: http://www.observium.org/svn/observer/trunk@66 61d68cd4-352d-0410-923a-c4978735b2b8
This commit is contained in:
Adam Amstrong 2007-04-08 12:23:31 +00:00
parent 83728cf9d7
commit d30625c23c
2 changed files with 74 additions and 0 deletions

View File

@ -0,0 +1,40 @@
<?php
$oids = array ('ipForwDatagrams','ipInDelivers','ipInReceives','ipOutRequests','ipInDiscards','ipOutDiscards','ipOutNoRoutes',
'icmpInMsgs','icmpOutMsgs','icmpInErrors','icmpOutErrors','icmpInEchos','icmpOutEchos','icmpInEchoReps',
'icmpOutEchoReps','snmpInTotalReqVars','snmpInTotalSetVars','snmpInTraps','snmpOutTraps','snmpInPkts',
'snmpOutPkts','snmpOutGetResponses','snmpOutSetRequests','tcpActiveOpens','tcpPassiveOpens','tcpAttemptFails',
'tcpEstabResets','tcpInSegs','tcpOutSegs','tcpRetransSegs','udpInDatagrams','udpOutDatagrams','udpInErrors',
'udpNoPorts');
$rrdfile = "rrd/" . $hostname . "-netinfo.rrd";
$rrd_create = "rrdtool create $rrdfile ";
$rrd_create .= "RRA:AVERAGE:0.5:1:600 RRA:AVERAGE:0.5:6:700 RRA:AVERAGE:0.5:24:775 RRA:AVERAGE:0.5:288:797 RRA:MAX:0.5:1:600 \
RRA:MAX:0.5:6:700 RRA:MAX:0.5:24:775 RRA:MAX:0.5:288:797";
unset($snmpstring);
foreach($oids as $oid){
$rrd_create .= " DS:$oid:COUNTER:600:U:100000000000";
$snmpstring .= " $oid.0";
}
if(!file_exists($rrdfile)) { `$rrd_create`; }
$snmpdata = trim(`snmpget -O qv -$snmpver -c $community $hostname $snmpstring`);
$rrdupdate = "N";
foreach(explode("\n", $snmpdata) as $data) {
if(strstr($data, "No")) { $data = ""; }
$rrdupdate .= ":$data";
}
echo("\n$rrdfile $rrdupdate\n");
rrd_update($rrdfile, $rrdupdate);
rrd_error();
?>

View File

@ -0,0 +1,34 @@
<?
$query = "SELECT * FROM temperature AS T temp_host = '" . $device[id] . "'";
$temp_data = mysql_query($query);
while($temperature = mysql_fetch_array($temp_data)) {
$community = $temperature[community];
$hostname = $temperature[hostname];
$snmpver = $temperature[snmpver];
$temp_cmd = "snmpget -O qv -" . $device['snmpver'] . " -c " . $device['community'] . " " . $device['hostname'] . " " . $temperature['temp_oid'];
$temp = `$temp_cmd`;
$temprrd = "rrd/" . $temperature[hostname] . "-temp" . $temperature[temp_id] . ".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);
echo("$temprrd, N:$temp");
`rrdtool update $temprrd N:$temp`;
mysql_query("UPDATE temperature SET temp_current = '$temp' WHERE temp_id = '$temperature[temp_id]'");
}
?>