Files
librenms-librenms/check-errors.php
T

41 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
if ($argv[1]) { $where = "AND `interface_id` = ?"; $params = array($argv[1]); }
2007-06-24 16:07:03 +00:00
$i = '0';
foreach (dbFetchRows("SELECT * FROM `ports` AS I, `devices` AS D WHERE I.device_id = D.device_id $where", $params) as $interface)
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
}
echo("Checked $i Interfaces\n");
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
?>