librenms/check-errors.php
2008-03-17 22:31:05 +00:00

33 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]'"; }
$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_errors($interface);
mysql_query("UPDATE `interfaces` SET in_errors = '" . $errors['in'] . "', out_errors = '" . $errors['out'] . "' WHERE interface_id = '" . $interface['interface_id'] . "'");
if($errors['in'] > '100' || $errors['out'] > '100') { $errored[] = $interface['hostname'] . " - " . $interface['ifDescr'] . " - " . $interface['ifAlias'] . " - " . $errors['in'] . " - " . $errors['out']; }
}
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 interfaces", $msg, $config['email_headers']);
}
?>