1 | <?php |
||||
2 | /* |
||||
3 | * This program is free software: you can redistribute it and/or modify it |
||||
4 | * under the terms of the GNU General Public License as published by the |
||||
5 | * Free Software Foundation, either version 3 of the License, or (at your |
||||
6 | * option) any later version. Please see LICENSE.txt at the top level of |
||||
7 | * the source code distribution for details. |
||||
8 | * |
||||
9 | * @package LibreNMS |
||||
10 | * @subpackage graphs |
||||
11 | * @link https://www.librenms.org |
||||
12 | * @copyright 2017 LibreNMS |
||||
13 | * @author LibreNMS Contributors |
||||
14 | */ |
||||
15 | |||||
16 | require 'includes/html/graphs/common.inc.php'; |
||||
17 | |||||
18 | $stacked = generate_stacked_graphs(); |
||||
19 | |||||
20 | $i = 0; |
||||
21 | if ($width > '500') { |
||||
22 | $descr_len = 18; |
||||
23 | } else { |
||||
24 | $descr_len = 8; |
||||
25 | $descr_len += round(($width - 260) / 9.5); |
||||
26 | } |
||||
27 | |||||
28 | $unit_text = 'Bits/sec'; |
||||
29 | |||||
30 | if ($width > '500') { |
||||
31 | $rrd_options .= " COMMENT:'" . substr(str_pad($unit_text, ($descr_len + 5)), 0, ($descr_len + 5)) . " Current Average Maximum '"; |
||||
0 ignored issues
–
show
Bug
introduced
by
Loading history...
$descr_len + 5 of type double is incompatible with the type integer expected by parameter $length of str_pad() .
(
Ignorable by Annotation
)
If this is a false-positive, you can also ignore this issue in your code via the
Loading history...
|
|||||
32 | if (! $nototal) { |
||||
33 | $rrd_options .= " COMMENT:'Total '"; |
||||
34 | } |
||||
35 | |||||
36 | $rrd_options .= " COMMENT:'\l'"; |
||||
37 | } else { |
||||
38 | $rrd_options .= " COMMENT:'" . substr(str_pad($unit_text, ($descr_len + 5)), 0, ($descr_len + 5)) . " Now Ave Max\l'"; |
||||
39 | } |
||||
40 | |||||
41 | if (! isset($multiplier)) { |
||||
42 | $multiplier = '8'; |
||||
43 | } |
||||
44 | |||||
45 | foreach ($rrd_list as $rrd) { |
||||
46 | if (! \LibreNMS\Config::get("graph_colours.$colours_in.$iter") || ! \LibreNMS\Config::get("graph_colours.$colours_out.$iter")) { |
||||
47 | $iter = 0; |
||||
48 | } |
||||
49 | |||||
50 | $colour_in = \LibreNMS\Config::get("graph_colours.$colours_in.$iter"); |
||||
51 | $colour_out = \LibreNMS\Config::get("graph_colours.$colours_out.$iter"); |
||||
52 | |||||
53 | if (isset($rrd['descr_in'])) { |
||||
54 | $descr = \LibreNMS\Data\Store\Rrd::fixedSafeDescr($rrd['descr_in'], $descr_len) . ' In'; |
||||
55 | } else { |
||||
56 | $descr = \LibreNMS\Data\Store\Rrd::fixedSafeDescr($rrd['descr'], $descr_len) . ' In'; |
||||
57 | } |
||||
58 | |||||
59 | $descr_out = \LibreNMS\Data\Store\Rrd::fixedSafeDescr($rrd['descr_out'], $descr_len) . ' Out'; |
||||
60 | |||||
61 | $rrd_options .= ' DEF:' . $in . $i . '=' . $rrd['filename'] . ':' . $ds_in . ':AVERAGE '; |
||||
62 | $rrd_options .= ' DEF:' . $out . $i . '=' . $rrd['filename'] . ':' . $ds_out . ':AVERAGE '; |
||||
63 | $rrd_options .= ' CDEF:inB' . $i . '=in' . $i . ",$multiplier,* "; |
||||
64 | $rrd_options .= ' CDEF:outB' . $i . '=out' . $i . ",$multiplier,*"; |
||||
65 | $rrd_options .= ' CDEF:outB' . $i . '_neg=outB' . $i . ',' . $stacked['stacked'] . ',*'; |
||||
66 | $rrd_options .= ' CDEF:octets' . $i . '=inB' . $i . ',outB' . $i . ',+'; |
||||
67 | |||||
68 | if (! $args['nototal']) { |
||||
69 | $in_thing .= $seperator . $in . $i . ',UN,0,' . $in . $i . ',IF'; |
||||
70 | $out_thing .= $seperator . $out . $i . ',UN,0,' . $out . $i . ',IF'; |
||||
71 | $pluses .= $plus; |
||||
72 | $seperator = ','; |
||||
73 | $plus = ',+'; |
||||
74 | |||||
75 | $rrd_options .= ' VDEF:totin' . $i . '=inB' . $i . ',TOTAL'; |
||||
76 | $rrd_options .= ' VDEF:totout' . $i . '=outB' . $i . ',TOTAL'; |
||||
77 | $rrd_options .= ' VDEF:tot' . $i . '=octets' . $i . ',TOTAL'; |
||||
78 | } |
||||
79 | |||||
80 | if ($i) { |
||||
81 | $stack = ':STACK'; |
||||
82 | } |
||||
83 | |||||
84 | $rrd_options .= ' AREA:inB' . $i . '#' . $colour_in . $stacked['transparency'] . ":'" . $descr . "'$stack"; |
||||
85 | $rrd_options .= ' GPRINT:inB' . $i . ':LAST:%6.' . $float_precision . "lf%s$units"; |
||||
86 | $rrd_options .= ' GPRINT:inB' . $i . ':AVERAGE:%6.' . $float_precision . "lf%s$units"; |
||||
87 | $rrd_options .= ' GPRINT:inB' . $i . ':MAX:%6.' . $float_precision . "lf%s$units\l"; |
||||
88 | |||||
89 | if (! $nototal) { |
||||
90 | $rrd_options .= ' GPRINT:totin' . $i . ':%6.' . $float_precision . "lf%s$total_units"; |
||||
91 | } |
||||
92 | |||||
93 | $rrd_options .= " 'HRULE:0#" . $colour_out . ':' . $descr_out . "'"; |
||||
94 | $rrd_optionsb .= " 'AREA:outB" . $i . '_neg#' . $colour_out . $stacked['transparency'] . ":$stack'"; |
||||
95 | $rrd_options .= ' GPRINT:outB' . $i . ':LAST:%6.' . $float_precision . "lf%s$units"; |
||||
96 | $rrd_options .= ' GPRINT:outB' . $i . ':AVERAGE:%6.' . $float_precision . "lf%s$units"; |
||||
97 | $rrd_options .= ' GPRINT:outB' . $i . ':MAX:%6.' . $float_precision . "lf%s$units\l"; |
||||
98 | |||||
99 | if (! $nototal) { |
||||
100 | $rrd_options .= ' GPRINT:totout' . $i . ':%6.' . $float_precision . "lf%s$total_units"; |
||||
101 | } |
||||
102 | |||||
103 | $rrd_options .= " 'COMMENT:\l'"; |
||||
104 | $i++; |
||||
105 | $iter++; |
||||
106 | } |
||||
107 | |||||
108 | if ($custom_graph) { |
||||
109 | $rrd_options .= $custom_graph; |
||||
110 | } |
||||
111 | |||||
112 | if (! $nototal) { |
||||
113 | $rrd_options .= ' CDEF:' . $in . 'octets=' . $in_thing . $pluses; |
||||
114 | $rrd_options .= ' CDEF:' . $out . 'octets=' . $out_thing . $pluses; |
||||
115 | $rrd_options .= ' CDEF:octets=inoctets,outoctets,+'; |
||||
116 | $rrd_options .= ' CDEF:doutoctets=outoctets,' . $stacked['stacked'] . ',*'; |
||||
117 | $rrd_options .= ' CDEF:inbits=inoctets,8,*'; |
||||
118 | $rrd_options .= ' CDEF:outbits=outoctets,8,*'; |
||||
119 | $rrd_options .= ' CDEF:doutbits=doutoctets,8,*'; |
||||
120 | $rrd_options .= ' VDEF:percentile_in=inbits,' . \LibreNMS\Config::get('percentile_value') . ',PERCENT'; |
||||
121 | $rrd_options .= ' VDEF:percentile_out=outbits,' . \LibreNMS\Config::get('percentile_value') . ',PERCENT'; |
||||
122 | $rrd_options .= ' CDEF:dpercentile_outn=doutbits,' . $stacked['stacked'] . ',* VDEF:dpercentile_outnp=dpercentile_outn,' . \LibreNMS\Config::get('percentile_value') . ',PERCENT CDEF:dpercentile_outnpn=doutbits,doutbits,-,dpercentile_outnp,' . $stacked['stacked'] . ',*,+ VDEF:dpercentile_out=dpercentile_outnpn,FIRST'; |
||||
123 | $rrd_options .= ' VDEF:totin=inoctets,TOTAL'; |
||||
124 | $rrd_options .= ' VDEF:totout=outoctets,TOTAL'; |
||||
125 | $rrd_options .= ' VDEF:tot=octets,TOTAL'; |
||||
126 | } |
||||
127 | |||||
128 | $rrd_options .= $rrd_optionsb; |
||||
129 | $rrd_options .= ' HRULE:0#999999'; |
||||
130 | |||||
131 | unset($stacked); |
||||
132 |