Issues (2963)

includes/polling/os/snom.inc.php (1 issue)

1
<?php
2
3
use LibreNMS\RRD\RrdDefinition;
4
5
echo "Polling SNOM device...\n";
6
7
// Get SNOM specific version string from silly SNOM location. Silly SNOM!
8
$device['sysDescr'] = snmp_get($device, '1.3.6.1.2.1.7526.2.4', '-Oqv');
9
$device['sysDescr'] = str_replace('-', ' ', $device['sysDescr']);
10
$device['sysDescr'] = str_replace('"', '', $device['sysDescr']);
11
[$hardware, $features, $version] = explode(' ', $device['sysDescr']);
12
13
// Get data for calls and network from SNOM specific SNMP OIDs.
14
$snmpdata = snmp_get($device, ['1.3.6.1.2.1.7526.2.1.1', '1.3.6.1.2.1.7526.2.1.2', '1.3.6.1.2.1.7526.2.2.1', '1.3.6.1.2.1.7526.2.2.2'], '-Oqv');
15
$snmpdatab = snmp_get($device, ['1.3.6.1.2.1.7526.2.5', '1.3.6.1.2.1.7526.2.6'], '-Oqv');
16
17
[$rxbytes, $rxpkts, $txbytes, $txpkts] = explode("\n", $snmpdata);
0 ignored issues
show
It seems like $snmpdata 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

17
[$rxbytes, $rxpkts, $txbytes, $txpkts] = explode("\n", /** @scrutinizer ignore-type */ $snmpdata);
Loading history...
18
[$calls, $registrations] = explode("\n", $snmpdatab);
19
$txbytes = (0 - $txbytes * 8);
20
$rxbytes = (0 - $rxbytes * 8);
21
echo "$rxbytes, $rxpkts, $txbytes, $txpkts, $calls, $registrations";
22
23
$rrd_name = 'data';
24
$rrd_def = RrdDefinition::make()
25
    ->addDataset('INOCTETS', 'COUNTER', null, 100000000000)
26
    ->addDataset('OUTOCTETS', 'COUNTER', null, 10000000000)
27
    ->addDataset('INPKTS', 'COUNTER', null, 10000000000)
28
    ->addDataset('OUTPKTS', 'COUNTER', null, 10000000000)
29
    ->addDataset('CALLS', 'COUNTER', null, 10000000000)
30
    ->addDataset('REGISTRATIONS', 'COUNTER', null, 10000000000);
31
32
$fields = [
33
    'INOCTETS'      => $rxbytes,
34
    'OUTOCTETS'     => $txbytes,
35
    'INPKTS'        => $rxpkts,
36
    'OUTPKTS'       => $rxbytes,
37
    'CALLS'         => $calls,
38
    'REGISTRATIONS' => $registrations,
39
];
40
41
$tags = compact('rrd_name', 'rrd_def');
42
data_update($device, 'snom-data', $tags, $fields);
43