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
This commit is contained in:
Adam Amstrong
2012-01-27 10:57:29 +00:00
parent 528fdc9961
commit be6a81f193
2 changed files with 22 additions and 1 deletions

View File

@ -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

View File

@ -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))