From 19ccf99d8ff6dd653c428a7af71e8d78783bf40a Mon Sep 17 00:00:00 2001 From: Adam Amstrong Date: Fri, 25 Jun 2010 12:18:00 +0000 Subject: [PATCH] unify $os_group and $os_type into $config['os'] git-svn-id: http://www.observium.org/svn/observer/trunk@1264 61d68cd4-352d-0410-923a-c4978735b2b8 --- discovery.php | 2 +- html/graph.php | 7 +- html/includes/dev-overview-data.inc.php | 2 +- html/includes/hostbox.inc | 2 +- html/pages/device.php | 2 +- html/pages/device/graphs.inc.php | 2 +- html/pages/devices.php | 2 +- includes/static-config.php | 110 +++++++++++++----------- poller.php | 2 +- 9 files changed, 69 insertions(+), 62 deletions(-) diff --git a/discovery.php b/discovery.php index b4558f50a..839712595 100755 --- a/discovery.php +++ b/discovery.php @@ -97,7 +97,7 @@ while ($device = mysql_fetch_array($device_query)) mysql_query("UPDATE `devices` SET `os` = '".strtolower($device['os'])."' WHERE device_id = '".$device['device_id']."'"); $device['os'] = strtolower($device['os']); echo("OS lowercased."); } - if($os_groups[$device['os']]) {$device['os_group'] = $os_groups[$device['os']]; echo "(".$device['os_group'].")";} + if($config['os'][$device['os']]['group']) {$device['os_group'] = $config['os'][$device['os']]['group']; echo "(".$device['os_group'].")";} echo("\n"); diff --git a/html/graph.php b/html/graph.php index 11a7df535..340b4626b 100644 --- a/html/graph.php +++ b/html/graph.php @@ -42,12 +42,11 @@ if($_GET['debug']) { $graphfile = $config['temp_dir'] . "/" . strgen() . ".png"; $os = gethostosbyid($device_id); - $os_lower = strtolower($os); - if($os_groups[$os_lower]) {$os_group = $os_groups[$os_lower];} + if($config['os'][$os]['group']) {$os_group = $config['os'][$os]['group'];} - if(is_file($config['install_dir'] . "/html/includes/graphs/".$type."_".$os_lower.".inc.php")) { + if(is_file($config['install_dir'] . "/html/includes/graphs/".$type."_".$os.".inc.php")) { /// Type + OS Specific - include($config['install_dir'] . "/html/includes/graphs/".$type."_".$os_lower.".inc.php"); + include($config['install_dir'] . "/html/includes/graphs/".$type."_".$os.".inc.php"); }elseif($os_group && is_file($config['install_dir'] . "/html/includes/graphs/".$type."_".$os_group.".inc.php")) { /// Type + OS Group Specific include($config['install_dir'] . "/html/includes/graphs/".$type."_".$os_group.".inc.php"); diff --git a/html/includes/dev-overview-data.inc.php b/html/includes/dev-overview-data.inc.php index 68700381c..eb55e0355 100644 --- a/html/includes/dev-overview-data.inc.php +++ b/html/includes/dev-overview-data.inc.php @@ -26,7 +26,7 @@ if ($device['os'] == "ios") { formatCiscoHardware($device); } if ($device['features']) { $device['features'] = "(".$device['features'].")"; } - $device['os_text'] = $os_text[$device['os']]; + $device['os_text'] = $config['os'][$device['os']]['text']; echo($dev_img . ' '); diff --git a/html/includes/hostbox.inc b/html/includes/hostbox.inc index f7e56c61a..9a095df17 100644 --- a/html/includes/hostbox.inc +++ b/html/includes/hostbox.inc @@ -12,7 +12,7 @@ $image = getImage($device['device_id']); if ($device['os'] == "ios") { formatCiscoHardware($device, true); } - $device['os_text'] = $os_text[$device['os']]; + $device['os_text'] = $config['os'][$device['os']]['text']; echo(' diff --git a/html/pages/device.php b/html/pages/device.php index 9a1d02a50..33733f372 100644 --- a/html/pages/device.php +++ b/html/pages/device.php @@ -17,7 +17,7 @@ $select[$section] = "selected"; $device_query = mysql_query("SELECT * FROM `devices` WHERE `device_id` = '" . $_GET['id'] . "'"); while($device = mysql_fetch_array($device_query)) { - if($os_groups[$device['os']]) {$device['os_group'] = $os_groups[$device['os']]; } + if($config['os'][$device['os']]['group']) {$device['os_group'] = $config['os'][$device['os']]['group']; } echo('
'); include("includes/device-header.inc.php"); diff --git a/html/pages/device/graphs.inc.php b/html/pages/device/graphs.inc.php index 985c7352c..1331f9a15 100644 --- a/html/pages/device/graphs.inc.php +++ b/html/pages/device/graphs.inc.php @@ -8,7 +8,7 @@ while ($device = mysql_fetch_array($device_query)) echo('
'); - if ($os_groups[$device['os']]) { $os_group = $os_groups[$device['os']]; } + if ($config['os'][$device['os']]['group']) { $os_group = $config['os'][$device['os']]['group']; } if (is_file($config['install_dir'] . "/html/pages/device/graphs/os-".$device['os'].".inc.php")) { /// OS Specific diff --git a/html/pages/devices.php b/html/pages/devices.php index 488579fe5..094f2cec2 100644 --- a/html/pages/devices.php +++ b/html/pages/devices.php @@ -17,7 +17,7 @@ { echo(""); + echo(">".$config['os'][$data['os']]['text'].""); } } ?> diff --git a/includes/static-config.php b/includes/static-config.php index 305decb43..876f6b357 100644 --- a/includes/static-config.php +++ b/includes/static-config.php @@ -20,61 +20,69 @@ $config['afi']['ipv6']['multicast'] = "IPv6 Multicast"; ## Don't bulkwalk for these OS types $config['nobulkwalk'] = array("netmanplus"); -## Set OS Groups -$os_groups['linux'] = "unix"; -$os_groups['freebsd'] = "unix"; -$os_groups['openbsd'] = "unix"; -$os_groups['netbsd'] = "unix"; -$os_groups['dragonfly'] = "unix"; -$os_groups['monowall'] = "unix"; -$os_groups['solaris'] = "unix"; -$os_groups['adva'] = "unix"; -$os_groups['opensolaris'] = "unix"; +$config['os']['linux']['group'] = "unix"; +$config['os']['linux']['text'] = "Linux"; +$config['os']['freebsd']['group'] = "unix"; +$config['os']['freebsd']['text'] = "FreeBSD"; +$config['os']['openbsd']['group'] = "unix"; +$config['os']['openbsd']['text'] = "OpenBSD"; +$config['os']['netbsd']['group'] = "unix"; +$config['os']['netbsd']['text'] = "NetBSD"; +$config['os']['dragonfly']['group'] = "unix"; +$config['os']['dragonfly']['text'] = "DragonflyBSD"; +$config['os']['monowall']['group'] = "unix"; +$config['os']['monowall']['text'] = "m0n0wall"; +$config['os']['solaris']['group'] = "unix"; +$config['os']['solaris']['text'] = "Sun Solaris"; +$config['os']['opensolaris']['group'] = "unix"; +$config['os']['opensolaris']['text'] = "Adva"; +$config['os']['opensolaris']['group'] = "unix"; +$config['os']['opensolaris']['text'] = "Sun OpenSolaris"; -$os_groups['iosxe'] = "ios"; -$os_groups['iosxr'] = "ios"; -$os_groups['ios'] = "ios"; -$os_groups['asa'] = "ios"; +$config['os']['ios']['group'] = "ios"; +$config['os']['ios']['text'] = "Cisco IOS"; +$config['os']['iosxe']['group'] = "ios"; +$config['os']['iosxe']['text'] = "Cisco IOS-XE"; +$config['os']['iosxr']['group'] = "ios"; +$config['os']['iosxr']['text'] = "Cisco IOS-XR"; +$config['os']['asa']['group'] = "ios"; +$config['os']['asa']['text'] = "Cisco ASA"; +$config['os']['pix']['group'] = "ios"; +$config['os']['pix']['text'] = "Cisco PIXOS"; +$config['os']['nxos']['group'] = "ios"; +$config['os']['nxos']['text'] = "Cisco NX-OS"; +$config['os']['catos']['group'] = "ios"; +$config['os']['catos']['text'] = "Cisco CatOS"; -$os_groups['mgeups'] = "ups"; -$os_groups['netmanplus'] = "ups"; +$config['os']['junos']['text'] = "Juniper JunOS"; +$config['os']['junose']['text'] = "Juniper JunOSe"; -$os_groups['dell-laser'] = "printer"; +$config['os']['mgeups']['group'] = "ios"; +$config['os']['mgeups']['text'] = "Cisco IOS"; +$config['os']['netmanplus']['group'] = "ios"; +$config['os']['netmanplus']['text'] = ""; +$config['os']['generic']['text'] = "Generic Device"; +$config['os']['ironware']['text'] = "Brocade IronWare"; +$config['os']['powerconnect']['text'] = "Dell PowerConnect"; +$config['os']['windows']['text'] = "Microsoft Windows"; +$config['os']['procurve']['text'] = "HP ProCurve"; +$config['os']['speedtouch']['text'] = "Thomson Speedtouch"; +$config['os']['allied']['text'] = "AlliedWare"; + +$config['os']['mgeups']['text'] = "MGE UPS"; +$config['os']['mgeups']['group'] = "ups"; + +$config['os']['apc']['text'] = "APC Management Module"; +$config['os']['areca']['text'] = "Areca RAID Subsystem"; +$config['os']['netmanplus']['text'] = "NetMan Plus"; +$config['os']['netmanplus']['group'] = "ups"; +$config['os']['akcp']['text'] = "AKCP SensorProbe"; +$config['os']['minkelsrms']['text'] = "Minkels RMS"; +$config['os']['papouch-tme']['text'] = "Papouch TME"; + +$config['os']['dell-laser']['group'] = "printer"; +$config['os']['dell-laser']['text'] = "Dell Laser"; -## -$os_text['linux'] = "Linux"; -$os_text['ios'] = "Cisco IOS"; -$os_text['iosxr'] = "Cisco IOS XE"; -$os_text['iosxe'] = "Cisco IOS XR"; -$os_text['catos'] = "Cisco CatOS"; -$os_text['nxos'] = "Cisco NX-OS"; -$os_text['asa'] = "Cisco ASA"; -$os_text['pix'] = "Cisco PIX"; -$os_text['generic'] = "Generic Device"; -$os_text['ironware'] = "Brocade IronWare"; -$os_text['monowall'] = "m0n0wall"; -$os_text['freebsd'] = "FreeBSD"; -$os_text['openbsd'] = "OpenBSD"; -$os_text['netbsd'] = "NetBSD"; -$os_text['dragonflybsd'] = "DragonFlyBSD"; -$os_text['solaris'] = "Sun Solaris"; -$os_text['opensolaris'] = "OpenSolaris"; -$os_text['powerconnect'] = "Dell PowerConnect"; -$os_text['windows'] = "Microsoft Windows"; -$os_text['junos'] = "Juniper JunOS"; -$os_text['junose'] = "Juniper JunOSe"; -$os_text['procurve'] = "HP ProCurve"; -$os_text['speedtouch'] = "Thomson Speedtouch"; -$os_text['dell-laser'] = "Dell Laser Printer"; -$os_text['adva'] = "Adva"; -$os_text['allied'] = "AlliedWare"; -$os_text['mgeups'] = "MGE UPS"; -$os_text['apc'] = "APC Management Module"; -$os_text['areca'] = "Areca RAID Subsystem"; -$os_text['netmanplus'] = "NetMan Plus"; -$os_text['akcp'] = "AKCP SensorProbe"; -$os_text['minkelsrms'] = "Minkels RMS"; -$os_text['papouch-tme'] = "Papouch TME"; if(!$config['graph_colours']['greens']) { $config['graph_colours']['greens'] = array('B6D14B','91B13C','6D912D','48721E','24520F','003300'); diff --git a/poller.php b/poller.php index bed7120ee..010416636 100755 --- a/poller.php +++ b/poller.php @@ -53,7 +53,7 @@ while ($device = mysql_fetch_array($device_query)) { $device_start = utime(); // Start counting device poll time echo($device['hostname'] . " ".$device['device_id']." ".$device['os']." "); - if ($os_groups[$device['os']]) {$device['os_group'] = $os_groups[$device['os']]; echo "(".$device['os_group'].")";} + if($config['os'][$device['os']]['group']) {$device['os_group'] = $config['os'][$device['os']]['group']; echo "(".$device['os_group'].")";} echo("\n"); unset($poll_update); unset($poll_update_query); unset($poll_separator); unset($version); unset($uptime); unset($features);