Update graph and port pages to use new RRD naming schema.

Signed-off-by: Maximilian Wilhelm <max@rfc2324.org>
This commit is contained in:
Maximilian Wilhelm
2016-01-21 22:04:33 +01:00
parent 2c9df26bbf
commit 4d78a0261e
22 changed files with 65 additions and 54 deletions
+3 -2
View File
@@ -4,8 +4,9 @@
$i = 0;
foreach ($ports as $port) {
if (is_file($config['rrd_dir'].'/'.$port['hostname'].'/port-'.safename($port['ifIndex'].'.rrd'))) {
$rrd_list[$i]['filename'] = $config['rrd_dir'].'/'.$port['hostname'].'/port-'.safename($port['ifIndex'].'.rrd');
$rrd_file = get_port_rrdfile_path ($port['hostname'], $port['port_id']);
if (is_file($rrd_file)) {
$rrd_list[$i]['filename'] = $rrd_file;
$rrd_list[$i]['descr'] = $port['ifDescr'];
$i++;
}
+2 -3
View File
@@ -10,8 +10,8 @@ if (!is_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'))) {
$rrd_filename = $config['rrd_dir'].'/'.$port['hostname'].'/port-'.safename($port['ifIndex'].'.rrd');
$rrd_filename = get_port_rrdfile_path ($port['hostname'], $port['port_id']); // FIXME: Unification OK?
if (is_file($rrd_filename)) {
$rrd_list[$i]['filename'] = $rrd_filename;
$rrd_list[$i]['descr'] = $port['hostname'].'-'.$port['ifDescr'];
$rrd_list[$i]['descr_in'] = shorthost($port['hostname']);
@@ -20,7 +20,6 @@ foreach (dbFetchRows('SELECT * FROM `ports` AS I, `devices` AS D WHERE `port_des
}
}
// echo($config['rrd_dir'] . "/" . $port['hostname'] . "/port-" . safename($port['ifIndex'] . ".rrd"));
$units = 'bps';
$total_units = 'B';
$colours_in = 'greens';
+1 -1
View File
@@ -22,7 +22,7 @@ foreach (dbFetchRows('SELECT * FROM `ports` WHERE `device_id` = ?', array($devic
}
}
$rrd_filename = $config['rrd_dir'].'/'.$device['hostname'].'/port-'.safename($port['ifIndex'].'.rrd');
$rrd_filename = get_port_rrdfile_path ($device['hostname'], $port['port_id']);
if ($ignore != 1 && is_file($rrd_filename)) {
$port = ifLabel($port);
// Fix Labels! ARGH. This needs to be in the bloody database!
+1 -1
View File
@@ -21,7 +21,7 @@ foreach (dbFetchRows('SELECT * FROM `ports` AS P, `devices` AS D WHERE D.device_
}
}
$rrd_filename = $config['rrd_dir'].'/'.$port['hostname'].'/port-'.safename($port['ifIndex'].'.rrd');
$rrd_filename = get_port_rrdfile_path ($port['hostname'], $port['port_id']);
if (!$ignore && $i < 1100 && is_file($rrd_filename)) {
$rrd_filenames[] = $rrd_filename;
$rrd_list[$i]['filename'] = $rrd_filename;
+3 -2
View File
@@ -24,8 +24,9 @@ foreach ($devices as $device) {
}
}
if (is_file($config['rrd_dir'].'/'.$device['hostname'].'/port-'.safename($int['ifIndex'].'.rrd')) && $ignore != 1) {
$rrd_filename = $config['rrd_dir'].'/'.$device['hostname'].'/port-'.safename($int['ifIndex'].'.rrd');
$rrd_file = get_port_rrdfile_path ($device['hostname'], $int['port_id']);
if (is_file($rrd_file) && $ignore != 1) {
$rrd_filename = $rrd_file; // FIXME: Can this be unified without side-effects?
$rrd_list[$i]['filename'] = $rrd_filename;
$rrd_list[$i]['descr'] = $port['label'];
$rrd_list[$i]['descr_in'] = $device['hostname'];
+4 -3
View File
@@ -8,9 +8,10 @@ foreach (explode(',', $vars['id']) as $ifid) {
$ifid = str_replace('!', '', $ifid);
}
$int = dbFetchRow('SELECT `ifIndex`, `hostname` FROM `ports` AS I, devices as D WHERE I.port_id = ? AND I.device_id = D.device_id', array($ifid));
if (is_file($config['rrd_dir'].'/'.$int['hostname'].'/port-'.safename($int['ifIndex'].'.rrd'))) {
$rrd_filenames[$i] = $config['rrd_dir'].'/'.$int['hostname'].'/port-'.safename($int['ifIndex'].'.rrd');
$int = dbFetchRow('SELECT `hostname` FROM `ports` AS I, devices as D WHERE I.port_id = ? AND I.device_id = D.device_id', array($ifid));
$rrd_file = get_port_rrdfile_path ($int['hostname'], $ifid);
if (is_file($rrd_file)) {
$rrd_filenames[$i] = $rrd_file;
$i++;
}
}
@@ -13,10 +13,11 @@ if ($height < '99') {
$i = 1;
foreach (explode(',', $_GET['id']) as $ifid) {
$int = dbFetchRow('SELECT `ifIndex`, `hostname` FROM `ports` AS I, devices as D WHERE I.port_id = ? AND I.device_id = D.device_id', array($ifid));
if (is_file($config['rrd_dir'].'/'.$int['hostname'].'/port-'.$int['ifIndex'].'.rrd')) {
$rrd_options .= ' DEF:inoctets'.$i.'='.$config['rrd_dir'].'/'.$int['hostname'].'/port-'.$int['ifIndex'].'.rrd:INOCTETS:AVERAGE';
$rrd_options .= ' DEF:outoctets'.$i.'='.$config['rrd_dir'].'/'.$int['hostname'].'/port-'.$int['ifIndex'].'.rrd:OUTOCTETS:AVERAGE';
$int = dbFetchRow('SELECT `hostname` FROM `ports` AS I, devices as D WHERE I.port_id = ? AND I.device_id = D.device_id', array($ifid));
$rrd_file = get_port_rrdfile_path ($int['hostname'], $ifid);
if (is_file($rrd_file)) {
$rrd_options .= ' DEF:inoctets'.$i.'='.$rrd_file.':INOCTETS:AVERAGE';
$rrd_options .= ' DEF:outoctets'.$i.'='.$rrd_file.':OUTOCTETS:AVERAGE';
$in_thing .= $seperator.'inoctets'.$i.',UN,0,'.'inoctets'.$i.',IF';
$out_thing .= $seperator.'outoctets'.$i.',UN,0,'.'outoctets'.$i.',IF';
$pluses .= $plus;
@@ -30,10 +31,11 @@ unset($seperator);
unset($plus);
foreach (explode(',', $_GET['idb']) as $ifid) {
$int = dbFetchRow('SELECT `ifIndex`, `hostname` FROM `ports` AS I, devices as D WHERE I.port_id = ? AND I.device_id = D.device_id', array($ifid));
if (is_file($config['rrd_dir'].'/'.$int['hostname'].'/port-'.$int['ifIndex'].'.rrd')) {
$rrd_options .= ' DEF:inoctetsb'.$i.'='.$config['rrd_dir'].'/'.$int['hostname'].'/port-'.$int['ifIndex'].'.rrd:INOCTETS:AVERAGE';
$rrd_options .= ' DEF:outoctetsb'.$i.'='.$config['rrd_dir'].'/'.$int['hostname'].'/port-'.$int['ifIndex'].'.rrd:OUTOCTETS:AVERAGE';
$int = dbFetchRow('SELECT `hostname` FROM `ports` AS I, devices as D WHERE I.port_id = ? AND I.device_id = D.device_id', array($ifid));
$rrd_file = get_port_rrdfile_path ($int['hostname'], $ifid);
if (is_file($rrd_file)) {
$rrd_options .= ' DEF:inoctetsb'.$i.'='.$rrd_file.':INOCTETS:AVERAGE';
$rrd_options .= ' DEF:outoctetsb'.$i.'='.$rrd_file.':OUTOCTETS:AVERAGE';
$in_thingb .= $seperator.'inoctetsb'.$i.',UN,0,'.'inoctetsb'.$i.',IF';
$out_thingb .= $seperator.'outoctetsb'.$i.',UN,0,'.'outoctetsb'.$i.',IF';
$plusesb .= $plus;
@@ -4,9 +4,10 @@ $i = 0;
foreach (explode(',', $vars['id']) as $ifid) {
$port = dbFetchRow('SELECT * FROM `ports` AS I, devices as D WHERE I.port_id = ? AND I.device_id = D.device_id', array($ifid));
if (is_file($config['rrd_dir'].'/'.$port['hostname'].'/port-'.safename($port['ifIndex'].'.rrd'))) {
$rrd_file = get_port_rrdfile_path ($port['hostname'], $ifid);
if (is_file($rrd_file)) {
$port = ifLabel($port);
$rrd_list[$i]['filename'] = $config['rrd_dir'].'/'.$port['hostname'].'/port-'.safename($port['ifIndex'].'.rrd');
$rrd_list[$i]['filename'] = $rrd_file;
$rrd_list[$i]['descr'] = $port['hostname'].' '.$port['ifDescr'];
$rrd_list[$i]['descr_in'] = $port['hostname'];
$rrd_list[$i]['descr_out'] = makeshortif($port['label']);
@@ -14,8 +14,9 @@ if ($height < '99') {
$i = 1;
foreach (explode(',', $_GET['id']) as $ifid) {
$int = dbFetchRow('SELECT `ifIndex`, `hostname` FROM `ports` AS I, devices as D WHERE I.port_id = ? AND I.device_id = D.device_id', array($ifid));
if (is_file($config['rrd_dir'].'/'.$int['hostname'].'/port-'.$int['ifIndex'].'.rrd')) {
$int = dbFetchRow('SELECT `hostname` FROM `ports` AS I, devices as D WHERE I.port_id = ? AND I.device_id = D.device_id', array($ifid));
$rrd_file = get_port_rrdfile_path ($int['hostname'], $ifid);
if (is_file($rrd_file)) {
if (strstr($inverse, 'a')) {
$in = 'OUT';
$out = 'IN';
@@ -25,8 +26,8 @@ foreach (explode(',', $_GET['id']) as $ifid) {
$out = 'OUT';
}
$rrd_options .= ' DEF:inoctets'.$i.'='.$config['rrd_dir'].'/'.$int['hostname'].'/port-'.$int['ifIndex'].'.rrd:'.$in.'OCTETS:AVERAGE';
$rrd_options .= ' DEF:outoctets'.$i.'='.$config['rrd_dir'].'/'.$int['hostname'].'/port-'.$int['ifIndex'].'.rrd:'.$out.'OCTETS:AVERAGE';
$rrd_options .= ' DEF:inoctets'.$i.'='.$rrd_file.':'.$in.'OCTETS:AVERAGE';
$rrd_options .= ' DEF:outoctets'.$i.'='.$rrd_file.':'.$out.'OCTETS:AVERAGE';
$in_thing .= $seperator.'inoctets'.$i.',UN,0,'.'inoctets'.$i.',IF';
$out_thing .= $seperator.'outoctets'.$i.',UN,0,'.'outoctets'.$i.',IF';
$pluses .= $plus;
@@ -40,8 +41,9 @@ unset($seperator);
unset($plus);
foreach (explode(',', $_GET['idb']) as $ifid) {
$int = dbFetchRow('SELECT `ifIndex`, `hostname` FROM `ports` AS I, devices as D WHERE I.port_id = ? AND I.device_id = D.device_id', array($ifid));
if (is_file($config['rrd_dir'].'/'.$int['hostname'].'/port-'.$int['ifIndex'].'.rrd')) {
$int = dbFetchRow('SELECT `hostname` FROM `ports` AS I, devices as D WHERE I.port_id = ? AND I.device_id = D.device_id', array($ifid));
$rrd_file = get_port_rrdfile_path ($int['hostname'], $ifid);
if (is_file($rrd_file)) {
if (strstr($inverse, 'b')) {
$in = 'OUT';
$out = 'IN';
@@ -51,8 +53,8 @@ foreach (explode(',', $_GET['idb']) as $ifid) {
$out = 'OUT';
}
$rrd_options .= ' DEF:inoctetsb'.$i.'='.$config['rrd_dir'].'/'.$int['hostname'].'/port-'.$int['ifIndex'].'.rrd:'.$in.'OCTETS:AVERAGE';
$rrd_options .= ' DEF:outoctetsb'.$i.'='.$config['rrd_dir'].'/'.$int['hostname'].'/port-'.$int['ifIndex'].'.rrd:'.$out.'OCTETS:AVERAGE';
$rrd_options .= ' DEF:inoctetsb'.$i.'='.$rrd_file.':'.$in.'OCTETS:AVERAGE';
$rrd_options .= ' DEF:outoctetsb'.$i.'='.$rrd_file.':'.$out.'OCTETS:AVERAGE';
$in_thingb .= $seperator.'inoctetsb'.$i.',UN,0,'.'inoctetsb'.$i.',IF';
$out_thingb .= $seperator.'outoctetsb'.$i.',UN,0,'.'outoctetsb'.$i.',IF';
$plusesb .= $plus;
@@ -66,8 +68,9 @@ unset($seperator);
unset($plus);
foreach (explode(',', $_GET['idc']) as $ifid) {
$int = dbFetchRow('SELECT `ifIndex`, `hostname` FROM `ports` AS I, devices as D WHERE I.port_id = ? AND I.device_id = D.device_id', array($ifid));
if (is_file($config['rrd_dir'].'/'.$int['hostname'].'/port-'.$int['ifIndex'].'.rrd')) {
$int = dbFetchRow('SELECT `hostname` FROM `ports` AS I, devices as D WHERE I.port_id = ? AND I.device_id = D.device_id', array($ifid));
$rrd_file = get_port_rrdfile_path ($int['hostname'], $ifid);
if (is_file($rrd_file)) {
if (strstr($inverse, 'c')) {
$in = 'OUT';
$out = 'IN';
@@ -77,8 +80,8 @@ foreach (explode(',', $_GET['idc']) as $ifid) {
$out = 'OUT';
}
$rrd_options .= ' DEF:inoctetsc'.$i.'='.$config['rrd_dir'].'/'.$int['hostname'].'/port-'.$int['ifIndex'].'.rrd:'.$in.'OCTETS:AVERAGE';
$rrd_options .= ' DEF:outoctetsc'.$i.'='.$config['rrd_dir'].'/'.$int['hostname'].'/port-'.$int['ifIndex'].'.rrd:'.$out.'OCTETS:AVERAGE';
$rrd_options .= ' DEF:inoctetsc'.$i.'='.$rrd_file.':'.$in.'OCTETS:AVERAGE';
$rrd_options .= ' DEF:outoctetsc'.$i.'='.$rrd_file.':'.$out.'OCTETS:AVERAGE';
$in_thingc .= $seperator.'inoctetsc'.$i.',UN,0,'.'inoctetsc'.$i.',IF';
$out_thingc .= $seperator.'outoctetsc'.$i.',UN,0,'.'outoctetsc'.$i.',IF';
$plusesc .= $plus;
@@ -1,6 +1,6 @@
<?php
$rrd_filename = $config['rrd_dir'].'/'.$device['hostname'].'/port-'.safename($port['ifIndex'].'-adsl.rrd');
$rrd_filename = get_port_rrdfile_path ($device['hostname'], $port['port_id'], 'adsl');
$rrd_list[0]['filename'] = $rrd_filename;
$rrd_list[0]['descr'] = 'Downstream';
@@ -1,6 +1,6 @@
<?php
$rrd_filename = $config['rrd_dir'].'/'.$device['hostname'].'/port-'.safename($port['ifIndex'].'-adsl.rrd');
$rrd_filename = get_port_rrdfile_path ($device['hostname'], $port['port_id'], 'adsl');
$rrd_list[0]['filename'] = $rrd_filename;
$rrd_list[0]['descr'] = 'Downstream';
+1 -1
View File
@@ -1,6 +1,6 @@
<?php
$rrd_filename = $config['rrd_dir'].'/'.$device['hostname'].'/port-'.safename($port['ifIndex'].'-adsl.rrd');
$rrd_filename = get_port_rrdfile_path ($device['hostname'], $port['port_id'], 'adsl');
$rrd_list[0]['filename'] = $rrd_filename;
$rrd_list[0]['descr'] = 'Downstream';
+1 -1
View File
@@ -1,6 +1,6 @@
<?php
$rrd_filename = $config['rrd_dir'].'/'.$device['hostname'].'/port-'.safename($port['ifIndex'].'-adsl.rrd');
$rrd_filename = get_port_rrdfile_path ($device['hostname'], $port['port_id'], 'adsl');
$rrd_list[0]['filename'] = $rrd_filename;
$rrd_list[0]['descr'] = 'Downstream';
+1 -1
View File
@@ -1,6 +1,6 @@
<?php
$rrd_filename = $config['rrd_dir'].'/'.$device['hostname'].'/port-'.safename($port['ifIndex'].'-adsl.rrd');
$rrd_filename = get_port_rrdfile_path ($device['hostname'], $port['port_id'], 'adsl');
$rrd_list[0]['filename'] = $rrd_filename;
$rrd_list[0]['descr'] = 'Downstream';
+1 -1
View File
@@ -13,5 +13,5 @@ if (is_numeric($vars['id']) && ($auth || port_permitted($vars['id']))) {
$auth = true;
$rrd_filename = $config['rrd_dir'].'/'.$device['hostname'].'/port-'.safename($port['ifIndex'].'.rrd');
$rrd_filename = get_port_rrdfile_path ($device['hostname'], $port['port_id']);
}
+1 -1
View File
@@ -18,7 +18,7 @@ $oids = array(
);
$i = 0;
$rrd_filename = $config['rrd_dir'].'/'.$device['hostname'].'/'.safename('port-'.$port['ifIndex'].'-dot3.rrd');
$rrd_filename = get_port_rrdfile_path ($device['hostname'], $port['port_id'], 'dot3');
if (is_file($rrd_filename)) {
foreach ($oids as $oid) {
+7 -5
View File
@@ -1,15 +1,17 @@
<?php
$rrd_file = get_port_rrdfile_path ($device['hostname'], $port['port_id']);
// FIXME uhh..
if (1) {
// $rrd_list[1]['filename'] = $config['rrd_dir'] . "/" . $device['hostname'] . "/port-" . safename($port['ifIndex'] . ".rrd");
// $rrd_list[1]['filename'] = $rrd_file;
// $rrd_list[1]['descr'] = $int['ifDescr'];
// $rrd_list[1]['ds_in'] = "INNUCASTPKTS";
// $rrd_list[1]['ds_out'] = "OUTNUCASTPKTS";
// $rrd_list[1]['descr'] = "NonUnicast";
// $rrd_list[1]['colour_area_in'] = "BB77BB";
// $rrd_list[1]['colour_area_out'] = "FFDD88";
$rrd_list[2]['filename'] = $config['rrd_dir'].'/'.$device['hostname'].'/port-'.safename($port['ifIndex'].'.rrd');
$rrd_list[2]['filename'] = $rrd_file;
$rrd_list[2]['descr'] = $int['ifDescr'];
$rrd_list[2]['ds_in'] = 'INBROADCASTPKTS';
$rrd_list[2]['ds_out'] = 'OUTBROADCASTPKTS';
@@ -17,7 +19,7 @@ if (1) {
$rrd_list[2]['colour_area_in'] = 'aa37BB';
$rrd_list[2]['colour_area_out'] = 'ee9D88';
$rrd_list[4]['filename'] = $config['rrd_dir'].'/'.$device['hostname'].'/port-'.safename($port['ifIndex'].'.rrd');
$rrd_list[4]['filename'] = $rrd_file;
$rrd_list[4]['descr'] = $int['ifDescr'];
$rrd_list[4]['ds_in'] = 'INMULTICASTPKTS';
$rrd_list[4]['ds_out'] = 'OUTMULTICASTPKTS';
@@ -36,8 +38,8 @@ if (1) {
include 'includes/graphs/generic_multi_seperated.inc.php';
}
else if (is_file($config['rrd_dir'].'/'.$device['hostname'].'/'.safename($port['ifIndex'].'.rrd'))) {
$rrd_filename = $config['rrd_dir'].'/'.$device['hostname'].'/'.safename($port['ifIndex'].'.rrd');
else if (is_file($rrd_file)) {
$rrd_filename = $rrd_file;
$ds_in = 'INNUCASTPKTS';
$ds_out = 'OUTNUCASTPKTS';
+3 -2
View File
@@ -3,8 +3,9 @@
// Generate a list of ports and then call the multi_bits grapher to generate from the list
$i = 0;
foreach (dbFetchRows('SELECT * FROM `ports` WHERE `device_id` = ? AND `pagpGroupIfIndex` = ?', array($port['device_id'], $port['ifIndex'])) as $int) {
if (is_file($config['rrd_dir'].'/'.$hostname.'/port-'.safename($int['ifIndex'].'.rrd'))) {
$rrd_list[$i]['filename'] = $config['rrd_dir'].'/'.$hostname.'/port-'.safename($int['ifIndex'].'.rrd');
$rrd_file = get_port_rrdfile_path ($hostname, int['port_id']);
if (is_file($rrd_file)) {
$rrd_list[$i]['filename'] = $rrd_file;
$rrd_list[$i]['descr'] = $int['ifDescr'];
$i++;
}
+2 -2
View File
@@ -338,10 +338,10 @@ echo '</td></tr>';
// If we're showing graphs, generate the graph and print the img tags
if ($graph_type == 'etherlike') {
$graph_file = $config['rrd_dir'].'/'.$device['hostname'].'/port-'.safename($port['ifIndex']).'-dot3.rrd';
$graph_file = get_port_rrdfile_path ($device['hostname'], $if_id, 'dot3');
}
else {
$graph_file = $config['rrd_dir'].'/'.$device['hostname'].'/port-'.safename($port['ifIndex']).'.rrd';
$graph_file = get_port_rrdfile_path ($device['hostname'], $if_id);
}
if ($graph_type && is_file($graph_file)) {
+1 -1
View File
@@ -1,6 +1,6 @@
<?php
if (file_exists($config['rrd_dir'].'/'.$device['hostname'].'/port-'.$port['ifIndex'].'-adsl.rrd')) {
if (file_exists(get_port_rrdfile_path ($device['hostname'], $port['port_id'], 'adsl'))) {
$iid = $id;
echo '<div class=graphhead>ADSL Line Speed</div>';
$graph_type = 'port_adsl_speed';
+2 -2
View File
@@ -1,6 +1,6 @@
<?php
if (file_exists($config['rrd_dir'].'/'.$device['hostname'].'/port-'.$port['ifIndex'].'.rrd')) {
if (file_exists(get_port_rrdfile_path ($device['hostname'], $port['port_id']))) {
$iid = $id;
echo '<div class="panel panel-default">
<div class="panel-heading">
@@ -41,7 +41,7 @@ if (file_exists($config['rrd_dir'].'/'.$device['hostname'].'/port-'.$port['ifInd
include 'includes/print-interface-graphs.inc.php';
echo '</div></div>';
if (is_file($config['rrd_dir'].'/'.$device['hostname'].'/port-'.$port['ifIndex'].'-dot3.rrd')) {
if (is_file(get_port_rrdfile_path ($device['hostname'], $port['port_id'], 'dot3'))) {
echo '<div class="panel panel-default">
<div class="panel-heading">
<h3 class="panel-title">Ethernet Errors</h3>
+1 -1
View File
@@ -94,7 +94,7 @@ if ($if_list) {
echo '<br />';
if (file_exists($config['rrd_dir'].'/'.$port['hostname'].'/port-'.$port['ifIndex'].'.rrd')) {
if (file_exists(get_port_rrdfile_path ($port['hostname'], $port['port_id']))) {
$graph_type = 'port_bits';
include 'includes/print-interface-graphs.inc.php';