unified sensor polling, apart from temperatures for now -- run discovery if you have frequencies being polled in your installation

git-svn-id: http://www.observium.org/svn/observer/trunk@2075 61d68cd4-352d-0410-923a-c4978735b2b8
This commit is contained in:
Tom Laermans
2011-04-13 14:00:12 +00:00
parent f19eb5f662
commit 21090cc3a3
15 changed files with 109 additions and 258 deletions

View File

@@ -1,51 +0,0 @@
<?php
$query = "SELECT * FROM sensors WHERE sensor_class='current' AND device_id = '" . $device['device_id'] . "' AND poller_type='snmp'";
$current_data = mysql_query($query);
while ($sensor = mysql_fetch_assoc($current_data))
{
echo("Checking current " . $sensor['sensor_descr'] . "... ");
$current = snmp_get($device, $sensor['sensor_oid'], "-OUqnv", "SNMPv2-MIB");
if ($sensor['sensor_divisor']) { $current = $current / $sensor['sensor_divisor']; }
if ($sensor['sensor_multplier']) { $current = $current * $sensor['sensor_multiplier']; }
$currentrrd = $config['rrd_dir'] . "/" . $device['hostname'] . "/" . safename("current-" . $sensor['sensor_descr'] . ".rrd");
if (!is_file($currentrrd))
{
rrdtool_create($currentrrd,"--step 300 \
DS:sensor: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($current . " A\n");
rrdtool_update($currentrrd,"N:$current");
# FIXME also warn when crossing WARN level!!
if ($sensor['sensor_limit_low'] != "" && $sensor['sensor_current'] > $sensor['sensor_limit_low'] && $current <= $sensor['sensor_limit_low'])
{
$msg = "Current Alarm: " . $device['hostname'] . " " . $sensor['sensor_descr'] . " is under threshold: " . $current . "A (< " . $sensor['sensor_limit'];
$msg .= "A) at " . date($config['timestamp_format']);
notify($device, "Current Alarm: " . $device['hostname'] . " " . $sensor['sensor_descr'], $msg);
echo("Alerting for " . $device['hostname'] . " " . $sensor['sensor_descr'] . "\n");
log_event('Current ' . $sensor['sensor_descr'] . " under threshold: " . $current . " A (< " . $sensor['sensor_limit_low'] . " A)", $device, 'current', $current['sensor_id']);
}
else if ($sensor['sensor_limit'] != "" && $sensor['sensor_current'] < $sensor['sensor_limit'] && $current >= $sensor['sensor_limit'])
{
$msg = "Current Alarm: " . $device['hostname'] . " " . $sensor['sensor_descr'] . " is over threshold: " . $current . "A (> " . $sensor['sensor_limit'];
$msg .= "A) at " . date($config['timestamp_format']);
notify($device, "Current Alarm: " . $device['hostname'] . " " . $sensor['sensor_descr'], $msg);
echo("Alerting for " . $device['hostname'] . " " . $sensor['sensor_descr'] . "\n");
log_event('Current ' . $sensor['sensor_descr'] . " above threshold: " . $current . " A (> " . $sensor['sensor_limit'] . " A)", $device, 'current', $current['sensor_id']);
}
mysql_query("UPDATE sensors SET sensor_current = '$current' WHERE sensor_class='current' AND sensor_id = '" . $sensor['sensor_id'] . "'");
}
?>

View File

@@ -1,54 +0,0 @@
<?php
$query = "SELECT * FROM sensors WHERE sensor_class='fanspeed' AND device_id = '" . $device['device_id'] . "' AND poller_type='snmp'";
$fan_data = mysql_query($query);
while ($sensor = mysql_fetch_assoc($fan_data))
{
echo("Checking fan " . $sensor['sensor_descr'] . "... ");
$fan = snmp_get($device, $sensor['sensor_oid'], "-OUqnv", "SNMPv2-MIB");
if ($sensor['sensor_divisor']) { $fan = $fan / $sensor['sensor_divisor']; }
if ($sensor['sensor_multiplier']) { $fan = $fan * $sensor['sensor_multiplier']; }
$old_rrd_file = $config['rrd_dir'] . "/" . $device['hostname'] . "/" . safename("fanspeed-" . $sensor['sensor_descr'] . ".rrd");
$rrd_file = $config['rrd_dir'] . "/" . $device['hostname'] . "/fanspeed-" . safename($sensor['sensor_type']."-".$sensor['sensor_index']) . ".rrd";
if (is_file($old_rrd_file)) { rename($old_rrd_file, $rrd_file); }
if (!is_file($rrd_file))
{
rrdtool_create($rrd_file,"--step 300 \
DS:sensor:GAUGE:600:0:20000 \
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($fan . " rpm\n");
rrdtool_update($rrd_file,"N:$fan");
if ($sensor['sensor_limit_low'] != "" && $sensor['sensor_current'] > $sensor['sensor_limit_low'] && $fan <= $sensor['sensor_limit_low'])
{
$msg = "Fan Alarm: " . $device['hostname'] . " " . $sensor['sensor_descr'] . " is " . $fan . "rpm (Limit " . $sensor['sensor_limit_low'];
$msg .= "rpm) at " . date($config['timestamp_format']);
notify($device, "Fan Alarm: " . $device['hostname'] . " " . $sensor['sensor_descr'], $msg);
echo("Alerting for " . $device['hostname'] . " " . $sensor['sensor_descr'] . "\n");
log_event('Fan speed ' . $sensor['sensor_descr'] . " under threshold: " . $sensor['sensor_current'] . " rpm (<= " . $sensor['sensor_limit_low'] . " rpm)", $device, 'fanspeed', $sensor['sensor_id']);
}
else if ($sensor['sensor_limit_low_warn'] != "" && $sensor['sensor_limit_low_warn'] && $sensor['sensor_current'] > $sensor['sensor_limit_warn'] && $fan <= $sensor['sensor_limit_low_warn'])
{
$msg = "Fan Warning: " . $device['hostname'] . " " . $sensor['sensor_descr'] . " is " . $fan . "rpm (Warning limit " . $sensor['sensor_limit_low_warn'];
$msg .= "rpm) at " . date($config['timestamp_format']);
notify($device, "Fan Warning: " . $device['hostname'] . " " . $sensor['sensor_descr'], $msg);
echo("Alerting for " . $device['hostname'] . " " . $sensor['sensor_descr'] . "\n");
log_event('Fan speed ' . $sensor['sensor_descr'] . " under warning threshold: " . $sensor['sensor_current'] . " rpm (<= " . $sensor['sensor_limit_low_warn'] . " rpm)", $device, 'fanspeed', $sensor['sensor_id']);
}
mysql_query("UPDATE sensors SET sensor_current = '$fan' WHERE sensor_class='fanspeed' AND sensor_id = '" . $sensor['sensor_id'] . "'");
}
?>

View File

@@ -1,51 +0,0 @@
<?php
$query = "SELECT * FROM `sensors` WHERE device_id = '" . $device['device_id'] . "' AND `sensor_class` = 'freq' AND poller_type='snmp'";
$sensor_data = mysql_query($query);
while ($sensor = mysql_fetch_assoc($sensor_data))
{
echo("Checking frequency " . $sensor['sensor_descr'] . "... ");
$freq = snmp_get($device, $sensor['sensor_oid'], "-OUqnv", "SNMPv2-MIB");
if ($sensor['sensor_divisor']) { $freq = $freq / $sensor['sensor_divisor']; }
if ($sensor['sensor_multiplier']) { $freq = $freq * $sensor['sensor_multiplier']; }
$rrd_file = $config['rrd_dir'] . "/" . $device['hostname'] . "/" . safename("frequency-" . $sensor['sensor_descr'] . ".rrd");
if (!is_file($rrd_file))
{
rrdtool_create($rrd_file,"--step 300 \
DS:sensor: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($freq . " Hz\n");
rrdtool_update($rrd_file,"N:$freq");
if ($sensor['sensor_current'] > $sensor['sensor_limit_low'] && $freq <= $sensor['sensor_limit_low'])
{
$msg = "Frequency Alarm: " . $device['hostname'] . " " . $sensor['sensor_descr'] . " is " . $freq . "Hz (Limit " . $sensor['sensor_limit'];
$msg .= "Hz) at " . date($config['timestamp_format']);
notify($device, "Frequency Alarm: " . $device['hostname'] . " " . $sensor['sensor_descr'], $msg);
echo("Alerting for " . $device['hostname'] . " " . $sensor['sensor_descr'] . "\n");
log_event('Frequency ' . $sensor['sensor_descr'] . " under threshold: " . $freq . " Hz (< " . $sensor['sensor_limit_low'] . " Hz)", $device, 'frequency', $sensor['sensor_id']);
}
else if ($sensor['sensor_current'] < $sensor['sensor_limit'] && $freq >= $sensor['sensor_limit'])
{
$msg = "Frequency Alarm: " . $device['hostname'] . " " . $sensor['sensor_descr'] . " is " . $freq . "Hz (Limit " . $sensor['sensor_limit'];
$msg .= "Hz) at " . date($config['timestamp_format']);
notify($device, "Frequency Alarm: " . $device['hostname'] . " " . $sensor['sensor_descr'], $msg);
echo("Alerting for " . $device['hostname'] . " " . $sensor['sensor_descr'] . "\n");
log_event('Frequency ' . $sensor['sensor_descr'] . " above threshold: " . $freq . " Hz (> " . $sensor['sensor_limit'] . " Hz)", $device, 'frequency', $sensor['sensor_id']);
}
mysql_query("UPDATE frequency SET sensor_current = '$freq' WHERE sensor_id = '" . $sensor['sensor_id'] . "'");
}
?>

View File

@@ -0,0 +1,57 @@
<?php
function poll_sensor($device, $class, $unit)
{
global $config;
$query = "SELECT * FROM sensors WHERE sensor_class='$class' AND device_id = '" . $device['device_id'] . "' AND poller_type='snmp'";
$sensor_data = mysql_query($query);
while ($sensor = mysql_fetch_assoc($sensor_data))
{
echo("Checking $class " . $sensor['sensor_descr'] . "... ");
$sensor_value = snmp_get($device, $sensor['sensor_oid'], "-OUqnv", "SNMPv2-MIB");
if ($sensor['sensor_divisor']) { $sensor_value = $sensor_value / $sensor['sensor_divisor']; }
if ($sensor['sensor_multiplier']) { $sensor_value = $sensor_value * $sensor['sensor_multiplier']; }
$rrd_file = $config['rrd_dir'] . "/" . $device['hostname'] . "/" . safename("$class-" . $sensor['sensor_descr'] . ".rrd");
if (!is_file($rrd_file))
{
rrdtool_create($rrd_file,"--step 300 \
DS:sensor:GAUGE:600:-273:20000 \
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("$sensor_value $unit\n");
rrdtool_update($rrd_file,"N:$sensor_value");
# FIXME also warn when crossing WARN level!!
if ($sensor['sensor_limit_low'] != "" && $sensor['sensor_current'] > $sensor['sensor_limit_low'] && $sensor_value <= $sensor['sensor_limit_low'])
{
$msg = ucfirst($class) . " Alarm: " . $device['hostname'] . " " . $sensor['sensor_descr'] . " is under threshold: " . $sensor_value . "$unit (< " . $sensor['sensor_limit'];
$msg .= "$unit) at " . date($config['timestamp_format']);
notify($device, ucfirst($class) . " Alarm: " . $device['hostname'] . " " . $sensor['sensor_descr'], $msg);
echo("Alerting for " . $device['hostname'] . " " . $sensor['sensor_descr'] . "\n");
log_event(ucfirst($class) . ' ' . $sensor['sensor_descr'] . " under threshold: " . $sensor_value . " $unit (< " . $sensor['sensor_limit_low'] . " $unit)", $device, $class, $sensor['sensor_id']);
}
else if ($sensor['sensor_limit'] != "" && $sensor['sensor_current'] < $sensor['sensor_limit'] && $sensor_value >= $sensor['sensor_limit'])
{
$msg = ucfirst($class) . " Alarm: " . $device['hostname'] . " " . $sensor['sensor_descr'] . " is over threshold: " . $sensor_value . "$unit (> " . $sensor['sensor_limit'];
$msg .= "$unit) at " . date($config['timestamp_format']);
notify($device, ucfirst($class) . " Alarm: " . $device['hostname'] . " " . $sensor['sensor_descr'], $msg);
echo("Alerting for " . $device['hostname'] . " " . $sensor['sensor_descr'] . "\n");
log_event(ucfirst($class) . ' ' . $sensor['sensor_descr'] . " above threshold: " . $sensor_value . " $unit (> " . $sensor['sensor_limit'] . " $unit)", $device, $class, $sensor['sensor_id']);
}
mysql_query("UPDATE sensors SET sensor_current = '$sensor_value' WHERE sensor_class='$class' AND sensor_id = '" . $sensor['sensor_id'] . "'");
}
}
?>

View File

@@ -1,50 +0,0 @@
<?php
$query = "SELECT * FROM sensors WHERE sensor_class='humidity' AND device_id = '" . $device['device_id'] . "' AND poller_type='snmp'";
$hum_data = mysql_query($query);
while ($sensor = mysql_fetch_assoc($hum_data))
{
echo("Checking humidity " . $sensor['sensor_descr'] . "... ");
$hum = snmp_get($device, $sensor['sensor_oid'], "-OUqnv", "SNMPv2-MIB");
if ($sensor['sensor_divisor']) { $hum = $hum / $sensor['sensor_divisor']; }
if ($sensor['sensor_multiplier']) { $hum = $hum / $sensor['sensor_multiplier']; }
$humrrd = $config['rrd_dir'] . "/" . $device['hostname'] . "/" . safename("humidity-" . $sensor['sensor_descr'] . ".rrd");
if (!is_file($humrrd))
{
rrdtool_create($humrrd,"--step 300 \
DS:sensor: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($hum . " %\n");
rrdtool_update($humrrd,"N:$hum");
if ($sensor['sensor_limit_low'] != "" && $sensor['sensor_current'] > $sensor['sensor_limit_low'] && $hum <= $sensor['sensor_limit_low'])
{
$msg = "Humidity Alarm: " . $device['hostname'] . " " . $sensor['sensor_descr'] . " is " . $hum . "% (Limit " . $sensor['sensor_limit'];
$msg .= "%) at " . date($config['timestamp_format']);
notify($device, "Humidity Alarm: " . $device['hostname'] . " " . $sensor['sensor_descr'], $msg);
echo("Alerting for " . $device['hostname'] . " " . $sensor['sensor_descr'] . "\n");
log_event('Frequency ' . $sensor['sensor_descr'] . " under threshold: " . $hum . " % (< " . $sensor['sensor_limit_low'] . " %)", $device, 'humidity', $sensor['sensor_id']);
}
else if ($sensor['sensor_limit'] != "" && $sensor['sensor_current'] < $sensor['sensor_limit'] && $hum >= $sensor['sensor_limit'])
{
$msg = "Humidity Alarm: " . $device['hostname'] . " " . $sensor['sensor_descr'] . " is " . $hum . "% (Limit " . $sensor['sensor_limit'];
$msg .= "%) at " . date($config['timestamp_format']);
notify($device, "Humidity Alarm: " . $device['hostname'] . " " . $sensor['sensor_descr'], $msg);
echo("Alerting for " . $device['hostname'] . " " . $sensor['sensor_descr'] . "\n");
log_event('Humidity ' . $sensor['sensor_descr'] . " above threshold: " . $hum . " % (> " . $sensor['sensor_limit'] . " %)", $device, 'humidity', $sensor['sensor_id']);
}
mysql_query("UPDATE sensors SET sensor_current = '$hum' WHERE sensor_class='humidity' AND sensor_id = '" . $sensor['sensor_id'] . "'");
}
?>

View File

@@ -1,26 +1,30 @@
<?php
$query = "SELECT * FROM sensors WHERE sensor_class='temperature' AND device_id = '" . $device['device_id'] . "' AND poller_type='snmp'";
$temp_data = mysql_query($query);
while ($sensor = mysql_fetch_assoc($temp_data))
$class = 'temperature';
$unit = 'C';
$query = "SELECT * FROM sensors WHERE sensor_class='$class' AND device_id = '" . $device['device_id'] . "' AND poller_type='snmp'";
$sensor_data = mysql_query($query);
while ($sensor = mysql_fetch_assoc($sensor_data))
{
echo("Checking temp " . $sensor['sensor_descr'] . "... ");
for ($i = 0;$i < 5;$i++) # Try 5 times to get a valid temp reading
{
if ($debug) echo("Attempt $i ");
$temp = snmp_get($device, $sensor['sensor_oid'], "-OUqnv", "SNMPv2-MIB");
$temp = trim(str_replace("\"", "", $temp));
$sensor_value = snmp_get($device, $sensor['sensor_oid'], "-OUqnv", "SNMPv2-MIB");
$sensor_value = trim(str_replace("\"", "", $sensor_value));
if ($temp != 9999) break; # TME sometimes sends 999.9 when it is right in the middle of an update;
if ($sensor_value != 9999) break; # TME sometimes sends 999.9 when it is right in the middle of an update;
sleep(1); # Give the TME some time to reset
}
if ($sensor['sensor_divisor']) { $temp = $temp / $sensor['sensor_divisor']; }
if ($sensor['sensor_multiplier']) { $temp = $temp * $sensor['sensor_multiplier']; }
if ($sensor['sensor_divisor']) { $sensor_value = $sensor_value / $sensor['sensor_divisor']; }
if ($sensor['sensor_multiplier']) { $sensor_value = $sensor_value * $sensor['sensor_multiplier']; }
$old_rrd_file = $config['rrd_dir'] . "/" . $device['hostname'] . "/" . safename("temperature-" . $sensor['sensor_descr'] . ".rrd");
$rrd_file = $config['rrd_dir'] . "/" . $device['hostname'] . "/temperature-" . safename($sensor['sensor_type']."-".$sensor['sensor_index']) . ".rrd";
$old_rrd_file = $config['rrd_dir'] . "/" . $device['hostname'] . "/" . safename("$class-" . $sensor['sensor_descr'] . ".rrd");
$rrd_file = $config['rrd_dir'] . "/" . $device['hostname'] . "/$class-" . safename($sensor['sensor_type']."-".$sensor['sensor_index']) . ".rrd";
if (is_file($old_rrd_file)) { rename($old_rrd_file, $rrd_file); }
@@ -42,20 +46,20 @@ while ($sensor = mysql_fetch_assoc($temp_data))
RRA:MIN:0.5:288:797");
}
echo($temp . "C\n");
echo("$sensor_value $unit\n");
rrdtool_update($rrd_file,"N:$temp");
rrdtool_update($rrd_file,"N:$sensor_value");
if ($sensor['sensor_limit_low'] != "" && $sensor['sensor_current'] < $sensor['sensor_limit'] && $temp >= $sensor['sensor_limit'])
if ($sensor['sensor_limit_low'] != "" && $sensor['sensor_current'] < $sensor['sensor_limit'] && $sensor_value >= $sensor['sensor_limit'])
{
$msg = "Temp Alarm: " . $device['hostname'] . " " . $sensor['sensor_descr'] . " is " . $temp . " (Limit " . $sensor['sensor_limit'];
$msg = "Temp Alarm: " . $device['hostname'] . " " . $sensor['sensor_descr'] . " is " . $sensor_value . " (Limit " . $sensor['sensor_limit'];
$msg .= ") at " . date($config['timestamp_format']);
notify($device, "Temp Alarm: " . $device['hostname'] . " " . $sensor['sensor_descr'], $msg);
echo("Alerting for " . $device['hostname'] . " " . $sensor['sensor_descr'] . "\n");
log_event('Temperature ' . $sensor['sensor_descr'] . " over threshold: " . $temp . " " . html_entity_decode('&deg;') . "C (>= " . $sensor['sensor_limit'] . " " . html_entity_decode('&deg;') . 'C)', $device, 'temperature', $sensor['sensor_id']);
log_event('Temperature ' . $sensor['sensor_descr'] . " over threshold: " . $sensor_value . " " . html_entity_decode('&deg;') . "$unit (>= " . $sensor['sensor_limit'] . " " . html_entity_decode('&deg;') . "$unit)", $device, $class, $sensor['sensor_id']);
}
mysql_query("UPDATE sensors SET sensor_current = '$temp' WHERE sensor_class='temperature' AND sensor_id = '" . $sensor['sensor_id'] . "'");
mysql_query("UPDATE sensors SET sensor_current = '$sensor_value' WHERE sensor_class='$class' AND sensor_id = '" . $sensor['sensor_id'] . "'");
}
?>

View File

@@ -1,19 +1,22 @@
<?php
$query = "SELECT * FROM sensors WHERE sensor_class='voltage' AND device_id = '" . $device['device_id'] . "' AND poller_type='snmp'";
$volt_data = mysql_query($query);
$class = 'voltage';
$unit = 'V';
while ($sensor = mysql_fetch_assoc($volt_data))
$query = "SELECT * FROM sensors WHERE sensor_class='$class' AND device_id = '" . $device['device_id'] . "' AND poller_type='snmp'";
$sensor_data = mysql_query($query);
while ($sensor = mysql_fetch_assoc($sensor_data))
{
echo("Checking voltage " . $sensor['sensor_descr'] . "... ");
$volt = snmp_get($device, $sensor['sensor_oid'], "-OUqnv", "SNMPv2-MIB");
$sensor_value = snmp_get($device, $sensor['sensor_oid'], "-OUqnv", "SNMPv2-MIB");
if ($sensor['sensor_divisor']) { $volt = $volt / $sensor['sensor_divisor']; }
if ($sensor['sensor_multiplier']) { $volt = $volt * $sensor['sensor_multiplier']; }
if ($sensor['sensor_divisor']) { $sensor_value = $sensor_value / $sensor['sensor_divisor']; }
if ($sensor['sensor_multiplier']) { $sensor_value = $sensor_value * $sensor['sensor_multiplier']; }
$old_rrd_file = $config['rrd_dir'] . "/" . $device['hostname'] . "/" . safename("voltage-" . $sensor['sensor_descr'] . ".rrd");
$rrd_file = $config['rrd_dir'] . "/" . $device['hostname'] . "/voltage-" . safename($sensor['sensor_type']."-".$sensor['sensor_index']) . ".rrd";
$old_rrd_file = $config['rrd_dir'] . "/" . $device['hostname'] . "/" . safename("$class-" . $sensor['sensor_descr'] . ".rrd");
$rrd_file = $config['rrd_dir'] . "/" . $device['hostname'] . "/$class-" . safename($sensor['sensor_type']."-".$sensor['sensor_index']) . ".rrd";
if (is_file($old_rrd_file)) { rename($old_rrd_file, $rrd_file); }
@@ -27,27 +30,27 @@ while ($sensor = mysql_fetch_assoc($volt_data))
RRA:AVERAGE:0.5:12:2400");
}
echo($volt . " V\n");
echo("$sensor_value $unit\n");
rrdtool_update($rrd_file,"N:$volt");
rrdtool_update($rrd_file,"N:$sensor_value");
if ($sensor['sensor_limit_low'] != "" && $sensor['sensor_current'] > $sensor['sensor_limit_low'] && $volt <= $sensor['sensor_limit_low'])
if ($sensor['sensor_limit_low'] != "" && $sensor['sensor_current'] > $sensor['sensor_limit_low'] && $sensor_value <= $sensor['sensor_limit_low'])
{
$msg = "Voltage Alarm: " . $device['hostname'] . " " . $sensor['sensor_descr'] . " is " . $volt . "V (Limit " . $sensor['sensor_limit'];
$msg .= "V) at " . date($config['timestamp_format']);
$msg = "Voltage Alarm: " . $device['hostname'] . " " . $sensor['sensor_descr'] . " is " . $sensor_value . "$unit (Limit " . $sensor['sensor_limit'];
$msg .= "$unit) at " . date($config['timestamp_format']);
notify($device, "Voltage Alarm: " . $device['hostname'] . " " . $sensor['sensor_descr'], $msg);
echo("Alerting for " . $device['hostname'] . " " . $sensor['sensor_descr'] . "\n");
log_event('Voltage ' . $sensor['sensor_descr'] . " under threshold: " . $volt . " V (< " . $sensor['sensor_limit_low'] . " V)", $device, 'voltage', $sensor['sensor_id']);
log_event('Voltage ' . $sensor['sensor_descr'] . " under threshold: " . $sensor_value . " $unit (< " . $sensor['sensor_limit_low'] . " $unit)", $device, $class, $sensor['sensor_id']);
}
else if ($sensor['sensor_limit'] != "" && $sensor['sensor_current'] < $sensor['sensor_limit'] && $volt >= $sensor['sensor_limit'])
else if ($sensor['sensor_limit'] != "" && $sensor['sensor_current'] < $sensor['sensor_limit'] && $sensor_value >= $sensor['sensor_limit'])
{
$msg = "Voltage Alarm: " . $device['hostname'] . " " . $sensor['sensor_descr'] . " is " . $volt . "V (Limit " . $sensor['sensor_limit'];
$msg .= "V) at " . date($config['timestamp_format']);
$msg = "Voltage Alarm: " . $device['hostname'] . " " . $sensor['sensor_descr'] . " is " . $sensor_value . "$unit (Limit " . $sensor['sensor_limit'];
$msg .= "$unit) at " . date($config['timestamp_format']);
notify($device, "Voltage Alarm: " . $device['hostname'] . " " . $sensor['sensor_descr'], $msg);
echo("Alerting for " . $device['hostname'] . " " . $sensor['sensor_descr'] . "\n");
log_event('Voltage ' . $sensor['sensor_descr'] . " above threshold: " . $volt . " V (> " . $sensor['sensor_limit'] . " V)", $device, 'voltage', $sensor['sensor_id']);
log_event('Voltage ' . $sensor['sensor_descr'] . " above threshold: " . $sensor_value . " $unit (> " . $sensor['sensor_limit'] . " $unit)", $device, $class, $sensor['sensor_id']);
}
mysql_query("UPDATE sensors SET sensor_current = '$volt' WHERE sensor_class='voltage' AND sensor_id = '" . $sensor['sensor_id'] . "'");
mysql_query("UPDATE sensors SET sensor_current = '$sensor_value' WHERE sensor_class='$class' AND sensor_id = '" . $sensor['sensor_id'] . "'");
}
?>