mirror of
https://github.com/librenms/librenms.git
synced 2024-10-07 16:52:45 +00:00
Removed old alerting system code
This commit is contained in:
@@ -1,59 +0,0 @@
|
||||
#!/usr/bin/env php
|
||||
<?php
|
||||
|
||||
/**
|
||||
* Observium
|
||||
*
|
||||
* This file is part of Observium.
|
||||
*
|
||||
* @package observium
|
||||
* @subpackage alerts
|
||||
* @author Adam Armstrong <adama@memetic.org>
|
||||
* @copyright (C) 2006 - 2012 Adam Armstrong
|
||||
*/
|
||||
|
||||
chdir(dirname($argv[0]));
|
||||
|
||||
require 'includes/defaults.inc.php';
|
||||
require 'config.php';
|
||||
require 'includes/definitions.inc.php';
|
||||
require 'includes/functions.php';
|
||||
require 'html/includes/functions.inc.php';
|
||||
|
||||
// Check all of our interface RRD files for errors
|
||||
if ($argv[1]) {
|
||||
$where = 'AND `port_id` = ?';
|
||||
$params = array($argv[1]);
|
||||
}
|
||||
|
||||
$i = 0;
|
||||
$errored = 0;
|
||||
|
||||
foreach (dbFetchRows("SELECT * FROM `ports` AS I, `devices` AS D WHERE I.device_id = D.device_id $where", $params) as $interface) {
|
||||
$errors = ($interface['ifInErrors_delta'] + $interface['ifOutErrors_delta']);
|
||||
if ($errors > '1') {
|
||||
$errored[] = generate_device_link($interface, $interface['hostname'].' - '.$interface['ifDescr'].' - '.$interface['ifAlias'].' - '.$interface['ifInErrors_delta'].' - '.$interface['ifOutErrors_delta']);
|
||||
$errored++;
|
||||
}
|
||||
|
||||
$i++;
|
||||
}
|
||||
|
||||
echo "Checked $i interfaces\n";
|
||||
|
||||
if (is_array($errored)) {
|
||||
// If there are errored ports
|
||||
$i = 0;
|
||||
$msg = "Interfaces with errors : \n\n";
|
||||
|
||||
foreach ($errored as $int) {
|
||||
$msg .= "$int\n";
|
||||
// Add a line to the report email warning about them
|
||||
$i++;
|
||||
}
|
||||
|
||||
// Send the alert email
|
||||
notify($device, $config['project_name']." detected errors on $i interface".($i != 1 ? 's' : ''), $msg);
|
||||
}
|
||||
|
||||
echo "$errored interfaces with errors over the past 5 minutes.\n";
|
@@ -39,22 +39,6 @@ foreach (dbFetchRows('SELECT * FROM `devices` AS D, `services` AS S WHERE S.devi
|
||||
|
||||
if ($service_status != $status) {
|
||||
$update['service_changed'] = time();
|
||||
|
||||
if ($service['sysContact']) {
|
||||
$email = $service['sysContact'];
|
||||
}
|
||||
else {
|
||||
$email = $config['email_default'];
|
||||
}
|
||||
|
||||
if ($status == '1') {
|
||||
$msg = 'Service Up: '.$service['service_type'].' on '.$service['hostname'];
|
||||
notify($device, 'Service Up: '.$service['service_type'].' on '.$service['hostname'], $msg);
|
||||
}
|
||||
else if ($status == '0') {
|
||||
$msg = 'Service Down: '.$service['service_type'].' on '.$service['hostname'];
|
||||
notify($device, 'Service Down: '.$service['service_type'].' on '.$service['hostname'], $msg);
|
||||
}
|
||||
}
|
||||
else {
|
||||
unset($updated);
|
||||
|
@@ -780,50 +780,6 @@ function send_mail($emails,$subject,$message,$html=false) {
|
||||
}
|
||||
}
|
||||
|
||||
function notify($device,$title,$message) {
|
||||
global $config;
|
||||
|
||||
if ($config['alerts']['email']['enable']) {
|
||||
if (!get_dev_attrib($device,'disable_notify')) {
|
||||
if ($config['alerts']['email']['default_only']) {
|
||||
$email = $config['alerts']['email']['default'];
|
||||
}
|
||||
else {
|
||||
if (get_dev_attrib($device,'override_sysContact_bool')) {
|
||||
$email = get_dev_attrib($device,'override_sysContact_string');
|
||||
}
|
||||
elseif ($device['sysContact']) {
|
||||
$email = $device['sysContact'];
|
||||
}
|
||||
else {
|
||||
$email = $config['alerts']['email']['default'];
|
||||
}
|
||||
}
|
||||
$emails = parse_email($email);
|
||||
if ($emails) {
|
||||
$message_header = $config['page_title_prefix']."\n\n"; // FIXME: use different config element
|
||||
$message_footer = "\n\nE-mail sent to: ";
|
||||
$i = 0;
|
||||
$count = count($emails);
|
||||
foreach ($emails as $email => $email_name) {
|
||||
$i++;
|
||||
$message_footer .= $email;
|
||||
if ($i < $count) {
|
||||
$message_footer .= ", ";
|
||||
}
|
||||
else {
|
||||
$message_footer .= "\n";
|
||||
}
|
||||
}
|
||||
$message_footer .= "E-mail sent at: " . date($config['timestamp_format']) . "\n";
|
||||
if( ($err = send_mail($emails,$title, $message_header.$message.$message_footer)) !== true) {
|
||||
echo "Mailer Error: ".$err."\n";
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
function formatCiscoHardware(&$device, $short = false) {
|
||||
if ($device['os'] == "ios") {
|
||||
if ($device['hardware']) {
|
||||
|
@@ -136,15 +136,12 @@ if ($config['enable_bgp']) {
|
||||
if ($bgpPeerFsmEstablishedTime) {
|
||||
if (!(is_array($config['alerts']['bgp']['whitelist']) && !in_array($peer['bgpPeerRemoteAs'], $config['alerts']['bgp']['whitelist'])) && ($bgpPeerFsmEstablishedTime < $peer['bgpPeerFsmEstablishedTime'] || $bgpPeerState != $peer['bgpPeerState'])) {
|
||||
if ($peer['bgpPeerState'] == $bgpPeerState) {
|
||||
notify($device, 'BGP Session flapped: '.$peer['bgpPeerIdentifier'].' (AS'.$peer['bgpPeerRemoteAs'].' - '.$peer['astext'].')', 'BGP Session flapped '.formatUptime($bgpPeerFsmEstablishedTime)." ago.\n\nHostname : ".$device['hostname']."\nPeer IP : ".$peer['bgpPeerIdentifier']."\nRemote AS: ".$peer['bgpPeerRemoteAs'].' ('.$peer['astext'].')');
|
||||
log_event('BGP Session Flap: '.$peer['bgpPeerIdentifier'].' (AS'.$peer['bgpPeerRemoteAs'].')', $device, 'bgpPeer', $bgpPeer_id);
|
||||
}
|
||||
else if ($bgpPeerState == 'established') {
|
||||
notify($device, 'BGP Session up: '.$peer['bgpPeerIdentifier'].' (AS'.$peer['bgpPeerRemoteAs'].' - '.$peer['astext'].')', 'BGP Session up since '.formatUptime($bgpPeerFsmEstablishedTime).".\n\nHostname : ".$device['hostname']."\nPeer IP : ".$peer['bgpPeerIdentifier']."\nRemote AS: ".$peer['bgpPeerRemoteAs'].' ('.$peer['astext'].')');
|
||||
log_event('BGP Session Up: '.$peer['bgpPeerIdentifier'].' (AS'.$peer['bgpPeerRemoteAs'].')', $device, 'bgpPeer', $bgpPeer_id);
|
||||
}
|
||||
else if ($peer['bgpPeerState'] == 'established') {
|
||||
notify($device, 'BGP Session down: '.$peer['bgpPeerIdentifier'].' (AS'.$peer['bgpPeerRemoteAs'].' - '.$peer['astext'].')', 'BGP Session down since '.formatUptime($bgpPeerFsmEstablishedTime).".\n\nHostname : ".$device['hostname']."\nPeer IP : ".$peer['bgpPeerIdentifier']."\nRemote AS: ".$peer['bgpPeerRemoteAs'].' ('.$peer['astext'].')');
|
||||
log_event('BGP Session Down: '.$peer['bgpPeerIdentifier'].' (AS'.$peer['bgpPeerRemoteAs'].')', $device, 'bgpPeer', $bgpPeer_id);
|
||||
}
|
||||
}
|
||||
|
@@ -102,14 +102,10 @@ function poll_sensor($device, $class, $unit) {
|
||||
|
||||
// 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'] && $sensor['sensor_alert'] == 1) {
|
||||
$msg = ucfirst($class).' Alarm: '.$device['hostname'].' '.$sensor['sensor_descr'].' is under threshold: '.$sensor_value."$unit (< ".$sensor['sensor_limit']."$unit)";
|
||||
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'] && $sensor['sensor_alert'] == 1) {
|
||||
$msg = ucfirst($class).' Alarm: '.$device['hostname'].' '.$sensor['sensor_descr'].' is over threshold: '.$sensor_value."$unit (> ".$sensor['sensor_limit']."$unit)";
|
||||
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']);
|
||||
}
|
||||
@@ -192,7 +188,6 @@ function poll_device($device, $options) {
|
||||
dbInsert(array('importance' => '0', 'device_id' => $device['device_id'], 'message' => 'Device is '.($status == '1' ? 'up' : 'down')), 'alerts');
|
||||
|
||||
log_event('Device status changed to '.($status == '1' ? 'Up' : 'Down'), $device, ($status == '1' ? 'up' : 'down'));
|
||||
notify($device, 'Device '.($status == '1' ? 'Up' : 'Down').': '.$device['hostname'], 'Device '.($status == '1' ? 'up' : 'down').': '.$device['hostname'].' '.$response['status_reason']);
|
||||
}
|
||||
|
||||
if ($status == '1') {
|
||||
|
@@ -463,7 +463,6 @@ foreach ($ports as $port) {
|
||||
echo 'IN: '.$port['stats']['ifInBits_rate'].' OUT: '.$port['stats']['ifOutBits_rate'].' THRESH: '.$saturation_threshold;
|
||||
if (($port['stats']['ifInBits_rate'] >= $saturation_threshold || $port['stats']['ifOutBits_rate'] >= $saturation_threshold) && $saturation_threshold > 0) {
|
||||
log_event('Port reached saturation threshold: '.formatRates($port['stats']['ifInBits_rate']).'/'.formatRates($port['stats']['ifOutBits_rate']).' - ifspeed: '.formatRates($this_port['stats']['ifSpeed']), $device, 'interface', $port['port_id']);
|
||||
notify($device, 'Port saturation threshold reached on '.$device['hostname'], 'Port saturation threshold alarm: '.$device['hostname'].' on '.$port['ifDescr']."\nRates:".formatRates($port['stats']['ifInBits_rate']).'/'.formatRates($port['stats']['ifOutBits_rate']).' - ifspeed: '.formatRates($this_port['ifSpeed']));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -569,27 +568,6 @@ foreach ($ports as $port) {
|
||||
}
|
||||
|
||||
// End Update Database
|
||||
// Send alerts for interface flaps.
|
||||
if ($config['alerts']['port']['ifdown'] && ($port['ifOperStatus'] != $this_port['ifOperStatus']) && $port['ignore'] == 0) {
|
||||
if ($this_port['ifAlias']) {
|
||||
$falias = preg_replace('/^"/', '', $this_port['ifAlias']);
|
||||
$falias = preg_replace('/"$/', '', $falias);
|
||||
$full = $this_port['ifDescr'].' ('.$falias.')';
|
||||
}
|
||||
else {
|
||||
$full = $this_port['ifDescr'];
|
||||
}
|
||||
|
||||
switch ($this_port['ifOperStatus']) {
|
||||
case 'up':
|
||||
notify($device, 'Interface UP - '.$device['hostname'].' - '.$full, 'Device: '.$device['hostname']."\nInterface: ".$full);
|
||||
break;
|
||||
|
||||
case 'down':
|
||||
notify($device, 'Interface DOWN - '.$device['hostname'].' - '.$full, 'Device: '.$device['hostname']."\nInterface: ".$full);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
else if ($port['disabled'] != '1') {
|
||||
echo 'Port Deleted';
|
||||
|
@@ -65,7 +65,6 @@ if ($snmp_uptime > $uptime && is_numeric($snmp_uptime)) {
|
||||
|
||||
if (is_numeric($uptime)) {
|
||||
if ($uptime < $device['uptime']) {
|
||||
notify($device, 'Device rebooted: '.$device['hostname'], 'Device Rebooted : '.$device['hostname'].' '.formatUptime($uptime).' ago.');
|
||||
log_event('Device rebooted after '.formatUptime($device['uptime']), $device, 'reboot', $device['uptime']);
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user