Files
librenms-librenms/check-errors.php
T

42 lines
1.1 KiB
PHP
Raw Normal View History

2010-09-03 18:26:59 +00:00
#!/usr/bin/env php
2007-06-24 16:07:03 +00:00
<?php
include("includes/defaults.inc.php");
2007-06-24 16:07:03 +00:00
include("config.php");
include("includes/functions.php");
## 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
$i = '0';
$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
while ($interface = mysql_fetch_array($interface_query))
{
2009-10-28 13:49:37 +00:00
$errors = $interface['ifInErrors_delta'] + $interface['ifOutErrors_delta'];
2011-03-15 15:10:23 +00:00
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
}
echo("Checked $i Interfaces\n");
2011-03-15 15:10:23 +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";
2011-03-17 11:12:32 +00:00
2011-03-15 15:10:23 +00:00
foreach ($errored as $int)
{
$msg .= "$int\n"; ## Add a line to the report email warning about them
2008-03-12 16:21:13 +00:00
$i++;
2011-03-15 15:10:23 +00:00
}
## 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-15 15:10:23 +00:00
?>