Issues (2963)

graphs/device/bigip_ltm_allvs_currconns.inc.php (3 issues)

1
<?php
2
/*
3
 * LibreNMS module to display F5 LTM Virtual Server Details
4
 *
5
 * Copyright (c) 2021 Martin Bergström <[email protected]>
6
 *
7
 * This program is free software: you can redistribute it and/or modify it
8
 * under the terms of the GNU General Public License as published by the
9
 * Free Software Foundation, either version 3 of the License, or (at your
10
 * option) any later version.  Please see LICENSE.txt at the top level of
11
 * the source code distribution for details.
12
 */
13
14
$component = new LibreNMS\Component();
15
$options = [];
16
$options['filter']['type'] = ['=', 'f5-ltm-vs'];
17
$components = $component->getComponents($device['device_id'], $options);
18
19
// We only care about our device id.
20
$components = $components[$device['device_id']];
21
22
include 'includes/html/graphs/common.inc.php';
23
$rrd_options .= ' -l 0 -E ';
24
$rrd_options .= " COMMENT:'VS Current Connections       Now      Avg      Max\\n'";
25
$colours = array_merge(\LibreNMS\Config::get('graph_colours.mixed'), \LibreNMS\Config::get('graph_colours.manycolours'));
0 ignored issues
show
It seems like LibreNMS\Config::get('graph_colours.mixed') can also be of type null; however, parameter $arrays of array_merge() does only seem to accept array, 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

25
$colours = array_merge(/** @scrutinizer ignore-type */ \LibreNMS\Config::get('graph_colours.mixed'), \LibreNMS\Config::get('graph_colours.manycolours'));
Loading history...
26
$colcount = 0;
27
$count = 0;
28
29
// add all LTM VS on this device.
30
foreach ($components as $compid => $comp) {
31
    $label = $comp['label'];
32
    $hash = $comp['hash'];
33
    $rrd_filename = Rrd::name($device['hostname'], [$comp['type'], $label, $hash, 'currconns']);
0 ignored issues
show
The method name() does not exist on App\Facades\Rrd. Since you implemented __callStatic, consider adding a @method annotation. ( Ignorable by Annotation )

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

33
    /** @scrutinizer ignore-call */ 
34
    $rrd_filename = Rrd::name($device['hostname'], [$comp['type'], $label, $hash, 'currconns']);
Loading history...
34
    if (Rrd::checkRrdExists($rrd_filename)) {
0 ignored issues
show
The method checkRrdExists() does not exist on App\Facades\Rrd. Since you implemented __callStatic, consider adding a @method annotation. ( Ignorable by Annotation )

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

34
    if (Rrd::/** @scrutinizer ignore-call */ checkRrdExists($rrd_filename)) {
Loading history...
35
        // Grab a colour from the array.
36
        if (isset($colours[$colcount])) {
37
            $colour = $colours[$colcount];
38
        } else {
39
            $colcount = 0;
40
            $colour = $colours[$colcount];
41
        }
42
43
        $rrd_options .= ' DEF:DS' . $count . '=' . $rrd_filename . ':currconns:AVERAGE ';
44
        $rrd_options .= ' LINE1.25:DS' . $count . '#' . $colour . ":'" . str_pad(substr($label, 0, 60), 60) . "'";
45
        $rrd_options .= ' GPRINT:DS' . $count . ':LAST:%6.2lf%s ';
46
        $rrd_options .= ' GPRINT:DS' . $count . ':AVERAGE:%6.2lf%s ';
47
        $rrd_options .= ' GPRINT:DS' . $count . ":MAX:%6.2lf%s\l ";
48
        $count++;
49
        $colcount++;
50
    }
51
}
52