From 16a098931635e46871ef6c61b38fdeec214e87dd Mon Sep 17 00:00:00 2001 From: Tom Laermans Date: Mon, 3 Oct 2011 13:40:37 +0000 Subject: [PATCH] move and optimize away some sql queries, remove obsolete code git-svn-id: http://www.observium.org/svn/observer/trunk@2638 61d68cd4-352d-0410-923a-c4978735b2b8 --- html/includes/print-menubar.php | 22 ---------------------- html/includes/print-vm.inc.php | 4 ++-- html/includes/topnav.inc.php | 15 ++++++++++++++- html/index.php | 27 +++++++++++++++------------ includes/common.php | 27 +++++++++++++++++++-------- includes/rewrites.php | 2 +- includes/snmp.inc.php | 1 - 7 files changed, 51 insertions(+), 47 deletions(-) diff --git a/html/includes/print-menubar.php b/html/includes/print-menubar.php index 46a71eba1..d541c32cf 100644 --- a/html/includes/print-menubar.php +++ b/html/includes/print-menubar.php @@ -3,33 +3,11 @@ $service_alerts = dbFetchCell("SELECT COUNT(service_id) FROM services WHERE service_status = '0'"); $if_alerts = dbFetchCell("SELECT COUNT(interface_id) FROM `ports` WHERE `ifOperStatus` = 'down' AND `ifAdminStatus` = 'up' AND `ignore` = '0'"); -$device_alerts = "0"; -$device_alert_sql = "WHERE 0"; - if (isset($config['enable_bgp']) && $config['enable_bgp']) { $bgp_alerts = dbFetchCell("SELECT COUNT(*) FROM bgpPeers AS B where (bgpPeerAdminStatus = 'start' OR bgpPeerAdminStatus = 'running') AND bgpPeerState != 'established'"); } -foreach (dbFetchRows("SELECT * FROM `devices`") as $device) -{ - $this_alert = 0; - if ($device['status'] == 0 && $device['ignore'] == '0') { $this_alert = "1"; } elseif ($device['ignore'] == '0') - { - - ## sluggish. maybe we cache this at poll-time? - -# if (dbFetchCell("SELECT count(service_id) FROM services WHERE service_status = '0' AND device_id = ?", array($device['device_id']))) { $this_alert = "1"; } -# if (dbFetchCell("SELECT count(*) FROM ports WHERE `ifOperStatus` = 'down' AND `ifAdminStatus` = 'up' AND device_id = ? AND `ignore` = '0'", array($device['device_id']))) { $this_alert = "1"; } - } - if ($this_alert) - { - $device_alerts++; - $device_alert_sql .= " OR `device_id` = '" . $device['device_id'] . "'"; - } - - $cache['devices'][$device['hostname']] = $device; -} ?>