Issues (2963)

polling/applications/opengridscheduler.inc.php (1 issue)

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 opengridscheduler
11
 * @link       https://www.librenms.org
12
 * @copyright  2017 LibreNMS
13
 * @author     SvennD <[email protected]>
14
*/
15
16
use LibreNMS\RRD\RrdDefinition;
17
18
$name = 'ogs';
19
$app_id = $app['app_id'];
20
$oid = '.1.3.6.1.4.1.8072.1.3.2.3.1.2.3.111.103.115';
21
22
echo ' ' . $name;
23
24
// get data through snmp
25
$ogs_data = snmp_get($device, $oid, '-Oqv');
26
27
// define the rrd
28
$rrd_name = ['app', $name, $app_id];
29
$rrd_def = RrdDefinition::make()
30
    ->addDataset('running_jobs', 'GAUGE', 0)
31
    ->addDataset('pending_jobs', 'GAUGE', 0)
32
    ->addDataset('suspend_jobs', 'GAUGE', 0)
33
    ->addDataset('zombie_jobs', 'GAUGE', 0);
34
35
// parse the data from the script
36
$data = explode("\n", $ogs_data);
0 ignored issues
show
It seems like $ogs_data can also be of type false; however, parameter $string of explode() 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

36
$data = explode("\n", /** @scrutinizer ignore-type */ $ogs_data);
Loading history...
37
$fields = [
38
    'running_jobs' => $data[0],
39
    'pending_jobs' => $data[1],
40
    'suspend_jobs' => $data[2],
41
    'zombie_jobs' => $data[3],
42
];
43
44
// push the data in an array and into the rrd
45
$tags = compact('name', 'app_id', 'rrd_name', 'rrd_def');
46
data_update($device, 'app', $tags, $fields);
47
update_application($app, $ogs_data, $fields);
48
49
// cleanup
50
unset($ogs_data, $rrd_name, $rrd_def, $data, $fields, $tags);
51