From 07e730de71af36055b28d5119c1b5d62cce241fb Mon Sep 17 00:00:00 2001 From: Adam Amstrong Date: Mon, 3 May 2010 16:20:32 +0000 Subject: [PATCH] basics of customisable ifAlias parser. fixed "Processorss" to "Processors" in top menu git-svn-id: http://www.observium.org/svn/observer/trunk@1088 61d68cd4-352d-0410-923a-c4978735b2b8 --- config.php.default | 3 +++ database-update.sql | 2 ++ html/includes/print-menubar.php | 2 +- html/pages/customers.php | 2 +- html/pages/services.php | 36 ++++++++++++++++++++++++++++++--- includes/polling/ports.inc.php | 22 ++++++++++++++++++++ 6 files changed, 62 insertions(+), 5 deletions(-) diff --git a/config.php.default b/config.php.default index a07bacb7e..2dad094be 100755 --- a/config.php.default +++ b/config.php.default @@ -106,6 +106,9 @@ $config['show_services'] = 1; # Enable Services on menu $config['ports_page_default'] = "details/"; # Default devices ports page display type. "details/", "graphs/bits/", etc +#$config['port_descr_parser'] = "includes/port-descr-parser.inc.php"; +## Use parser to parse out ifAlias into type/descr/speed/circuit/notes + ### Which additional features should we enable? $config['enable_bgp'] = 1; # Enable BGP session collection and display diff --git a/database-update.sql b/database-update.sql index 054109e91..5f9b04894 100644 --- a/database-update.sql +++ b/database-update.sql @@ -5,3 +5,5 @@ DROP TABLE `cempMemPool`; DROP TABLE `cpmCPU`; DROP TABLE `cmpMemPool`; ALTER TABLE `mempools` CHANGE `mempool_used` `mempool_used` BIGINT( 16 ) NOT NULL ,CHANGE `mempool_free` `mempool_free` BIGINT( 16 ) NOT NULL ,CHANGE `mempool_total` `mempool_total` BIGINT( 16 ) NOT NULL ,CHANGE `mempool_largestfree` `mempool_largestfree` BIGINT( 16 ) NULL DEFAULT NULL ,CHANGE `mempool_lowestfree` `mempool_lowestfree` BIGINT( 16 ) NULL DEFAULT NULL ; +ALTER TABLE `ports` ADD `port_descr_type` VARCHAR( 32 ) NULL DEFAULT NULL AFTER `device_id` ,ADD `port_descr_descr` VARCHAR( 64 ) NULL DEFAULT NULL AFTER `port_descr_type` ,ADD `port_descr_circuit` VARCHAR( 64 ) NULL DEFAULT NULL AFTER `port_descr_descr` ,ADD `port_descr_speed` VARCHAR( 32 ) NULL DEFAULT NULL AFTER `port_descr_circuit` ,ADD `port_descr_notes` VARCHAR( 128 ) NULL DEFAULT NULL AFTER `port_descr_speed`; + diff --git a/html/includes/print-menubar.php b/html/includes/print-menubar.php index 8647e76eb..c959c2873 100644 --- a/html/includes/print-menubar.php +++ b/html/includes/print-menubar.php @@ -176,7 +176,7 @@ echo('
  • Processorss
  • +
  • Processors
  • Memory
  • Storage

  • diff --git a/html/pages/customers.php b/html/pages/customers.php index a813784f1..f20877c5e 100644 --- a/html/pages/customers.php +++ b/html/pages/customers.php @@ -31,7 +31,7 @@ $ifclass = ifclass($interface['ifOperStatus'], $interface['ifAdminStatus']); - list(,$customer) = preg_split("/[\:\[\]\{\}\(\)]/", $interface['ifAlias']); + list($type,$customer) = preg_split("/[\:\[\]\{\}\(\)]/", $interface['ifAlias']); list(,$circuit) = preg_split("/[\{\}]/", $interface['ifAlias']); list(,$notes) = preg_split("/[\(\)]/", $interface['ifAlias']); list(,$speed) = preg_split("/[\[\]]/", $interface['ifAlias']); diff --git a/html/pages/services.php b/html/pages/services.php index e089a7367..344addec3 100644 --- a/html/pages/services.php +++ b/html/pages/services.php @@ -1,4 +1,13 @@ -Basic | "); +echo("Details"); + +print_optionbar_end(); + +print_r($_GET); if($_GET['status'] == '0') { $where = " AND service_status = '0'"; } else { unset ($where); } @@ -15,9 +24,30 @@ if ($_SESSION['userlevel'] >= '5') { $device_id = $host_data['device_id']; $device_hostname = $host_data['hostname']; $service_query = mysql_query("SELECT * FROM `services` WHERE `device_id` = '" . $host_data['device_id'] . "' $where"); - while($service = mysql_fetch_array($service_query)) { + while($service = mysql_fetch_array($service_query)) + { include("includes/print-service.inc"); - $samehost = 1; +# $samehost = 1; + if($_GET['opta'] == "details") + { + + $graph_array['height'] = "100"; + $graph_array['width'] = "215"; + $graph_array['to'] = $now; + $graph_array['id'] = $service['service_id']; + $graph_array['type'] = "service"; + + $periods = array('day', 'week', 'month', 'year'); + + echo(''); + + foreach($periods as $period) { + $graph_array['from'] = $$period; + $graph_array_zoom = $graph_array; $graph_array_zoom['height'] = "150"; $graph_array_zoom['width'] = "400"; + echo(overlib_link($_SERVER['REQUEST_URI'], generate_graph_tag($graph_array), generate_graph_tag($graph_array_zoom), NULL)); + } + echo(""); + } } unset ($samehost); } diff --git a/includes/polling/ports.inc.php b/includes/polling/ports.inc.php index 309b690c2..0ab72c065 100755 --- a/includes/polling/ports.inc.php +++ b/includes/polling/ports.inc.php @@ -92,6 +92,28 @@ } } + /// Parse description (usually ifAlias) if config option set + + if(isset($config['port_descr_parser'])) + { + $port_attribs = array('type','descr','circuit','speed','notes'); + include($config['port_descr_parser']); + + foreach ($port_attribs as $attrib) { + $attrib_key = "port_descr_".$attrib; + if($port_ifAlias[$attrib]) + { + if($port_ifAlias[$attrib] != $port[$attrib_key]) + { + $update .= ", `".$attrib_key."` = '".$port_ifAlias[$attrib]."'"; + eventlog($attrib . ": ".$port[$attrib_key]." -> " . $port_ifAlias[$attrib], $device['device_id'], $port['interface_id']); + } + } + } + } + + /// Ende parse ifAlias + /// Update IF-MIB metrics foreach ($stat_oids_db as $oid) { $update .= ", `$oid` = '".$this_port[$oid]."'";