From d21af56be1deb6b108c8c695871e8c01e36a78c1 Mon Sep 17 00:00:00 2001 From: Adam Amstrong Date: Fri, 28 May 2010 15:21:27 +0000 Subject: [PATCH] fix emailing of up/down hosts and add config option to allow unauth'd graphs git-svn-id: http://www.observium.org/svn/observer/trunk@1091 61d68cd4-352d-0410-923a-c4978735b2b8 --- html/graph.php | 4 +++- includes/defaults.inc.php | 2 ++ poll-device.php | 3 +++ 3 files changed, 8 insertions(+), 1 deletion(-) diff --git a/html/graph.php b/html/graph.php index bf24aa527..c2027b761 100644 --- a/html/graph.php +++ b/html/graph.php @@ -15,7 +15,9 @@ if($_GET['debug']) { include("../includes/rewrites.php"); include("includes/authenticate.inc.php"); - if(!$_SESSION['authenticated']) { echo("not authenticated"); exit; } + if(!$config['allow_unauth_graphs']) { + if(!$_SESSION['authenticated']) { echo("not authenticated"); exit; } + } if($_GET['device']) { $_GET['id'] = $_GET['device']; diff --git a/includes/defaults.inc.php b/includes/defaults.inc.php index 2546b0a0d..365a9121b 100644 --- a/includes/defaults.inc.php +++ b/includes/defaults.inc.php @@ -83,6 +83,8 @@ $config['ignore_mount_optical'] = 1; # Ignore mounted optical discs $config['device_traffic_iftype'] = array('/loopback/','/other/','/tunnel/','/virtual/','/mpls/'); $config['device_traffic_descr'] = array('/loopback/','/vlan/','/tunnel/','/:/'); +$config['allow_unauth_graphs'] = 0; ## Allow graphs to be viewed by anyone + # Sensors $config['allow_entity_sensor']['amperes'] = 1; diff --git a/poll-device.php b/poll-device.php index 825256649..49253c754 100755 --- a/poll-device.php +++ b/poll-device.php @@ -78,6 +78,9 @@ while ($device = mysql_fetch_array($device_query)) { mysql_query("UPDATE `devices` SET `status` = '".$status."' WHERE `device_id` = '".$device['device_id']."'"); mysql_query("INSERT INTO alerts (importance, device_id, message) VALUES ('0', '" . $device['device_id'] . "', 'Device is " .($status == '1' ? 'up' : 'down') . "')"); eventlog('Device status changed to ' . ($status == '1' ? 'Up' : 'Down'), $device['device_id']); + mail($email, "Device ".($status == '1' ? 'Up' : 'Down').": " . $device['hostname'], "Device ".($status == '1' ? 'up' : 'down').": " . $device['hostname'] . " at " . date($config['timestamp_format']), $config['email_headers']); + + } if ($status == "1")