mirror of
https://github.com/librenms/librenms.git
synced 2024-10-07 16:52:45 +00:00
git-svn-id: http://www.observium.org/svn/observer/trunk@1344 61d68cd4-352d-0410-923a-c4978735b2b8
55 lines
2.5 KiB
PHP
55 lines
2.5 KiB
PHP
<?php
|
|
|
|
$query = "SELECT * FROM frequency WHERE device_id = '" . $device['device_id'] . "'";
|
|
$freq_data = mysql_query($query);
|
|
while($frequency = mysql_fetch_array($freq_data)) {
|
|
|
|
echo("Checking frequency " . $frequency['freq_descr'] . "... ");
|
|
|
|
$freq = snmp_get($device, $frequency['freq_oid'], "-OUqnv", "SNMPv2-MIB");
|
|
|
|
if ($frequency['freq_precision'])
|
|
{
|
|
$freq = $freq / $frequency['freq_precision'];
|
|
}
|
|
|
|
$freqrrd = $config['rrd_dir'] . "/" . $device['hostname'] . "/" . safename("freq-" . $frequency['freq_descr'] . ".rrd");
|
|
|
|
if (!is_file($freqrrd)) {
|
|
`rrdtool create $freqrrd \
|
|
--step 300 \
|
|
DS:freq: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($freqrrd,"N:$freq");
|
|
|
|
if($frequency['freq_current'] > $frequency['freq_limit_low'] && $freq <= $frequency['freq_limit_low'])
|
|
{
|
|
if($device['sysContact']) { $email = $device['sysContact']; } else { $email = $config['email_default']; }
|
|
$msg = "Frequency Alarm: " . $device['hostname'] . " " . $frequency['freq_descr'] . " is " . $freq . "Hz (Limit " . $frequency['freq_limit'];
|
|
$msg .= "Hz) at " . date($config['timestamp_format']);
|
|
notify($device, "Frequency Alarm: " . $device['hostname'] . " " . $frequency['freq_descr'], $msg);
|
|
echo("Alerting for " . $device['hostname'] . " " . $frequency['freq_descr'] . "\n");
|
|
log_event('Frequency ' . $frequency['freq_descr'] . " under threshold: " . $freq . " Hz (< " . $frequency['freq_limit_low'] . " Hz)", $device['device_id'] , 'frequency', $frequency['freq_id']);
|
|
}
|
|
else if($frequency['freq_current'] < $frequency['freq_limit'] && $freq >= $frequency['freq_limit'])
|
|
{
|
|
if($device['sysContact']) { $email = $device['sysContact']; } else { $email = $config['email_default']; }
|
|
$msg = "Frequency Alarm: " . $device['hostname'] . " " . $frequency['freq_descr'] . " is " . $freq . "Hz (Limit " . $frequency['freq_limit'];
|
|
$msg .= "Hz) at " . date($config['timestamp_format']);
|
|
notify($device, "Frequency Alarm: " . $device['hostname'] . " " . $frequency['freq_descr'], $msg);
|
|
echo("Alerting for " . $device['hostname'] . " " . $frequency['freq_descr'] . "\n");
|
|
log_event('Frequency ' . $frequency['freq_descr'] . " above threshold: " . $freq . " Hz (> " . $frequency['freq_limit'] . " Hz)", $device['device_id'], 'frequency', $frequency['freq_id']);
|
|
}
|
|
|
|
mysql_query("UPDATE frequency SET freq_current = '$freq' WHERE freq_id = '" . $frequency['freq_id'] . "'");
|
|
}
|
|
|
|
?>
|