-
Notifications
You must be signed in to change notification settings - Fork 0
/
check-errors.php
executable file
·37 lines (29 loc) · 1.13 KB
/
check-errors.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
#!/usr/bin/php
<?php
include("includes/defaults.inc.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 `ports` 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 ports
$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);
}
?>