mirror of
https://github.com/librenms/librenms.git
synced 2024-10-07 16:52:45 +00:00
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:
@@ -35,3 +35,4 @@ ALTER TABLE `vminfo` ADD `vm_type` VARCHAR(16) NOT NULL DEFAULT 'vmware' AFTER `
|
||||
CREATE TABLE IF NOT EXISTS `cef_switching` ( `device_id` int(11) NOT NULL, `entPhysicalIndex` int(11) NOT NULL, `afi` varchar(4) COLLATE utf8_unicode_ci NOT NULL, `cef_index` int(11) NOT NULL, `cef_path` varchar(16) COLLATE utf8_unicode_ci NOT NULL, `drop` int(11) NOT NULL, `punt` int(11) NOT NULL, `punt2host` int(11) NOT NULL, `drop_prev` int(11) NOT NULL, `punt_prev` int(11) NOT NULL, `punt2host_prev` int(11) NOT NULL,`updated` INT NOT NULL , `updated_prev` INT NOT NULL ) ENGINE=InnoDB DEFAULT CHARSET=utf8;
|
||||
ALTER TABLE `mac_accounting` CHANGE `peer_mac` `mac` VARCHAR( 32 ) CHARACTER SET latin1 COLLATE latin1_swedish_ci NOT NULL
|
||||
ALTER TABLE `mac_accounting` DROP `peer_ip`, DROP `peer_desc`, DROP `peer_asn`;
|
||||
UPDATE sensors SET sensor_class='frequency' WHERE sensor_class='freq';
|
||||
|
@@ -6,7 +6,7 @@ $device = device_by_id_cache($id);
|
||||
$rrd_options .= " -l 0 -E ";
|
||||
|
||||
$iter = "1";
|
||||
$sql = mysql_query("SELECT * FROM sensors WHERE sensor_class='freq' AND device_id = '$id'");
|
||||
$sql = mysql_query("SELECT * FROM sensors WHERE sensor_class='frequency' AND device_id = '$id'");
|
||||
$rrd_options .= " COMMENT:' Cur Min Max\\n'";
|
||||
|
||||
while ($frequency = mysql_fetch_assoc($sql))
|
||||
|
@@ -53,11 +53,7 @@ if (device_permitted($_GET['id']) || $check_device == $_GET['id'])
|
||||
mysql_result(mysql_query("select count(sensor_id) from sensors WHERE device_id = '" . $device['device_id'] . "'"), 0) +
|
||||
mysql_result(mysql_query("select count(*) from cempMemPool WHERE device_id = '" . $device['device_id'] . "'"), 0) +
|
||||
mysql_result(mysql_query("select count(*) from cpmCPU WHERE device_id = '" . $device['device_id'] . "'"), 0) +
|
||||
mysql_result(mysql_query("select count(*) from processors WHERE device_id = '" . $device['device_id'] . "'"), 0) +
|
||||
mysql_result(mysql_query("select count(current_id) from current WHERE device_id = '" . $device['device_id'] . "'"), 0) +
|
||||
mysql_result(mysql_query("select count(freq_id) from frequencies WHERE device_id = '" . $device['device_id'] . "'"), 0) +
|
||||
mysql_result(mysql_query("select count(volt_id) from voltage WHERE device_id = '" . $device['device_id'] . "'"), 0) +
|
||||
mysql_result(mysql_query("select count(fan_id) from fanspeed WHERE device_id = '" . $device['device_id'] . "'"), 0);
|
||||
mysql_result(mysql_query("select count(*) from processors WHERE device_id = '" . $device['device_id'] . "'"), 0);
|
||||
|
||||
if ($health)
|
||||
{
|
||||
|
@@ -10,7 +10,7 @@ $humidity = mysql_result(mysql_query("select count(*) from sensors WHERE sensor_
|
||||
$fans = mysql_result(mysql_query("select count(*) from sensors WHERE sensor_class='fanspeed' AND device_id = '" . $device['device_id'] . "'"), 0);
|
||||
$volts = mysql_result(mysql_query("select count(*) from sensors WHERE sensor_class='voltage' AND device_id = '" . $device['device_id'] . "'"), 0);
|
||||
$current = mysql_result(mysql_query("select count(*) from sensors WHERE sensor_class='current' AND device_id = '" . $device['device_id'] . "'"), 0);
|
||||
$freqs = mysql_result(mysql_query("select count(*) from sensors WHERE sensor_class='freq' AND device_id = '" . $device['device_id'] . "'"), 0);
|
||||
$freqs = mysql_result(mysql_query("select count(*) from sensors WHERE sensor_class='frequency' AND device_id = '" . $device['device_id'] . "'"), 0);
|
||||
|
||||
$datas[] = 'overview';
|
||||
if ($processor) { $datas[] = 'processor'; }
|
||||
|
@@ -1,6 +1,6 @@
|
||||
<?php
|
||||
|
||||
$class = "freq";
|
||||
$class = "frequency";
|
||||
$unit = "Hz";
|
||||
$graph_type = "sensor_frequency";
|
||||
|
||||
|
@@ -1,7 +1,7 @@
|
||||
<?php
|
||||
|
||||
$graph_type = "sensor_frequency";
|
||||
$sensor_class = "freq";
|
||||
$sensor_class = "frequency";
|
||||
$sensor_unit = "Hz";
|
||||
$sensor_type = "Frequency";
|
||||
|
||||
|
@@ -5,9 +5,9 @@ $unit = "Hz";
|
||||
|
||||
if ($_SESSION['userlevel'] >= '5')
|
||||
{
|
||||
$sql = "SELECT * FROM `sensors` AS V, `devices` AS D WHERE V.sensor_class='freq' AND V.device_id = D.device_id ORDER BY D.hostname, V.sensor_descr";
|
||||
$sql = "SELECT * FROM `sensors` AS V, `devices` AS D WHERE V.sensor_class='frequency' AND V.device_id = D.device_id ORDER BY D.hostname, V.sensor_descr";
|
||||
} else {
|
||||
$sql = "SELECT * FROM `sensors` AS V, `devices` AS D, devices_perms as P WHERE V.sensor_class='freq' V.device_id = D.device_id AND D.device_id = P.device_id AND P.user_id = '" . $_SESSION['user_id'] . "' ORDER BY D.hostname, V.sensor_descr";
|
||||
$sql = "SELECT * FROM `sensors` AS V, `devices` AS D, devices_perms as P WHERE V.sensor_class='frequency' V.device_id = D.device_id AND D.device_id = P.device_id AND P.user_id = '" . $_SESSION['user_id'] . "' ORDER BY D.hostname, V.sensor_descr";
|
||||
}
|
||||
|
||||
$query = mysql_query($sql);
|
||||
|
@@ -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'] . "'");
|
||||
}
|
||||
|
||||
?>
|
@@ -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'] . "'");
|
||||
}
|
||||
|
||||
?>
|
@@ -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'] . "'");
|
||||
}
|
||||
|
||||
?>
|
57
includes/polling/functions.inc.php
Normal file
57
includes/polling/functions.inc.php
Normal 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'] . "'");
|
||||
}
|
||||
}
|
||||
|
||||
?>
|
@@ -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'] . "'");
|
||||
}
|
||||
|
||||
?>
|
@@ -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('°') . "C (>= " . $sensor['sensor_limit'] . " " . html_entity_decode('°') . 'C)', $device, 'temperature', $sensor['sensor_id']);
|
||||
log_event('Temperature ' . $sensor['sensor_descr'] . " over threshold: " . $sensor_value . " " . html_entity_decode('°') . "$unit (>= " . $sensor['sensor_limit'] . " " . html_entity_decode('°') . "$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'] . "'");
|
||||
}
|
||||
|
||||
?>
|
@@ -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'] . "'");
|
||||
}
|
||||
|
||||
?>
|
@@ -15,6 +15,7 @@
|
||||
include("includes/defaults.inc.php");
|
||||
include("config.php");
|
||||
include("includes/functions.php");
|
||||
include("includes/polling/functions.inc.php");
|
||||
|
||||
$poller_start = utime();
|
||||
echo("Observium Poller v".$config['version']."\n\n");
|
||||
@@ -222,12 +223,7 @@ while ($device = mysql_fetch_assoc($device_query))
|
||||
}
|
||||
} else {
|
||||
include("includes/polling/ipmi.inc.php");
|
||||
include("includes/polling/temperatures.inc.php");
|
||||
include("includes/polling/humidity.inc.php");
|
||||
include("includes/polling/fanspeeds.inc.php");
|
||||
include("includes/polling/voltages.inc.php");
|
||||
include("includes/polling/frequencies.inc.php");
|
||||
include("includes/polling/current.inc.php");
|
||||
include("includes/polling/sensors.inc.php");
|
||||
include("includes/polling/processors.inc.php");
|
||||
include("includes/polling/mempools.inc.php");
|
||||
include("includes/polling/storage.inc.php");
|
||||
|
Reference in New Issue
Block a user