Skip to content

Commit 9487f4a

Browse files
authored
Misc graph fixes (librenms#18148)
1 parent a34c699 commit 9487f4a

File tree

4 files changed

+13
-12
lines changed

4 files changed

+13
-12
lines changed

LibreNMS/Billing.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -150,7 +150,7 @@ private static function get95thIn($bill_id, $datefrom, $dateto): float
150150
$q_95_sql = 'SELECT (in_delta / period * 8) AS rate FROM bill_data WHERE bill_id = ?';
151151
$q_95_sql .= ' AND timestamp > ? AND timestamp <= ? ORDER BY rate ASC';
152152
$a_95th = dbFetchColumn($q_95_sql, [$bill_id, $datefrom, $dateto]);
153-
$m_95th = $a_95th[$measurement_95th];
153+
$m_95th = $a_95th[$measurement_95th] ?? 0;
154154

155155
return round($m_95th, 2);
156156
}
@@ -165,7 +165,7 @@ private static function get95thout($bill_id, $datefrom, $dateto): float
165165
$q_95_sql = 'SELECT (out_delta / period * 8) AS rate FROM bill_data WHERE bill_id = ?';
166166
$q_95_sql .= ' AND timestamp > ? AND timestamp <= ? ORDER BY rate ASC';
167167
$a_95th = dbFetchColumn($q_95_sql, [$bill_id, $datefrom, $dateto]);
168-
$m_95th = $a_95th[$measurement_95th];
168+
$m_95th = $a_95th[$measurement_95th] ?? 0;
169169

170170
return round($m_95th, 2);
171171
}

includes/html/graphs/bill/bits.inc.php

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,12 +3,13 @@
33
use LibreNMS\Billing;
44
use LibreNMS\Util\Number;
55

6-
$datefrom = date('YmdHis', $vars['from']);
7-
$dateto = date('YmdHis', $vars['to']);
6+
$datefrom = date('YmdHis', $vars['from'] ?? null);
7+
$dateto = date('YmdHis', $vars['to'] ?? null);
8+
$bill_id = $vars['id'] ?? 0;
89

9-
$rates = Billing::getRates($vars['id'], $datefrom, $dateto, $vars['dir']);
10+
$rates = Billing::getRates($bill_id, $datefrom, $dateto, $vars['dir'] ?? null);
1011

11-
$ports = dbFetchRows('SELECT * FROM `bill_ports` AS B, `ports` AS P, `devices` AS D WHERE B.bill_id = ? AND P.port_id = B.port_id AND D.device_id = P.device_id', [$vars['id']]);
12+
$ports = dbFetchRows('SELECT * FROM `bill_ports` AS B, `ports` AS P, `devices` AS D WHERE B.bill_id = ? AND P.port_id = B.port_id AND D.device_id = P.device_id', [$bill_id]);
1213

1314
// Generate a list of ports and then call the multi_bits grapher to generate from the list
1415
$i = 0;

includes/html/graphs/generic_multi_bits_separated.inc.php

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -65,12 +65,8 @@
6565
$colour_out = \App\Facades\LibrenmsConfig::get("graph_colours.$colours_out.$iter");
6666

6767
if (! $nodetails) {
68-
if (isset($rrd['descr_in'])) {
69-
$descr = \LibreNMS\Data\Store\Rrd::fixedSafeDescr($rrd['descr_in'], $descr_len) . ' In';
70-
} else {
71-
$descr = \LibreNMS\Data\Store\Rrd::fixedSafeDescr($rrd['descr'], $descr_len) . ' In';
72-
}
73-
$descr_out = \LibreNMS\Data\Store\Rrd::fixedSafeDescr($rrd['descr_out'], $descr_len) . ' Out';
68+
$descr = \LibreNMS\Data\Store\Rrd::fixedSafeDescr($rrd['descr_in'] ?? $rrd['descr'] ?? '', $descr_len) . ' In';
69+
$descr_out = \LibreNMS\Data\Store\Rrd::fixedSafeDescr($rrd['descr_out'] ?? '', $descr_len) . ' Out';
7470
}
7571

7672
$rrd_options .= ' DEF:' . $in . $i . '=' . $rrd['filename'] . ':' . $ds_in . ':AVERAGE ';

includes/html/graphs/multiport/bits_separate.inc.php

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,10 @@
66

77
foreach (explode(',', $vars['id']) as $ifid) {
88
$port = dbFetchRow('SELECT * FROM `ports` AS I, devices as D WHERE I.port_id = ? AND I.device_id = D.device_id', [$ifid]);
9+
if (! $port) {
10+
continue;
11+
}
12+
913
$rrd_file = get_port_rrdfile_path($port['hostname'], $ifid);
1014
if (Rrd::checkRrdExists($rrd_file)) {
1115
$port = cleanPort($port);

0 commit comments

Comments
 (0)