Added support for custom customer descriptions in ifDescr

This commit is contained in:
laf
2015-05-14 00:37:40 +01:00
parent 0c4ff03cda
commit 8f8ef81799
4 changed files with 16 additions and 3 deletions

View File

@ -125,6 +125,7 @@ $config['show_locations'] = 1; # Enable Locations on menu
$config['show_locations_dropdown'] = 1; # Enable Locations dropdown on menu $config['show_locations_dropdown'] = 1; # Enable Locations dropdown on menu
$config['show_services'] = 0; # Enable Services on menu $config['show_services'] = 0; # Enable Services on menu
$config['int_customers'] = 1; # Enable Customer Port Parsing $config['int_customers'] = 1; # Enable Customer Port Parsing
$config['customers_descr'] = 'cust'; // The description to look for in ifDescr. Can be an array as well array('cust','cid');
$config['int_transit'] = 1; # Enable Transit Types $config['int_transit'] = 1; # Enable Transit Types
$config['int_peering'] = 1; # Enable Peering Types $config['int_peering'] = 1; # Enable Peering Types
$config['int_core'] = 1; # Enable Core Port Types $config['int_core'] = 1; # Enable Core Port Types

View File

@ -2,7 +2,13 @@
// Generate a list of ports and then call the multi_bits grapher to generate from the list // Generate a list of ports and then call the multi_bits grapher to generate from the list
$i=0; $i=0;
foreach (dbFetchRows("SELECT * FROM `ports` AS I, `devices` AS D WHERE `port_descr_type` = 'cust' AND `port_descr_descr` = ? AND D.device_id = I.device_id", array($vars['id'])) as $port)
if (!is_array($config['customers_descr'])) {
$config['customers_descr'] = array($config['customers_descr']);
}
$descr_type = "'". implode("', '", $config['customers_descr']) ."'";
foreach (dbFetchRows("SELECT * FROM `ports` AS I, `devices` AS D WHERE `port_descr_type` IN (?) AND `port_descr_descr` = ? AND D.device_id = I.device_id", array(array($descr_type),$vars['id'])) as $port)
{ {
if (is_file($config['rrd_dir'] . "/" . $port['hostname'] . "/port-" . safename($port['ifIndex'] . ".rrd"))) if (is_file($config['rrd_dir'] . "/" . $port['hostname'] . "/port-" . safename($port['ifIndex'] . ".rrd")))
{ {

View File

@ -18,7 +18,12 @@ $i = 1;
$pagetitle[] = "Customers"; $pagetitle[] = "Customers";
foreach (dbFetchRows("SELECT * FROM `ports` WHERE `port_descr_type` = 'cust' GROUP BY `port_descr_descr` ORDER BY `port_descr_descr`") as $customer) if (!is_array($config['customers_descr'])) {
$config['customers_descr'] = array($config['customers_descr']);
}
$descr_type = "'". implode("', '", $config['customers_descr']) ."'";
foreach (dbFetchRows("SELECT * FROM `ports` WHERE `port_descr_type` IN (?) GROUP BY `port_descr_descr` ORDER BY `port_descr_descr`", array(array($descr_type))) as $customer)
{ {
$i++; $i++;
@ -26,7 +31,7 @@ foreach (dbFetchRows("SELECT * FROM `ports` WHERE `port_descr_type` = 'cust' GRO
if (!is_integer($i/2)) { $bg_colour = $list_colour_a; } else { $bg_colour = $list_colour_b; } if (!is_integer($i/2)) { $bg_colour = $list_colour_a; } else { $bg_colour = $list_colour_b; }
foreach (dbFetchRows("SELECT * FROM `ports` WHERE `port_descr_type` = 'cust' AND `port_descr_descr` = ?", array($customer['port_descr_descr'])) as $port) foreach (dbFetchRows("SELECT * FROM `ports` WHERE `port_descr_type` IN (?) AND `port_descr_descr` = ?", array(array($descr_type),$customer['port_descr_descr'])) as $port)
{ {
$device = device_by_id_cache($port['device_id']); $device = device_by_id_cache($port['device_id']);

View File

@ -128,6 +128,7 @@ $config['public_status'] = false; // Enable public accessable status page
$config['old_graphs'] = 1; // RRDfiles from before the great rra reform. This is default for a while. $config['old_graphs'] = 1; // RRDfiles from before the great rra reform. This is default for a while.
$config['int_customers'] = 1; # Enable Customer Port Parsing $config['int_customers'] = 1; # Enable Customer Port Parsing
$config['customers_descr'] = 'cust';
$config['int_transit'] = 1; # Enable Transit Types $config['int_transit'] = 1; # Enable Transit Types
$config['int_peering'] = 1; # Enable Peering Types $config['int_peering'] = 1; # Enable Peering Types
$config['int_core'] = 1; # Enable Core Port Types $config['int_core'] = 1; # Enable Core Port Types