From 95426357619dd2fd4dc22e2c8aa0be2bbd25ba31 Mon Sep 17 00:00:00 2001 From: Adam Amstrong Date: Fri, 25 Jun 2010 13:04:03 +0000 Subject: [PATCH] merge $popgraph and $popdescr into $config['os'] as overgraph and overtext merge ifalias/ifdescr/ifname/ifindex decision making about port names into $config['os'] git-svn-id: http://www.observium.org/svn/observer/trunk@1265 61d68cd4-352d-0410-923a-c4978735b2b8 --- database-update.sql | 1 + html/includes/functions.inc.php | 17 ++- includes/polling/interfaces.inc.php | 2 +- includes/rewrites.php | 8 +- includes/snmp.inc.php | 14 +-- includes/static-config.php | 179 +++++++++++++++------------- 6 files changed, 119 insertions(+), 102 deletions(-) diff --git a/database-update.sql b/database-update.sql index d02a272d1..73fd9a1f5 100644 --- a/database-update.sql +++ b/database-update.sql @@ -16,5 +16,6 @@ CREATE TABLE IF NOT EXISTS `ucd_diskio` ( `diskio_id` int(11) NOT NULL AUTO_INC ALTER TABLE `eventlog` CHANGE `type` `type` VARCHAR( 64 ) CHARACTER SET latin1 COLLATE latin1_swedish_ci NULL DEFAULT NULL; ALTER TABLE `bills` ADD `bill_custid` VARCHAR( 64 ) NOT NULL ,ADD `bill_ref` VARCHAR( 64 ) NOT NULL ,ADD `bill_notes` VARCHAR( 256 ) NOT NULL; CREATE TABLE IF NOT EXISTS `applications` ( `app_id` int(11) NOT NULL AUTO_INCREMENT, `device_id` int(11) NOT NULL, `app_type` varchar(64) NOT NULL, PRIMARY KEY (`app_id`)) ENGINE=MyISAM DEFAULT CHARSET=latin1 AUTO_INCREMENT=5 ; +## 0.10.6 CREATE TABLE IF NOT EXISTS `sensors` ( `sensor_id` int(11) NOT NULL auto_increment, `sensor_class` varchar(64) NOT NULL, `device_id` int(11) NOT NULL default '0', `sensor_oid` varchar(64) NOT NULL, `sensor_index` varchar(8) NOT NULL, `sensor_type` varchar(32) NOT NULL, `sensor_descr` varchar(32) NOT NULL default '', `sensor_precision` int(11) NOT NULL default '1', `sensor_current` float default NULL, `sensor_limit` float default NULL, `sensor_limit_warn` float default NULL, `sensor_limit_low` float default NULL, `sensor_limit_low_warn` float default NULL, PRIMARY KEY (`sensor_id`), KEY `sensor_host` (`device_id`)) ENGINE=MyISAM AUTO_INCREMENT=189 DEFAULT CHARSET=latin1; ALTER TABLE `devices` CHANGE `type` `type` VARCHAR(20) NOT NULL; diff --git a/html/includes/functions.inc.php b/html/includes/functions.inc.php index dc80cdc4a..068fc7e5f 100644 --- a/html/includes/functions.inc.php +++ b/html/includes/functions.inc.php @@ -11,21 +11,26 @@ function generateiflink($interface, $text=0, $type = NULL) function generatedevicelink($device, $text=0, $start=0, $end=0) { - global $twoday; global $day; global $now; global $config; global $popgraph; global $popdescr; + global $twoday; global $day; global $now; global $config; if (!$start) { $start = $day; } if (!$end) { $end = $now; } $class = devclass($device); if (!$text) { $text = $device['hostname']; } - if (isset($popgraph[$device['os']])) + if (isset($config['os'][$device['os']]['overgraph'])) { - $graphs = $popgraph[$device['os']]; - $descr = $popdescr[$device['os']]; + $graphs = $config['os'][$device['os']]['overgraph']; + $descr = $config['os'][$device['os']]['overtext']; } + elseif (isset($config['os'][$device['os_group']]['overgraph'])) + { + $graphs = $config['os'][$device['os_group']]['overgraph']; + $descr = $config['os'][$device['os_group']]['overtext']; + } else { - $graphs = $popgraph['default']; - $descr = $popdescr['default']; + $graphs = $config['os']['default']['overgraph']; + $descr = $config['os']['default']['overtext']; } $url = $config['base_url']."/device/" . $device['device_id'] . "/"; diff --git a/includes/polling/interfaces.inc.php b/includes/polling/interfaces.inc.php index e63b9bddc..edb97ee64 100644 --- a/includes/polling/interfaces.inc.php +++ b/includes/polling/interfaces.inc.php @@ -59,7 +59,7 @@ while ($interface = mysql_fetch_array($interface_query)) { } } - if($config[ifname][$device[os]]) { $ifDescr = $ifName; } + if($config['os'][$device[os]]['ifname']) { $ifDescr = $ifName; } $rrdfile = $host_rrd . "/" . safename($interface['ifIndex'] . ".rrd"); diff --git a/includes/rewrites.php b/includes/rewrites.php index 95100007c..e367129cc 100644 --- a/includes/rewrites.php +++ b/includes/rewrites.php @@ -15,16 +15,16 @@ function ifLabel ($interface, $device = NULL) { if(!$device) { $device = device_array($interface['device_id']); } $os = strtolower($device['os']); - if(isset($config['ifname'][$os])) { + if (isset($config['os'][$os]['ifname'])) { $interface['label'] = $interface['ifName']; - } elseif(isset($config['ifAlias'][$os])) { + } elseif (isset($config['os'][$os]['ifalias'])) { $interface['label'] = $interface['ifAlias']; } else { $interface['label'] = $interface['ifDescr']; - if(isset($config['appendifindex'][$os])) { $interface['label'] = $interface['label'] . " " . $interface['ifIndex']; } + if (isset($config['os'][$os]['ifindex'])) { $interface['label'] = $interface['label'] . " " . $interface['ifIndex']; } } - if($device['os'] == "speedtouch") { + if ($device['os'] == "speedtouch") { list($interface['label']) = explode("thomson", $interface['label']); } diff --git a/includes/snmp.inc.php b/includes/snmp.inc.php index eec166a6e..f4bf93836 100644 --- a/includes/snmp.inc.php +++ b/includes/snmp.inc.php @@ -19,7 +19,7 @@ function snmp_get ($device, $oid, $options = NULL, $mib = NULL, $mibdir = NULL) function snmp_walk($device, $oid, $options = NULL, $mib = NULL, $mibdir = NULL) { global $debug; global $config; global $runtime_stats; - if ($device['snmpver'] == 'v1' || in_array($device['os'],$config['nobulkwalk'])) + if ($device['snmpver'] == 'v1' || $config['os'][$device['os']]['nobulk']) { $snmpcommand = $config['snmpwalk']; } @@ -43,7 +43,7 @@ function snmp_walk($device, $oid, $options = NULL, $mib = NULL, $mibdir = NULL) function snmp_cache_cip($oid, $device, $array, $mib = 0) { global $config; - if ($device['snmpver'] == 'v1' || in_array($device['os'],$config['nobulkwalk'])) + if ($device['snmpver'] == 'v1' || $config['os'][$device['os']]['nobulk']) { $snmpcommand = $config['snmpwalk']; } @@ -80,7 +80,7 @@ function snmp_cache_cip($oid, $device, $array, $mib = 0) function snmp_cache_ifIndex($device) { global $config; - if ($device['snmpver'] == 'v1' || in_array($device['os'],$config['nobulkwalk'])) + if ($device['snmpver'] == 'v1' || $config['os'][$device['os']]['nobulk']) { $snmpcommand = $config['snmpwalk']; } @@ -173,7 +173,7 @@ function snmpwalk_cache_triple_oid($device, $oid, $array, $mib = NULL, $mibdir = function snmpwalk_cache_twopart_oid($oid, $device, $array, $mib = 0) { global $config; - if ($device['snmpver'] == 'v1' || in_array($device['os'],$config['nobulkwalk'])) + if ($device['snmpver'] == 'v1' || $config['os'][$device['os']]['nobulk']) { $snmpcommand = $config['snmpwalk']; } @@ -199,7 +199,7 @@ function snmpwalk_cache_twopart_oid($oid, $device, $array, $mib = 0) { function snmpwalk_cache_threepart_oid($oid, $device, $array, $mib = 0) { global $config, $debug; - if ($device['snmpver'] == 'v1' || in_array($device['os'],$config['nobulkwalk'])) + if ($device['snmpver'] == 'v1' || $config['os'][$device['os']]['nobulk']) { $snmpcommand = $config['snmpwalk']; } @@ -226,7 +226,7 @@ function snmpwalk_cache_threepart_oid($oid, $device, $array, $mib = 0) { function snmp_cache_slotport_oid($oid, $device, $array, $mib = 0) { global $config; - if ($device['snmpver'] == 'v1' || in_array($device['os'],$config['nobulkwalk'])) + if ($device['snmpver'] == 'v1' || $config['os'][$device['os']]['nobulk']) { $snmpcommand = $config['snmpwalk']; } @@ -255,7 +255,7 @@ function snmp_cache_slotport_oid($oid, $device, $array, $mib = 0) { function snmp_cache_oid($oid, $device, $array, $mib = 0) { global $config; - if ($device['snmpver'] == 'v1' || in_array($device['os'],$config['nobulkwalk'])) + if ($device['snmpver'] == 'v1' || $config['os'][$device['os']]['nobulk']) { $snmpcommand = $config['snmpwalk']; } diff --git a/includes/static-config.php b/includes/static-config.php index 876f6b357..e2a7d5ab0 100644 --- a/includes/static-config.php +++ b/includes/static-config.php @@ -1,15 +1,5 @@