mirror of
https://github.com/librenms/librenms.git
synced 2024-10-07 16:52:45 +00:00
git-svn-id: http://www.observium.org/svn/observer/trunk@799 61d68cd4-352d-0410-923a-c4978735b2b8
37 lines
1.1 KiB
PHP
Executable File
37 lines
1.1 KiB
PHP
Executable File
#!/usr/bin/php
|
|
<?php
|
|
|
|
include("config.php");
|
|
include("includes/functions.php");
|
|
|
|
## Check all of our interface RRD files for errors
|
|
|
|
if($argv[1]) { $where = "AND `interface_id` = '$argv[1]'"; }
|
|
|
|
$i = '0';
|
|
|
|
$interface_query = mysql_query("SELECT * FROM `interfaces` AS I, `devices` AS D WHERE I.device_id = D.device_id $where");
|
|
while ($interface = mysql_fetch_array($interface_query)) {
|
|
$errors = $interface['ifInErrors_delta'] + $interface['ifOutErrors_delta'];
|
|
if($errors > '1') {
|
|
$errored[] = $interface['hostname'] . " - " . $interface['ifDescr'] . " - " . $interface['ifAlias'] . " - " . $interface['ifInErrors_delta'] . " - " . $interface['ifOutErrors_delta'];
|
|
}
|
|
$i++;
|
|
}
|
|
|
|
echo("Checked $i Interfaces\n");
|
|
|
|
if($errored) { ## If there are errored interfaces
|
|
$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
|
|
mail($config['email_default'], "Observer detected errors on $i interface" . ($i != 1 ? 's' : ''), $msg, $config['email_headers']);
|
|
echo($msg);
|
|
}
|
|
|
|
?>
|