From be6a81f193691d449214bfa1309389b550e0ce56 Mon Sep 17 00:00:00 2001 From: Adam Amstrong Date: Fri, 27 Jan 2012 10:57:29 +0000 Subject: [PATCH] port utilisation alerter (bit dirty, maybe put %age into db too?) git-svn-id: http://www.observium.org/svn/observer/trunk@2853 61d68cd4-352d-0410-923a-c4978735b2b8 --- includes/defaults.inc.php | 5 +++++ includes/polling/ports.inc.php | 18 +++++++++++++++++- 2 files changed, 22 insertions(+), 1 deletion(-) diff --git a/includes/defaults.inc.php b/includes/defaults.inc.php index a41828e85f..0814510861 100644 --- a/includes/defaults.inc.php +++ b/includes/defaults.inc.php @@ -91,6 +91,11 @@ $config['alerts']['email']['default_only'] = FALSE; ## Only use default recipi $config['alerts']['email']['enable'] = TRUE; ## Enable email alerts $config['alerts']['bgp']['whitelist'] = NULL; ## Populate as an array() with ASNs to alert on. +### Port bandwidth threshold percentage %age utilisation above this will cause an alert + +$config['alerts']['port_util_alert'] = FALSE; ## Disabled as default +$config['alerts']['port_util_perc'] = 85; ## %age above which to alert + $config['uptime_warning'] = "84600"; ## Time in seconds to display a "Device Rebooted" Alert. 0 to disable warnings. ### Cosmetics diff --git a/includes/polling/ports.inc.php b/includes/polling/ports.inc.php index a6d862c92f..a1b6355abc 100755 --- a/includes/polling/ports.inc.php +++ b/includes/polling/ports.inc.php @@ -274,9 +274,25 @@ foreach ($ports as $port) } } - echo('bits('.formatRates($port['update']['ifInOctets_rate']).'/'.formatRates($port['update']['ifOutOctets_rate']).')'); + $port['ifInBits_rate'] = $port['update']['ifInOctets_rate'] * 8; + $port['ifOutBits_rate'] = $port['update']['ifOutOctets_rate'] * 8; + echo('bits('.formatRates($port['ifInBits_rate']).'/'.formatRates($port['ifOutBits_rate']).')'); echo('pkts('.format_si($port['update']['ifInUcastPkts_rate']).'pps/'.format_si($port['update']['ifOutUcastPkts_rate']).'pps)'); + ### Port utilisation % threshold alerting. ## Fixme allow setting threshold per-port. probably 90% of ports we don't care about. + if($config['alerts']['port_util_alert']) + { + // Check for port saturation of $config['alerts']['port_util_perc'] or higher. Alert if we see this. + // Check both inbound and outbound rates + $saturation_threshold = $this_port['ifSpeed'] * ( $config['alerts']['port_util_perc'] / 100 ); + echo("IN: " . $port['ifInBits_rate'] . " OUT: " . $port['ifOutBits_rate'] . " THRESH: " . $saturation_threshold); + if (($port['ifInBits_rate'] >= $saturation_threshold || $port['ifOutBits_rate'] >= $saturation_threshold) && $saturation_threshold > 0) + { + log_event('Port reached saturation threshold: ' . formatRates($port['ifInBits_rate']) . '/' . formatRates($port['ifOutBits_rate']) . ' - ifspeed: ' . formatRates( $this_port['ifSpeed']) , $device, 'interface', $port['interface_id']); + notify($device, 'Port saturation threshold reached on ' . $device['hostname'] , 'Port saturation threshold alarm: ' . $device['hostname'] . ' on ' . $port['ifDescr'] . "\nRates:" . formatRates($port['ifInBits_rate']) . '/' . formatRates($port['ifOutBits_rate']) . ' - ifspeed: ' . formatRates( $this_port['ifSpeed']) . "\nTimestamp: " . date($config['timestamp_format'])); + } + } + /// Update RRDs $rrdfile = $host_rrd . "/port-" . safename($port['ifIndex'] . ".rrd"); if (!is_file($rrdfile))