2007-06-24 16:07:03 +00:00
|
|
|
#!/usr/bin/php
|
|
|
|
<?php
|
|
|
|
|
2010-02-27 14:44:38 +00:00
|
|
|
include("includes/defaults.inc.php");
|
2007-06-24 16:07:03 +00:00
|
|
|
include("config.php");
|
|
|
|
include("includes/functions.php");
|
|
|
|
|
2008-03-17 22:31:05 +00:00
|
|
|
## Check all of our interface RRD files for errors
|
|
|
|
|
2007-06-24 16:07:03 +00:00
|
|
|
if($argv[1]) { $where = "AND `interface_id` = '$argv[1]'"; }
|
|
|
|
|
2009-10-12 09:48:40 +00:00
|
|
|
$i = '0';
|
|
|
|
|
2010-02-20 17:22:22 +00:00
|
|
|
$interface_query = mysql_query("SELECT * FROM `ports` AS I, `devices` AS D WHERE I.device_id = D.device_id $where");
|
2007-06-24 16:07:03 +00:00
|
|
|
while ($interface = mysql_fetch_array($interface_query)) {
|
2009-10-28 13:49:37 +00:00
|
|
|
$errors = $interface['ifInErrors_delta'] + $interface['ifOutErrors_delta'];
|
|
|
|
if($errors > '1') {
|
|
|
|
$errored[] = $interface['hostname'] . " - " . $interface['ifDescr'] . " - " . $interface['ifAlias'] . " - " . $interface['ifInErrors_delta'] . " - " . $interface['ifOutErrors_delta'];
|
2009-10-12 09:48:40 +00:00
|
|
|
}
|
|
|
|
$i++;
|
2008-03-12 16:21:13 +00:00
|
|
|
}
|
|
|
|
|
2009-10-12 09:48:40 +00:00
|
|
|
echo("Checked $i Interfaces\n");
|
2008-03-17 22:31:05 +00:00
|
|
|
|
2010-02-20 17:22:22 +00:00
|
|
|
if($errored) { ## If there are errored ports
|
2008-03-12 16:21:13 +00:00
|
|
|
$i=0;
|
|
|
|
$msg = "Interfaces with errors : \n\n";
|
|
|
|
foreach ($errored as $int) {
|
2008-03-17 22:31:05 +00:00
|
|
|
$msg .= "$int\n"; ## Add a line to the report email warning about them
|
2008-03-12 16:21:13 +00:00
|
|
|
$i++;
|
2009-10-12 09:48:40 +00:00
|
|
|
}
|
2008-03-17 22:31:05 +00:00
|
|
|
## Send the alert email
|
2010-02-09 16:37:49 +00:00
|
|
|
mail($config['email_default'], "Observer detected errors on $i interface" . ($i != 1 ? 's' : ''), $msg, $config['email_headers']);
|
2009-11-03 20:03:26 +00:00
|
|
|
echo($msg);
|
2007-06-24 16:07:03 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
?>
|