Issues (2963)

includes/html/graphs/qfp/avgpktsize.inc.php (2 issues)

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
 * @link       https://www.librenms.org
10
 *
11
 * @copyright  2019 LibreNMS
12
 * @author     Pavle Obradovic <[email protected]>
13
 */
14
$colour_area_in = 'AA66AA';
15
$colour_line_in = '330033';
16
17
$colour_area_out = 'FFDD88';
18
$colour_line_out = 'FF6600';
19
20
$colour_area_in_max = 'cc88cc';
21
$colour_area_out_max = 'FFefaa';
22
23
$graph_max = 1;
24
25
require 'includes/html/graphs/common.inc.php';
26
27
$stacked = generate_stacked_graphs();
28
29
$length = '10';
30
31
if (! isset($out_text)) {
32
    $out_text = 'Out';
33
}
34
35
if (! isset($in_text)) {
36
    $in_text = 'In';
37
}
38
39
$unit_text = str_pad(truncate($unit_text, $length), $length);
0 ignored issues
show
$length of type string 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 ignore-type  annotation

39
$unit_text = str_pad(truncate($unit_text, $length), /** @scrutinizer ignore-type */ $length);
Loading history...
It seems like truncate($unit_text, $length) 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

39
$unit_text = str_pad(/** @scrutinizer ignore-type */ truncate($unit_text, $length), $length);
Loading history...
40
$in_text = str_pad(truncate($in_text, $length), $length);
41
$out_text = str_pad(truncate($out_text, $length), $length);
42
43
$rrd_options .= ' DEF:in_packets=' . $rrd_filename . ':InTotalPps:AVERAGE';
44
$rrd_options .= ' DEF:out_packets=' . $rrd_filename . ':OutTotalPps:AVERAGE';
45
$rrd_options .= ' DEF:in_bits=' . $rrd_filename . ':InTotalBps:AVERAGE';
46
$rrd_options .= ' DEF:out_bits=' . $rrd_filename . ':OutTotalBps:AVERAGE';
47
48
$rrd_options .= ' CDEF:in_throughput=in_bits,8,/';
49
$rrd_options .= ' CDEF:out_throughput=out_bits,8,/';
50
51
$rrd_options .= ' CDEF:in_avg=in_throughput,in_packets,/';
52
$rrd_options .= ' CDEF:out_avg_tmp=out_throughput,out_packets,/';
53
$rrd_options .= ' CDEF:out_avg=out_avg_tmp,-1,*';
54
55
$rrd_options .= ' AREA:in_avg#' . $colour_area_in . $stacked['transparency'] . ':';
56
$rrd_options .= " COMMENT:'Average packet size\\n'";
57
$rrd_options .= ' LINE1.25:in_avg#' . $colour_line_in . ":'" . $in_text . "'";
58
$rrd_options .= ' GPRINT:in_avg:AVERAGE:%6.2lf%sB';
59
$rrd_options .= ' COMMENT:\\n';
60
61
$rrd_options .= ' AREA:out_avg#' . $colour_area_out . $stacked['transparency'] . ':';
62
$rrd_options .= ' LINE1.25:out_avg#' . $colour_line_out . ":'" . $out_text . "'";
63
$rrd_options .= ' GPRINT:out_avg_tmp:AVERAGE:%6.2lf%sB';
64
$rrd_options .= ' COMMENT:\\n';
65
66
$rrd_options .= ' HRULE:0#999999';
67
68
unset($stacked);
69