voltage polling complete

git-svn-id: http://www.observium.org/svn/observer/trunk@804 61d68cd4-352d-0410-923a-c4978735b2b8
This commit is contained in:
Tom Laermans
2010-02-10 12:03:12 +00:00
parent a917bbb358
commit 7b79de4fa4
4 changed files with 72 additions and 10 deletions

View File

@@ -9,6 +9,7 @@ while($fanspeed = mysql_fetch_array($fan_data)) {
$fan_cmd = $config['snmpget'] . " -m SNMPv2-MIB -O Uqnv -" . $device['snmpver'] . " -c " . $device['community'] . " " . $device['hostname'].":".$device['port'] . " " . $fanspeed['fan_oid'] . "|grep -v \"No Such Instance\""; $fan_cmd = $config['snmpget'] . " -m SNMPv2-MIB -O Uqnv -" . $device['snmpver'] . " -c " . $device['community'] . " " . $device['hostname'].":".$device['port'] . " " . $fanspeed['fan_oid'] . "|grep -v \"No Such Instance\"";
$fan = trim(str_replace("\"", "", shell_exec($fan_cmd))); $fan = trim(str_replace("\"", "", shell_exec($fan_cmd)));
if ($fanspeed['fan_precision']) { $fan = $fan / $fanspeed['fan_precision']; } if ($fanspeed['fan_precision']) { $fan = $fan / $fanspeed['fan_precision']; }
#FIXME also divide the limit here
$fanrrd = $config['rrd_dir'] . "/" . $device['hostname'] . "/" . safename("fan-" . $fanspeed['fan_descr'] . ".rrd"); $fanrrd = $config['rrd_dir'] . "/" . $device['hostname'] . "/" . safename("fan-" . $fanspeed['fan_descr'] . ".rrd");
@@ -27,10 +28,10 @@ while($fanspeed = mysql_fetch_array($fan_data)) {
rrdtool_update($fanrrd,"N:$fan"); rrdtool_update($fanrrd,"N:$fan");
if($fanspeed['fan_current'] > $fanspeed['fan_limit'] && $fan <= $fanspeed['fan_limit']) { if($fanspeed['fan_current'] > $fanspeed['fan_limit'] && $fan <= $fanspeed['fan_limit']) {
$updated = ", `service_changed` = '" . time() . "' "; $updated = ", `service_changed` = '" . time() . "' "; # FIXME what's this
if($device['sysContact']) { $email = $device['sysContact']; } else { $email = $config['email_default']; } if($device['sysContact']) { $email = $device['sysContact']; } else { $email = $config['email_default']; }
$msg = "Fan Alarm: " . $device['hostname'] . " " . $fanspeed['fan_descr'] . " is " . $fan . " (Limit " . $fanspeed['fan_limit']; $msg = "Fan Alarm: " . $device['hostname'] . " " . $fanspeed['fan_descr'] . " is " . $fan . "rpm (Limit " . $fanspeed['fan_limit'];
$msg .= ") at " . date('l dS F Y h:i:s A'); $msg .= "rpm) at " . date('l dS F Y h:i:s A');
mail($email, "Fan Alarm: " . $device['hostname'] . " " . $fanspeed['fan_descr'], $msg, $config['email_headers']); mail($email, "Fan Alarm: " . $device['hostname'] . " " . $fanspeed['fan_descr'], $msg, $config['email_headers']);
echo("Alerting for " . $device['hostname'] . " " . $fanspeed['fan_descr'] . "\n"); echo("Alerting for " . $device['hostname'] . " " . $fanspeed['fan_descr'] . "\n");
eventlog('Fan speed ' . $fanspeed['fan_descr'] . " under threshold: " . $fanspeed['fan_current'] . " rpm (&gt; " . $fanspeed['fan_limit'] . " rpm)", $device['device_id']); eventlog('Fan speed ' . $fanspeed['fan_descr'] . " under threshold: " . $fanspeed['fan_current'] . " rpm (&gt; " . $fanspeed['fan_limit'] . " rpm)", $device['device_id']);

View File

@@ -11,15 +11,17 @@ while($temperature = mysql_fetch_array($temp_data)) {
if ($debug) echo "Attempt $i "; if ($debug) echo "Attempt $i ";
$temp_cmd = $config['snmpget'] . " -m SNMPv2-MIB -O Uqnv -" . $device['snmpver'] . " -c " . $device['community'] . " " . $device['hostname'].":".$device['port'] . " " . $temperature['temp_oid'] . "|grep -v \"No Such Instance\""; $temp_cmd = $config['snmpget'] . " -m SNMPv2-MIB -O Uqnv -" . $device['snmpver'] . " -c " . $device['community'] . " " . $device['hostname'].":".$device['port'] . " " . $temperature['temp_oid'] . "|grep -v \"No Such Instance\"";
$temp = trim(str_replace("\"", "", shell_exec($temp_cmd))); $temp = trim(str_replace("\"", "", shell_exec($temp_cmd)));
if($temperature['temp_tenths']) { $temp = $temp / 10; }
else
{
if ($temperature['temp_precision']) { $temp = $temp / $temperature['temp_precision']; }
}
if ($temp != 999.9) break; # TME sometimes sends 999.9 when it is right in the middle of an update; if ($temp != 9999) break; # TME sometimes sends 999.9 when it is right in the middle of an update;
} }
if($temperature['temp_tenths']) { $temp = $temp / 10; }
else
{
if ($temperature['temp_precision']) { $temp = $temp / $temperature['temp_precision']; }
}
#FIXME also divide the limit here
$temprrd = $config['rrd_dir'] . "/" . $device['hostname'] . "/" . safename("temp-" . $temperature['temp_descr'] . ".rrd"); $temprrd = $config['rrd_dir'] . "/" . $device['hostname'] . "/" . safename("temp-" . $temperature['temp_descr'] . ".rrd");
if (!is_file($temprrd)) { if (!is_file($temprrd)) {
@@ -37,7 +39,7 @@ while($temperature = mysql_fetch_array($temp_data)) {
rrdtool_update($temprrd,"N:$temp"); rrdtool_update($temprrd,"N:$temp");
if($temperature['temp_current'] < $temperature['temp_limit'] && $temp >= $temperature['temp_limit']) { if($temperature['temp_current'] < $temperature['temp_limit'] && $temp >= $temperature['temp_limit']) {
$updated = ", `service_changed` = '" . time() . "' "; $updated = ", `service_changed` = '" . time() . "' "; # FIXME what's this
if($device['sysContact']) { $email = $device['sysContact']; } else { $email = $config['email_default']; } if($device['sysContact']) { $email = $device['sysContact']; } else { $email = $config['email_default']; }
$msg = "Temp Alarm: " . $device['hostname'] . " " . $temperature['temp_descr'] . " is " . $temp . " (Limit " . $temperature['temp_limit']; $msg = "Temp Alarm: " . $device['hostname'] . " " . $temperature['temp_descr'] . " is " . $temp . " (Limit " . $temperature['temp_limit'];
$msg .= ") at " . date('l dS F Y h:i:s A'); $msg .= ") at " . date('l dS F Y h:i:s A');

View File

@@ -0,0 +1,58 @@
<?php
$query = "SELECT * FROM voltage WHERE volt_host = '" . $device['device_id'] . "'";
$volt_data = mysql_query($query);
while($voltage = mysql_fetch_array($volt_data)) {
echo("Checking voltage " . $voltage['volt_descr'] . "... ");
$volt_cmd = $config['snmpget'] . " -m SNMPv2-MIB -O Uqnv -" . $device['snmpver'] . " -c " . $device['community'] . " " . $device['hostname'].":".$device['port'] . " " . $voltage['volt_oid'] . "|grep -v \"No Such Instance\"";
$volt = trim(str_replace("\"", "", shell_exec($volt_cmd)));
if ($voltage['volt_precision'])
{
$volt = $volt / $voltage['volt_precision'];
$voltage['volt_limit'] = $voltage['volt_limit'] / $voltage['volt_precision'];
$voltage['volt_limit_low'] = $voltage['volt_limit_low'] / $voltage['volt_precision'];
}
$voltrrd = $config['rrd_dir'] . "/" . $device['hostname'] . "/" . safename("volt-" . $voltage['volt_descr'] . ".rrd");
if (!is_file($voltrrd)) {
`rrdtool create $voltrrd \
--step 300 \
DS:volt: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`;
}
echo($volt . " V\n");
rrdtool_update($voltrrd,"N:$volt");
if($voltage['volt_current'] > $voltage['volt_limit_low'] && $volt <= $voltage['volt_limit_low'])
{
$updated = ", `service_changed` = '" . time() . "' "; # FIXME what's this?
if($device['sysContact']) { $email = $device['sysContact']; } else { $email = $config['email_default']; }
$msg = "Voltage Alarm: " . $device['hostname'] . " " . $voltage['volt_descr'] . " is " . $volt . "V (Limit " . $voltage['volt_limit'];
$msg .= "V) at " . date('l dS F Y h:i:s A');
mail($email, "Voltage Alarm: " . $device['hostname'] . " " . $voltage['volt_descr'], $msg, $config['email_headers']);
echo("Alerting for " . $device['hostname'] . " " . $voltage['volt_descr'] . "\n");
eventlog('Voltage ' . $voltage['volt_descr'] . " under threshold: " . $voltage['volt_current'] . " rpm (&gt; " . $voltage['volt_limit'] . " rpm)", $device['device_id']);
}
else if($voltage['volt_current'] < $voltage['volt_limit'] && $volt >= $voltage['volt_limit'])
{
$updated = ", `service_changed` = '" . time() . "' "; # FIXME what's this?
if($device['sysContact']) { $email = $device['sysContact']; } else { $email = $config['email_default']; }
$msg = "Voltage Alarm: " . $device['hostname'] . " " . $voltage['volt_descr'] . " is " . $volt . "V (Limit " . $voltage['volt_limit'];
$msg .= "V) at " . date('l dS F Y h:i:s A');
mail($email, "Voltage Alarm: " . $device['hostname'] . " " . $voltage['volt_descr'], $msg, $config['email_headers']);
echo("Alerting for " . $device['hostname'] . " " . $voltage['volt_descr'] . "\n");
eventlog('Voltage ' . $voltage['volt_descr'] . " above threshold: " . $voltage['volt_current'] . " rpm (&gt; " . $voltage['volt_limit'] . " rpm)", $device['device_id']);
}
mysql_query("UPDATE voltage SET volt_current = '$volt' WHERE volt_id = '" . $voltage['volt_id'] . "'");
}
?>

View File

@@ -104,6 +104,7 @@ while ($device = mysql_fetch_array($device_query)) {
include("includes/polling/temperatures.inc.php"); include("includes/polling/temperatures.inc.php");
include("includes/polling/fanspeeds.inc.php"); include("includes/polling/fanspeeds.inc.php");
include("includes/polling/voltages.inc.php");
include("includes/polling/device-netstats.inc.php"); include("includes/polling/device-netstats.inc.php");
include("includes/polling/ipSystemStats.inc.php"); include("includes/polling/ipSystemStats.inc.php");
include("includes/polling/ports.inc.php"); include("includes/polling/ports.inc.php");