2010-09-03 18:26:59 +00:00
|
|
|
#!/usr/bin/env php
|
2007-06-24 16:07:03 +00:00
|
|
|
<?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
|
|
|
|
|
2011-03-15 15:10:23 +00:00
|
|
|
if ($argv[1]) { $where = "AND `interface_id` = '$argv[1]'"; }
|
2007-06-24 16:07:03 +00:00
|
|
|
|
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");
|
2011-03-15 15:10:23 +00:00
|
|
|
|
2011-04-06 13:54:50 +00:00
|
|
|
while ($interface = mysql_fetch_assoc($interface_query))
|
2011-03-15 15:10:23 +00:00
|
|
|
{
|
2011-03-23 09:54:56 +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'];
|
|
|
|
}
|
|
|
|
$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
|
|
|
|
2011-03-15 15:10:23 +00:00
|
|
|
if ($errored)
|
|
|
|
{ ## If there are errored ports
|
2011-03-23 09:54:56 +00:00
|
|
|
$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, "Observium detected errors on $i interface" . ($i != 1 ? 's' : ''), $msg);
|
2007-06-24 16:07:03 +00:00
|
|
|
}
|
|
|
|
|
2011-03-22 20:27:39 +00:00
|
|
|
?>
|