Issues (2963)

graphs/generic_multi_simplex_seperated.inc.php (1 issue)

1
<?php
2
3
require 'includes/html/graphs/common.inc.php';
4
5
if (! isset($descr_len)) {
6
    $descr_len = 12;
7
}
8
9
if ($nototal) {
10
    $descr_len += '2';
11
    $unitlen += '2';
12
}
13
14
$rrd_options .= " COMMENT:'" . \LibreNMS\Data\Store\Rrd::fixedSafeDescr($unit_text, $descr_len) . "        Now       Min       Max     Avg\l'";
15
16
$unitlen = '10';
17
if ($nototal) {
18
    $descr_len += '2';
19
    $unitlen += '2';
20
}
21
22
$unit_text = str_pad(truncate($unit_text, $unitlen), $unitlen);
0 ignored issues
show
It seems like truncate($unit_text, $unitlen) can also be of type array; however, parameter $string of str_pad() does only seem to accept string, maybe add an additional type check? ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-type  annotation

22
$unit_text = str_pad(/** @scrutinizer ignore-type */ truncate($unit_text, $unitlen), $unitlen);
Loading history...
23
24
$colour_iter = 0;
25
foreach ($rrd_list as $i => $rrd) {
26
    if ($rrd['colour']) {
27
        $colour = $rrd['colour'];
28
    } else {
29
        if (! \LibreNMS\Config::get("graph_colours.$colours.$colour_iter")) {
30
            $colour_iter = 0;
31
        }
32
33
        $colour = \LibreNMS\Config::get("graph_colours.$colours.$colour_iter");
34
        $colour_iter++;
35
    }
36
37
    $descr = \LibreNMS\Data\Store\Rrd::fixedSafeDescr($rrd['descr'], $descr_len);
38
39
    $rrd_options .= ' DEF:' . $rrd['ds'] . $i . '=' . $rrd['filename'] . ':' . $rrd['ds'] . ':AVERAGE ';
40
41
    if ($simple_rrd) {
42
        $rrd_options .= ' CDEF:' . $rrd['ds'] . $i . 'min=' . $rrd['ds'] . $i . ' ';
43
        $rrd_options .= ' CDEF:' . $rrd['ds'] . $i . 'max=' . $rrd['ds'] . $i . ' ';
44
    } else {
45
        $rrd_options .= ' DEF:' . $rrd['ds'] . $i . 'min=' . $rrd['filename'] . ':' . $rrd['ds'] . ':MIN ';
46
        $rrd_options .= ' DEF:' . $rrd['ds'] . $i . 'max=' . $rrd['filename'] . ':' . $rrd['ds'] . ':MAX ';
47
    }
48
49
    if ($_GET['previous']) {
50
        $rrd_options .= ' DEF:' . $i . 'X=' . $rrd['filename'] . ':' . $rrd['ds'] . ':AVERAGE:start=' . $prev_from . ':end=' . $from;
51
        $rrd_options .= ' SHIFT:' . $i . "X:$period";
52
        $thingX .= $seperatorX . $i . 'X,UN,0,' . $i . 'X,IF';
53
        $plusesX .= $plusX;
54
        $seperatorX = ',';
55
        $plusX = ',+';
56
    }
57
58
    // Suppress totalling?
59
    if (! $nototal) {
60
        $rrd_options .= ' VDEF:tot' . $rrd['ds'] . $i . '=' . $rrd['ds'] . $i . ',TOTAL';
61
    }
62
63
    // This this not the first entry?
64
    if ($i) {
65
        $stack = ':STACK';
66
    }
67
68
    // if we've been passed a multiplier we must make a CDEF based on it!
69
    $g_defname = $rrd['ds'];
70
    if (is_numeric($multiplier)) {
71
        $g_defname = $rrd['ds'] . '_cdef';
72
        $rrd_options .= ' CDEF:' . $g_defname . $i . '=' . $rrd['ds'] . $i . ',' . $multiplier . ',*';
73
        $rrd_options .= ' CDEF:' . $g_defname . $i . 'min=' . $rrd['ds'] . $i . 'min,' . $multiplier . ',*';
74
        $rrd_options .= ' CDEF:' . $g_defname . $i . 'max=' . $rrd['ds'] . $i . 'max,' . $multiplier . ',*';
75
76
    // If we've been passed a divider (divisor!) we make a CDEF for it.
77
    } elseif (is_numeric($divider)) {
78
        $g_defname = $rrd['ds'] . '_cdef';
79
        $rrd_options .= ' CDEF:' . $g_defname . $i . '=' . $rrd['ds'] . $i . ',' . $divider . ',/';
80
        $rrd_options .= ' CDEF:' . $g_defname . $i . 'min=' . $rrd['ds'] . $i . 'min,' . $divider . ',/';
81
        $rrd_options .= ' CDEF:' . $g_defname . $i . 'max=' . $rrd['ds'] . $i . 'max,' . $divider . ',/';
82
    }
83
84
    // Are our text values related to te multiplier/divisor or not?
85
    if (isset($text_orig) && $text_orig) {
86
        $t_defname = $rrd['ds'];
87
    } else {
88
        $t_defname = $g_defname;
89
    }
90
91
    $rrd_options .= ' AREA:' . $g_defname . $i . '#' . $colour . ":'" . $descr . "'$stack";
92
93
    $rrd_options .= ' GPRINT:' . $t_defname . $i . ':LAST:%5.' . $float_precision . 'lf%s GPRINT:' . $t_defname . $i . 'min:MIN:%5.' . $float_precision . 'lf%s';
94
    $rrd_options .= ' GPRINT:' . $t_defname . $i . 'max:MAX:%5.' . $float_precision . 'lf%s GPRINT:' . $t_defname . $i . ":AVERAGE:'%5." . $float_precision . "lf%s\\n'";
95
96
    if (! $nototal) {
97
        $rrd_options .= ' GPRINT:tot' . $rrd['ds'] . $i . ':%6.' . $float_precision . "lf%s'" . \Rrd::safeDescr($total_units) . "'";
98
    }
99
100
    $rrd_options .= " COMMENT:'\\n'";
101
}//end foreach
102
103
if ($_GET['previous'] == 'yes') {
104
    if (is_numeric($multiplier)) {
105
        $rrd_options .= ' CDEF:X=' . $thingX . $plusesX . ',' . $multiplier . ',*';
106
    } elseif (is_numeric($divider)) {
107
        $rrd_options .= ' CDEF:X=' . $thingX . $plusesX . ',' . $divider . ',/';
108
    } else {
109
        $rrd_options .= ' CDEF:X=' . $thingX . $plusesX;
110
    }
111
112
    $rrd_options .= ' AREA:X#99999999:';
113
    $rrd_options .= ' LINE1.25:X#666666:';
114
}
115