diff --git a/includes/html/pages/bill.inc.php b/includes/html/pages/bill.inc.php index 5614a4853d..aacac20d0c 100644 --- a/includes/html/pages/bill.inc.php +++ b/includes/html/pages/bill.inc.php @@ -83,7 +83,7 @@ if (bill_permitted($bill_id)) { } echo ''; - }//end print_port_list ?> + }//end print_port_list?>

@@ -197,7 +197,7 @@ if (bill_permitted($bill_id)) { + }//end if?> diff --git a/includes/html/pages/plugin/admin.inc.php b/includes/html/pages/plugin/admin.inc.php index 01c5c09b3b..2d001021f0 100644 --- a/includes/html/pages/plugin/admin.inc.php +++ b/includes/html/pages/plugin/admin.inc.php @@ -30,7 +30,7 @@ $.ajax({ '; } - }//end if ?> + }//end if?>
diff --git a/includes/polling/applications.inc.php b/includes/polling/applications.inc.php index 095db09b4b..042f5fc86d 100644 --- a/includes/polling/applications.inc.php +++ b/includes/polling/applications.inc.php @@ -1,6 +1,6 @@ 0) { foreach ($app_rows as $app) { @@ -8,7 +8,7 @@ if (count($app_rows) > 0) { if (is_file($app_include)) { include $app_include; } else { - echo $app['app_type'].' include missing! '; + echo $app['app_type'] . ' include missing! '; } } echo "\n"; diff --git a/includes/polling/applications/apache.inc.php b/includes/polling/applications/apache.inc.php index aecb661a19..33dcee693b 100644 --- a/includes/polling/applications/apache.inc.php +++ b/includes/polling/applications/apache.inc.php @@ -5,22 +5,22 @@ use LibreNMS\RRD\RrdDefinition; $name = 'apache'; $app_id = $app['app_id']; -if (!empty($agent_data['app'][$name])) { +if (! empty($agent_data['app'][$name])) { $apache = $agent_data['app'][$name]; } else { $options = '-Oqv'; - $oid = '.1.3.6.1.4.1.8072.1.3.2.3.1.2.6.97.112.97.99.104.101'; - $apache = snmp_get($device, $oid, $options); + $oid = '.1.3.6.1.4.1.8072.1.3.2.3.1.2.6.97.112.97.99.104.101'; + $apache = snmp_get($device, $oid, $options); } echo ' apache'; -list ($total_access, $total_kbyte, $cpuload, $uptime, $reqpersec, $bytespersec, +[$total_access, $total_kbyte, $cpuload, $uptime, $reqpersec, $bytespersec, $bytesperreq, $busyworkers, $idleworkers, $score_wait, $score_start, $score_reading, $score_writing, $score_keepalive, $score_dns, - $score_closing, $score_logging, $score_graceful, $score_idle, $score_open) = explode("\n", $apache); + $score_closing, $score_logging, $score_graceful, $score_idle, $score_open] = explode("\n", $apache); -$rrd_name = array('app', $name, $app_id); +$rrd_name = ['app', $name, $app_id]; $rrd_def = RrdDefinition::make() ->addDataset('access', 'DERIVE', 0, 125000000000) ->addDataset('kbyte', 'DERIVE', 0, 125000000000) @@ -43,28 +43,28 @@ $rrd_def = RrdDefinition::make() ->addDataset('sb_idle', 'GAUGE', 0, 125000000000) ->addDataset('sb_open', 'GAUGE', 0, 125000000000); -$fields = array( - 'access' => intval(trim($total_access, '"')), - 'kbyte' => $total_kbyte, - 'cpu' => $cpuload, - 'uptime' => $uptime, - 'reqpersec' => $reqpersec, - 'bytespersec' => $bytespersec, - 'byesperreq' => $bytesperreq, - 'busyworkers' => $busyworkers, - 'idleworkers' => $idleworkers, - 'sb_wait' => $score_wait, - 'sb_start' => $score_start, - 'sb_reading' => $score_reading, - 'sb_writing' => $score_writing, - 'sb_keepalive' => $score_keepalive, - 'sb_dns' => $score_dns, - 'sb_closing' => $score_closing, - 'sb_logging' => $score_logging, - 'sb_graceful' => $score_graceful, - 'sb_idle' => $score_idle, - 'sb_open' => intval(trim($score_open, '"')), -); +$fields = [ + 'access' => intval(trim($total_access, '"')), + 'kbyte' => $total_kbyte, + 'cpu' => $cpuload, + 'uptime' => $uptime, + 'reqpersec' => $reqpersec, + 'bytespersec' => $bytespersec, + 'byesperreq' => $bytesperreq, + 'busyworkers' => $busyworkers, + 'idleworkers' => $idleworkers, + 'sb_wait' => $score_wait, + 'sb_start' => $score_start, + 'sb_reading' => $score_reading, + 'sb_writing' => $score_writing, + 'sb_keepalive' => $score_keepalive, + 'sb_dns' => $score_dns, + 'sb_closing' => $score_closing, + 'sb_logging' => $score_logging, + 'sb_graceful' => $score_graceful, + 'sb_idle' => $score_idle, + 'sb_open' => intval(trim($score_open, '"')), +]; $tags = compact('name', 'app_id', 'rrd_name', 'rrd_def'); data_update($device, 'app', $tags, $fields); diff --git a/includes/polling/applications/asterisk.inc.php b/includes/polling/applications/asterisk.inc.php index c6bf5d6120..7977e2cba6 100644 --- a/includes/polling/applications/asterisk.inc.php +++ b/includes/polling/applications/asterisk.inc.php @@ -7,27 +7,27 @@ $app_id = $app['app_id']; echo "$name, app_id=$app_id "; -if (!empty($agent_data[$name])) { +if (! empty($agent_data[$name])) { $rawdata = $agent_data[$name]; } else { $options = '-Oqv'; $oid = '.1.3.6.1.4.1.8072.1.3.2.4.1.2.8.97.115.116.101.114.105.115.107'; $rawdata = snmp_walk($device, $oid, $options); - $rawdata = str_replace("<<>>\n", '', $rawdata); + $rawdata = str_replace("<<>>\n", '', $rawdata); } -# Format Data +// Format Data $lines = explode("\n", $rawdata); -$asterisk = array(); -$asterisk_metrics = array(); +$asterisk = []; +$asterisk_metrics = []; foreach ($lines as $line) { - list($var,$value) = explode('=', $line); + [$var,$value] = explode('=', $line); $asterisk[$var] = $value; } unset($lines); -# Asterisk stats -$rrd_name = array('app', $name, 'stats', $app_id); +// Asterisk stats +$rrd_name = ['app', $name, 'stats', $app_id]; $rrd_def = RrdDefinition::make() ->addDataset('calls', 'GAUGE', 0, 10000) ->addDataset('channels', 'GAUGE', 0, 20000) @@ -37,15 +37,15 @@ $rrd_def = RrdDefinition::make() ->addDataset('sipunmononline', 'GAUGE', 0, 10000) ->addDataset('sipunmonoffline', 'GAUGE', 0, 10000); -$sip_fields = array( +$sip_fields = [ 'calls' => $asterisk['Calls'], 'channels' => $asterisk['Channels'], 'sippeers' => $asterisk['SipPeers'], 'sipmononline' => $asterisk['SipMonOnline'], 'sipmonoffline' => $asterisk['SipMonOffline'], 'sipunmononline' => $asterisk['SipUnMonOnline'], - 'sipunmonoffline' => $asterisk['SipUnMonOffline'] -); + 'sipunmonoffline' => $asterisk['SipUnMonOffline'], +]; $asterisk_metrics['stats'] = $sip_fields; $sip_tags = compact('name', 'app_id', 'rrd_name', 'rrd_def'); @@ -53,20 +53,20 @@ data_update($device, 'app', $sip_tags, $sip_fields); unset($rrd_name, $rrd_def, $sip_fields, $sip_tags); -# Additional iax2 stats -$rrd_name = array('app', $name, 'iax2', $app_id); +// Additional iax2 stats +$rrd_name = ['app', $name, 'iax2', $app_id]; $rrd_def = RrdDefinition::make() ->addDataset('iax2peers', 'GAUGE', 0, 10000) ->addDataset('iax2online', 'GAUGE', 0, 10000) ->addDataset('iax2offline', 'GAUGE', 0, 10000) ->addDataset('iax2unmonitored', 'GAUGE', 0, 10000); -$iax2_fields = array( +$iax2_fields = [ 'iax2peers' => $asterisk['Iax2Peers'], 'iax2online' => $asterisk['Iax2Online'], 'iax2offline' => $asterisk['Iax2Offline'], - 'iax2unmonitored' => $asterisk['Iax2Unmonitored'] -); + 'iax2unmonitored' => $asterisk['Iax2Unmonitored'], +]; $asterisk_metrics['iax2'] = $iax2_fields; $iax2_tags = compact('name', 'app_id', 'rrd_name', 'rrd_def'); diff --git a/includes/polling/applications/backupninja.inc.php b/includes/polling/applications/backupninja.inc.php index 8a92d8882c..2716674d56 100644 --- a/includes/polling/applications/backupninja.inc.php +++ b/includes/polling/applications/backupninja.inc.php @@ -12,33 +12,34 @@ try { } catch (JsonAppMissingKeysException $e) { $backupninja_data = $e->getParsedJson(); } catch (JsonAppException $e) { - echo PHP_EOL . $name . ':' .$e->getCode().':'. $e->getMessage() . PHP_EOL; - update_application($app, $e->getCode().':'.$e->getMessage(), []); // Set empty metrics and error message + echo PHP_EOL . $name . ':' . $e->getCode() . ':' . $e->getMessage() . PHP_EOL; + update_application($app, $e->getCode() . ':' . $e->getMessage(), []); // Set empty metrics and error message + return; } -$metrics = array(); +$metrics = []; $category = 'overview'; -$rrd_name = array('app', $name, $app_id, $category); +$rrd_name = ['app', $name, $app_id, $category]; $rrd_def = RrdDefinition::make() ->addDataset('last_actions', 'GAUGE', 0) ->addDataset('last_fatal', 'GAUGE', 0) ->addDataset('last_error', 'GAUGE', 0) ->addDataset('last_warning', 'GAUGE', 0); -$fields = array( +$fields = [ 'last_actions' => $backupninja_data['last_actions'], 'last_fatal' => $backupninja_data['last_fatal'], 'last_error' => $backupninja_data['last_error'], 'last_warning' => $backupninja_data['last_warning'], -); +]; $metrics[$category] = $fields; // Debug d_echo("backupninja : $fields"); -$tags = array('name' => $name, 'app_id' => $app_id, 'rrd_def' => $rrd_def, 'rrd_name' => $rrd_name); +$tags = ['name' => $name, 'app_id' => $app_id, 'rrd_def' => $rrd_def, 'rrd_name' => $rrd_name]; data_update($device, 'app', $tags, $fields); update_application($app, $output, $metrics); diff --git a/includes/polling/applications/bind.inc.php b/includes/polling/applications/bind.inc.php index 8ffc64d8bd..3876757db1 100644 --- a/includes/polling/applications/bind.inc.php +++ b/includes/polling/applications/bind.inc.php @@ -7,26 +7,26 @@ $app_id = $app['app_id']; echo " $name"; -if (!empty($agent_data['app'][$name])) { +if (! empty($agent_data['app'][$name])) { $bind = $agent_data['app'][$name]; } else { $options = '-Oqv'; - $mib = 'NET-SNMP-EXTEND-MIB'; - $oid = 'nsExtendOutputFull.4.98.105.110.100'; - $bind = snmp_get($device, $oid, $options, $mib); + $mib = 'NET-SNMP-EXTEND-MIB'; + $oid = 'nsExtendOutputFull.4.98.105.110.100'; + $bind = snmp_get($device, $oid, $options, $mib); } -list ($incoming, $outgoing, $server, $resolver, $cache, $rrsets, $adb, $sockets) = explode("\n", $bind); +[$incoming, $outgoing, $server, $resolver, $cache, $rrsets, $adb, $sockets] = explode("\n", $bind); // // INCOMING PROCESSING // -list ($a, $aaaa, $afsdb, $apl, $caa, $cdnskey, $cds, $cert, $cname, $dhcid, $dlv, $dnskey, $ds, $ipseckey, $key, $kx, +[$a, $aaaa, $afsdb, $apl, $caa, $cdnskey, $cds, $cert, $cname, $dhcid, $dlv, $dnskey, $ds, $ipseckey, $key, $kx, $loc, $mx, $naptr, $ns, $nsec, $nsec3, $nsec3param, $ptr, $rrsig, $rp, $sig, $soa, $srv, $sshfp, $ta, $tkey, $tlsa, - $tsig, $txt, $uri, $dname, $any, $axfr, $ixfr, $opt, $spf) = explode(',', $incoming); + $tsig, $txt, $uri, $dname, $any, $axfr, $ixfr, $opt, $spf] = explode(',', $incoming); -$metrics = array(); -$rrd_name = array('app', $name, $app_id); +$metrics = []; +$rrd_name = ['app', $name, $app_id]; $rrd_def = RrdDefinition::make() ->addDataset('any', 'DERIVE', 0) ->addDataset('a', 'DERIVE', 0) @@ -39,7 +39,7 @@ $rrd_def = RrdDefinition::make() ->addDataset('srv', 'DERIVE', 0) ->addDataset('spf', 'DERIVE', 0); -$fields = array( +$fields = [ 'any' => $any, 'a' => $a, 'aaaa' => $aaaa, @@ -50,13 +50,13 @@ $fields = array( 'soa' => $soa, 'srv' => $srv, 'spf' => $spf, -); +]; $metrics['queries'] = $fields; -$tags = array('name' => $name, 'app_id' => $app_id, 'rrd_def' => $rrd_def, 'rrd_name' => $rrd_name); +$tags = ['name' => $name, 'app_id' => $app_id, 'rrd_def' => $rrd_def, 'rrd_name' => $rrd_name]; data_update($device, 'app', $tags, $fields); -$rrd_name = array('app', $name, $app_id, 'incoming'); +$rrd_name = ['app', $name, $app_id, 'incoming']; $rrd_def = RrdDefinition::make() ->addDataset('afsdb', 'DERIVE', 0) ->addDataset('apl', 'DERIVE', 0) @@ -91,7 +91,7 @@ $rrd_def = RrdDefinition::make() ->addDataset('ixfr', 'DERIVE', 0) ->addDataset('opt', 'DERIVE', 0); -$fields = array( +$fields = [ 'afsdb' => $afsdb, 'apl' => $apl, 'caa' => $caa, @@ -124,20 +124,20 @@ $fields = array( 'axfr' => $axfr, 'ixfr' => $ixfr, 'opt' => $opt, -); +]; $metrics['incoming'] = $fields; -$tags = array('name' => $name, 'app_id' => $app_id, 'rrd_def' => $rrd_def, 'rrd_name' => $rrd_name); +$tags = ['name' => $name, 'app_id' => $app_id, 'rrd_def' => $rrd_def, 'rrd_name' => $rrd_name]; data_update($device, 'app', $tags, $fields); // // OUTGOING PROCESSING // -list ($a, $aaaa, $afsdb, $apl, $caa, $cdnskey, $cds, $cert, $cname, $dhcid, $dlv, $dnskey, $ds, $ipseckey, $key, $kx, +[$a, $aaaa, $afsdb, $apl, $caa, $cdnskey, $cds, $cert, $cname, $dhcid, $dlv, $dnskey, $ds, $ipseckey, $key, $kx, $loc, $mx, $naptr, $ns, $nsec, $nsec3, $nsec3param, $ptr, $rrsig, $rp, $sig, $soa, $srv, $sshfp, $ta, $tkey, $tlsa, - $tsig, $txt, $uri, $dname, $any, $axfr, $ixfr, $opt, $spf) = explode(',', $outgoing); + $tsig, $txt, $uri, $dname, $any, $axfr, $ixfr, $opt, $spf] = explode(',', $outgoing); -$rrd_name = array('app', $name, $app_id, 'outgoing'); +$rrd_name = ['app', $name, $app_id, 'outgoing']; $rrd_def = RrdDefinition::make() ->addDataset('any', 'DERIVE', 0) ->addDataset('a', 'DERIVE', 0) @@ -182,7 +182,7 @@ $rrd_def = RrdDefinition::make() ->addDataset('ixfr', 'DERIVE', 0) ->addDataset('opt', 'DERIVE', 0); -$fields = array( +$fields = [ 'any' => $any, 'a' => $a, 'aaaa' => $aaaa, @@ -225,19 +225,19 @@ $fields = array( 'axfr' => $axfr, 'ixfr' => $ixfr, 'opt' => $opt, -); +]; $metrics['outgoing'] = $fields; -$tags = array('name' => $name, 'app_id' => $app_id, 'rrd_def' => $rrd_def, 'rrd_name' => $rrd_name); +$tags = ['name' => $name, 'app_id' => $app_id, 'rrd_def' => $rrd_def, 'rrd_name' => $rrd_name]; data_update($device, 'app', $tags, $fields); // // SERVER PROCESSING // -list ($i4rr, $i6rr, $rwer, $trr, $aqr, $rqr, $rs, $trs, $rwes, $qrisa, $qriaa, $qrinaa, $qrin, $qris, $qrind, - $qcr, $dqr, $oqf, $uqr, $tqr, $oeor, $qd) = explode(',', $server); +[$i4rr, $i6rr, $rwer, $trr, $aqr, $rqr, $rs, $trs, $rwes, $qrisa, $qriaa, $qrinaa, $qrin, $qris, $qrind, + $qcr, $dqr, $oqf, $uqr, $tqr, $oeor, $qd] = explode(',', $server); -$rrd_name = array('app', $name, $app_id, 'server'); +$rrd_name = ['app', $name, $app_id, 'server']; $rrd_def = RrdDefinition::make() ->addDataset('i4rr', 'DERIVE', 0) ->addDataset('i6rr', 'DERIVE', 0) @@ -262,7 +262,7 @@ $rrd_def = RrdDefinition::make() ->addDataset('oeor', 'DERIVE', 0) ->addDataset('qd', 'DERIVE', 0); -$fields = array( +$fields = [ 'i4rr' => $i4rr, 'i6rr' => $i6rr, 'rwer' => $rwer, @@ -285,20 +285,20 @@ $fields = array( 'tqr' => $tqr, 'oeor' => $oeor, 'qd' => $qd, -); +]; $metrics['server'] = $fields; -$tags = array('name' => $name, 'app_id' => $app_id, 'rrd_def' => $rrd_def, 'rrd_name' => $rrd_name); +$tags = ['name' => $name, 'app_id' => $app_id, 'rrd_def' => $rrd_def, 'rrd_name' => $rrd_name]; data_update($device, 'app', $tags, $fields); // // RESOLVER PROCESSING // -list ($i4qs, $i6qs, $i4rr, $i6rr, $nr, $sr, $fr, $eqf, $trr, $ldr, $qr, $qt, $i4naf, $i6naf, +[$i4qs, $i6qs, $i4rr, $i6rr, $nr, $sr, $fr, $eqf, $trr, $ldr, $qr, $qt, $i4naf, $i6naf, $i4naff, $i6naff, $rttl10, $rtt10t100, $rtt100t500, $rtt500t800, $rtt800t1600, $rttg1600, - $bs, $rr) = explode(',', $resolver); + $bs, $rr] = explode(',', $resolver); -$rrd_name = array('app', $name, $app_id, 'resolver'); +$rrd_name = ['app', $name, $app_id, 'resolver']; $rrd_def = RrdDefinition::make() ->addDataset('i4qs', 'DERIVE', 0) ->addDataset('i6qs', 'DERIVE', 0) @@ -325,8 +325,7 @@ $rrd_def = RrdDefinition::make() ->addDataset('bs', 'GAUGE', 0) ->addDataset('rr', 'DERIVE', 0); - -$fields = array( +$fields = [ 'i4qs' => $i4qs, 'i6qs' => $i6qs, 'i4rr' => $i4rr, @@ -351,19 +350,19 @@ $fields = array( 'rttg1600' => $rttg1600, 'bs' => $bs, 'rr' => $rr, -); +]; $metrics['resolver'] = $fields; -$tags = array('name' => $name, 'app_id' => $app_id, 'rrd_def' => $rrd_def, 'rrd_name' => $rrd_name); +$tags = ['name' => $name, 'app_id' => $app_id, 'rrd_def' => $rrd_def, 'rrd_name' => $rrd_name]; data_update($device, 'app', $tags, $fields); // // CACHE PROCESSING // -list ($ch, $cm, $chfq, $cmfq, $crddtme, $crddtte, $cdn, $cdhb, $ctmt, $ctmiu, $cthmiu, - $chmt, $chmiu, $chhmiu) = explode(',', $cache); +[$ch, $cm, $chfq, $cmfq, $crddtme, $crddtte, $cdn, $cdhb, $ctmt, $ctmiu, $cthmiu, + $chmt, $chmiu, $chhmiu] = explode(',', $cache); -$rrd_name = array('app', $name, $app_id, 'cache'); +$rrd_name = ['app', $name, $app_id, 'cache']; $rrd_def = RrdDefinition::make() ->addDataset('ch', 'DERIVE', 0) ->addDataset('cm', 'DERIVE', 0) @@ -380,7 +379,7 @@ $rrd_def = RrdDefinition::make() ->addDataset('chmiu', 'GAUGE', 0) ->addDataset('chhmiu', 'GAUGE', 0); -$fields = array( +$fields = [ 'ch' => $ch, 'cm' => $cm, 'chfq' => $chfq, @@ -395,7 +394,7 @@ $fields = array( 'chmt' => $chmt, 'chmiu' => $chmiu, 'chhmiu' => $chhmiu, -); +]; $metrics['cache'] = $fields; $tags = compact('name', 'app_id', 'rrd_name', 'rrd_def'); @@ -404,34 +403,34 @@ data_update($device, 'app', $tags, $fields); // // ADB PROCESSING // -list ($ahts, $aiht, $nhts, $niht) = explode(',', $adb); +[$ahts, $aiht, $nhts, $niht] = explode(',', $adb); -$rrd_name = array('app', $name, $app_id, 'adb'); +$rrd_name = ['app', $name, $app_id, 'adb']; $rrd_def = RrdDefinition::make() ->addDataset('ahts', 'GAUGE', 0) ->addDataset('aiht', 'GAUGE', 0) ->addDataset('nhts', 'GAUGE', 0) ->addDataset('niht', 'GAUGE', 0); -$fields = array( +$fields = [ 'ahts' => $ahts, 'aiht' => $aiht, 'nhts' => $nhts, - 'niht' => $niht -); + 'niht' => $niht, +]; $metrics['adb'] = $fields; -$tags = array('name' => $name, 'app_id' => $app_id, 'rrd_def' => $rrd_def, 'rrd_name' => $rrd_name); +$tags = ['name' => $name, 'app_id' => $app_id, 'rrd_def' => $rrd_def, 'rrd_name' => $rrd_name]; data_update($device, 'app', $tags, $fields); // // SOCKETS PROCESSING // -list ($ui4so, $ui6so, $ti4so, $ti6so, $rso, $ui4sc, $ui6sc, $ti4sc, $ti6sc, $ui4sbf, $ti4sbf, $ui6sbf, $ti6sbf, +[$ui4so, $ui6so, $ti4so, $ti6so, $rso, $ui4sc, $ui6sc, $ti4sc, $ti6sc, $ui4sbf, $ti4sbf, $ui6sbf, $ti6sbf, $ui4scf, $ti4scf, $ui6scf, $ti6scf, $ui4ce, $ti4ce, $ui6ce, $ti6ce, $ti4ca, $ti6ca, $ui4se, $ti4se, $ui6se, - $ti6se, $ui4re, $ti4re, $ui6re, $ti6re, $ui4sa, $ui6sa, $ti4sa, $ti6sa, $rsa) = explode(',', $sockets); + $ti6se, $ui4re, $ti4re, $ui6re, $ti6re, $ui4sa, $ui6sa, $ti4sa, $ti6sa, $rsa] = explode(',', $sockets); -$rrd_name = array('app', $name, $app_id, 'sockets'); +$rrd_name = ['app', $name, $app_id, 'sockets']; $rrd_def = RrdDefinition::make() ->addDataset('ui4so', 'DERIVE', 0) ->addDataset('ui6so', 'DERIVE', 0) @@ -470,8 +469,7 @@ $rrd_def = RrdDefinition::make() ->addDataset('ti6sa', 'GAUGE', 0) ->addDataset('rsa', 'GAUGE', 0); - -$fields = array( +$fields = [ 'ui4so' => $ui4so, 'ui6so' => $ui6so, 'ti4so' => $ti4so, @@ -508,22 +506,22 @@ $fields = array( 'ti4sa' => $ti4sa, 'ti6sa' => $ti6sa, 'rsa' => $ti6sa, -); +]; $metrics['sockets'] = $fields; -$tags = array('name' => $name, 'app_id' => $app_id, 'rrd_def' => $rrd_def, 'rrd_name' => $rrd_name); +$tags = ['name' => $name, 'app_id' => $app_id, 'rrd_def' => $rrd_def, 'rrd_name' => $rrd_name]; data_update($device, 'app', $tags, $fields); // // RR SETS PROCESSING // -list ($a, $aaaa, $afsdb, $apl, $caa, $cdnskey, $cds, $cert, $cname, $dhcid, $dlv, $dnskey, $ds, $ipseckey, $key, $kx, +[$a, $aaaa, $afsdb, $apl, $caa, $cdnskey, $cds, $cert, $cname, $dhcid, $dlv, $dnskey, $ds, $ipseckey, $key, $kx, $loc, $mx, $naptr, $ns, $nsec, $nsec3, $nsec3param, $ptr, $rrsig, $rp, $sig, $soa, $srv, $sshfp, $ta, $tkey, $tlsa, $tsig, $txt, $uri, $dname, $nxdomain, $any, $axfr, $ixfr, $opt, $spf, $nota, $notaaaa, $notafsdb, $notapl, $notcaa, $notcdnskey, $notcds, $notcert, $notcname, $notdhcid, $notdlv, $notdnskey, $notds, $notipseckey, $notkey, $notkx, $notloc, $notmx, $notnaptr, $notns, $notnsec, $notnsec3, $notnsec3param, $notptr, $notrrsig, $notrp, $notsig, $notsoa, $notsrv, $notsshfp, $notta, $nottkey, $nottlsa, $nottsig, $nottxt, $noturi, $notdname, $notnxdomain, $notany, $notaxfr, $notixfr, $notopt, - $notspf) = explode(',', $rrsets); + $notspf] = explode(',', $rrsets); $rrd_def = RrdDefinition::make() ->addDataset('any', 'GAUGE', 0) @@ -571,9 +569,9 @@ $rrd_def = RrdDefinition::make() ->addDataset('opt', 'GAUGE', 0); //first handle the positive -$rrd_name = array('app', $name, $app_id, 'rrpositive'); +$rrd_name = ['app', $name, $app_id, 'rrpositive']; -$fields = array( +$fields = [ 'any' => $any, 'a' => $a, 'aaaa' => $aaaa, @@ -617,16 +615,16 @@ $fields = array( 'axfr' => $axfr, 'ixfr' => $ixfr, 'opt' => $opt, -); +]; $metrics['rrpositive'] = $fields; -$tags = array('name' => $name, 'app_id' => $app_id, 'rrd_def' => $rrd_def, 'rrd_name' => $rrd_name); +$tags = ['name' => $name, 'app_id' => $app_id, 'rrd_def' => $rrd_def, 'rrd_name' => $rrd_name]; data_update($device, 'app', $tags, $fields); // now handle the negative -$rrd_name = array('app', $name, $app_id, 'rrnegative'); +$rrd_name = ['app', $name, $app_id, 'rrnegative']; -$fields = array( +$fields = [ 'any' => $notany, 'a' => $nota, 'aaaa' => $notaaaa, @@ -670,9 +668,9 @@ $fields = array( 'axfr' => $notaxfr, 'ixfr' => $notixfr, 'opt' => $notopt, -); +]; $metrics['rrnegative'] = $fields; -$tags = array('name' => $name, 'app_id' => $app_id, 'rrd_def' => $rrd_def, 'rrd_name' => $rrd_name); +$tags = ['name' => $name, 'app_id' => $app_id, 'rrd_def' => $rrd_def, 'rrd_name' => $rrd_name]; data_update($device, 'app', $tags, $fields); update_application($app, $bind, $metrics); diff --git a/includes/polling/applications/ceph.inc.php b/includes/polling/applications/ceph.inc.php index 9d0c1d0cdf..0892fe15b4 100644 --- a/includes/polling/applications/ceph.inc.php +++ b/includes/polling/applications/ceph.inc.php @@ -3,16 +3,16 @@ use LibreNMS\RRD\RrdDefinition; $name = 'ceph'; -if (!empty($agent_data['app'][$name])) { +if (! empty($agent_data['app'][$name])) { $ceph_data = $agent_data['app'][$name]; $app_id = $app['app_id']; - $metrics = array(); + $metrics = []; foreach (explode('<', $ceph_data) as $section) { if (empty($section)) { continue; } - list($section, $data) = explode('>', $section); + [$section, $data] = explode('>', $section); if ($section == "poolstats") { $rrd_def = RrdDefinition::make() @@ -24,15 +24,15 @@ if (!empty($agent_data['app'][$name])) { if (empty($line)) { continue; } - list($pool,$ops,$wrbytes,$rbytes) = explode(':', $line); - $rrd_name = array('app', $name, $app_id, 'pool', $pool); + [$pool,$ops,$wrbytes,$rbytes] = explode(':', $line); + $rrd_name = ['app', $name, $app_id, 'pool', $pool]; - print "Ceph Pool: $pool, IOPS: $ops, Wr bytes: $wrbytes, R bytes: $rbytes\n"; - $fields = array( + echo "Ceph Pool: $pool, IOPS: $ops, Wr bytes: $wrbytes, R bytes: $rbytes\n"; + $fields = [ 'ops' => $ops, 'wrbytes' => $wrbytes, - 'rbytes' => $rbytes - ); + 'rbytes' => $rbytes, + ]; $metrics["pool_$pool"] = $fields; $tags = compact('name', 'app_id', 'pool', 'rrd_name', 'rrd_def'); data_update($device, 'app', $tags, $fields); @@ -46,14 +46,14 @@ if (!empty($agent_data['app'][$name])) { if (empty($line)) { continue; } - list($osd,$apply,$commit) = explode(':', $line); - $rrd_name = array('app', $name, $app_id, 'osd', $osd); + [$osd,$apply,$commit] = explode(':', $line); + $rrd_name = ['app', $name, $app_id, 'osd', $osd]; - print "Ceph OSD: $osd, Apply: $apply, Commit: $commit\n"; - $fields = array( + echo "Ceph OSD: $osd, Apply: $apply, Commit: $commit\n"; + $fields = [ 'apply_ms' => $apply, - 'commit_ms' => $commit - ); + 'commit_ms' => $commit, + ]; $metrics["osd_$osd"] = $fields; $tags = compact('name', 'app_id', 'osd', 'rrd_name', 'rrd_def'); data_update($device, 'app', $tags, $fields); @@ -68,15 +68,15 @@ if (!empty($agent_data['app'][$name])) { if (empty($line)) { continue; } - list($df,$avail,$used,$objects) = explode(':', $line); - $rrd_name = array('app', $name, $app_id, 'df', $df); + [$df,$avail,$used,$objects] = explode(':', $line); + $rrd_name = ['app', $name, $app_id, 'df', $df]; - print "Ceph Pool DF: $df, Avail: $avail, Used: $used, Objects: $objects\n"; - $fields = array( + echo "Ceph Pool DF: $df, Avail: $avail, Used: $used, Objects: $objects\n"; + $fields = [ 'avail' => $avail, 'used' => $used, - 'objects' => $objects - ); + 'objects' => $objects, + ]; $metrics["df_$df"] = $fields; $tags = compact('name', 'app_id', 'df', 'rrd_name', 'rrd_def'); data_update($device, 'app', $tags, $fields); diff --git a/includes/polling/applications/certificate.inc.php b/includes/polling/applications/certificate.inc.php index f121be1769..493e217816 100644 --- a/includes/polling/applications/certificate.inc.php +++ b/includes/polling/applications/certificate.inc.php @@ -1,6 +1,7 @@ getParsedJson(); } catch (JsonAppException $e) { - echo PHP_EOL . $name . ':' .$e->getCode().':'. $e->getMessage() . PHP_EOL; - update_application($app, $e->getCode().':'.$e->getMessage(), []); // Set empty metrics and error message + echo PHP_EOL . $name . ':' . $e->getCode() . ':' . $e->getMessage() . PHP_EOL; + update_application($app, $e->getCode() . ':' . $e->getMessage(), []); // Set empty metrics and error message + return; } -$rrd_name = array('app', $name, $app_id); +$rrd_name = ['app', $name, $app_id]; $rrd_def = RrdDefinition::make() ->addDataset('age', 'GAUGE', 0) ->addDataset('remaining_days', 'GAUGE', 0); -$metrics = array(); +$metrics = []; foreach ($certificate_data as $data) { $cert_name = $data['cert_name']; $age = $data['age']; $remaining_days = $data['remaining_days']; - $rrd_name = array('app', $name, $app_id, $cert_name); + $rrd_name = ['app', $name, $app_id, $cert_name]; - $fields = array( + $fields = [ 'age' => $age, - 'remaining_days' => $remaining_days - ); + 'remaining_days' => $remaining_days, + ]; $metrics[$cert_name] = $fields; - $tags = array('name' => $cert_name, 'app_id' => $app_id, 'rrd_def' => $rrd_def, 'rrd_name' => $rrd_name); + $tags = ['name' => $cert_name, 'app_id' => $app_id, 'rrd_def' => $rrd_def, 'rrd_name' => $rrd_name]; data_update($device, 'app', $tags, $fields); } diff --git a/includes/polling/applications/dhcp-stats.inc.php b/includes/polling/applications/dhcp-stats.inc.php index 16fd2749e5..6c02d93b43 100644 --- a/includes/polling/applications/dhcp-stats.inc.php +++ b/includes/polling/applications/dhcp-stats.inc.php @@ -1,15 +1,15 @@ addDataset('dhcp_total', 'GAUGE', 0) ->addDataset('dhcp_active', 'GAUGE', 0) @@ -65,7 +65,7 @@ $rrd_def = RrdDefinition::make() ->addDataset('dhcp_backup', 'GAUGE', 0) ->addDataset('dhcp_free', 'GAUGE', 0); -$fields = array( +$fields = [ 'dhcp_total' => $dhcp_total, 'dhcp_active' => $dhcp_active, 'dhcp_expired' => $dhcp_expired, @@ -75,10 +75,10 @@ $fields = array( 'dhcp_bootp' => $dhcp_bootp, 'dhcp_backup' => $dhcp_backup, 'dhcp_free' => $dhcp_free, -); +]; $metrics[$name . '_' . $category] = $fields; -$tags = array('name' => $name, 'app_id' => $app_id, 'rrd_def' => $rrd_def, 'rrd_name' => $rrd_name); +$tags = ['name' => $name, 'app_id' => $app_id, 'rrd_def' => $rrd_def, 'rrd_name' => $rrd_name]; data_update($device, 'app', $tags, $fields); if ($version == 2) { @@ -91,21 +91,21 @@ if ($version == 2) { ->addDataset('percent', 'GAUGE', 0); foreach ($pool_data as $data) { - $dhcp_pool_name = $data['first_ip'].'_-_'.$data['last_ip']; - $dhcp_current = $data['cur']; - $dhcp_max = $data['max']; - $dhcp_percent = $data['percent']; + $dhcp_pool_name = $data['first_ip'] . '_-_' . $data['last_ip']; + $dhcp_current = $data['cur']; + $dhcp_max = $data['max']; + $dhcp_percent = $data['percent']; - $rrd_name = array('app', $name, $app_id, $category, $dhcp_pool_name); + $rrd_name = ['app', $name, $app_id, $category, $dhcp_pool_name]; - $fields = array( + $fields = [ 'current' => $dhcp_current, 'max' => $dhcp_max, 'percent' => $dhcp_percent, - ); + ]; - $metrics[$dhcp_pool_name.'_'.$category] = $fields; - $tags = array('name' => $dhcp_pool_name, 'app_id' => $app_id, 'rrd_def' => $rrd_def, 'rrd_name' => $rrd_name); + $metrics[$dhcp_pool_name . '_' . $category] = $fields; + $tags = ['name' => $dhcp_pool_name, 'app_id' => $app_id, 'rrd_def' => $rrd_def, 'rrd_name' => $rrd_name]; data_update($device, 'app', $tags, $fields); } @@ -119,20 +119,20 @@ if ($version == 2) { foreach ($network_data as $data) { $dhcp_network_name = str_replace('/', '_', $data['network']); - $dhcp_current = $data['cur']; - $dhcp_max = $data['max']; - $dhcp_percent = $data['percent'] == 'nan' ? '0' : $data['percent']; + $dhcp_current = $data['cur']; + $dhcp_max = $data['max']; + $dhcp_percent = $data['percent'] == 'nan' ? '0' : $data['percent']; - $rrd_name = array('app', $name, $app_id, $category, $dhcp_network_name); + $rrd_name = ['app', $name, $app_id, $category, $dhcp_network_name]; - $fields = array( + $fields = [ 'current' => $dhcp_current, 'max' => $dhcp_max, 'percent' => $dhcp_percent, - ); + ]; - $metrics[$dhcp_network_name.'_'.$category] = $fields; - $tags = array('name' => $dhcp_network_name, 'app_id' => $app_id, 'rrd_def' => $rrd_def, 'rrd_name' => $rrd_name); + $metrics[$dhcp_network_name . '_' . $category] = $fields; + $tags = ['name' => $dhcp_network_name, 'app_id' => $app_id, 'rrd_def' => $rrd_def, 'rrd_name' => $rrd_name]; data_update($device, 'app', $tags, $fields); } } diff --git a/includes/polling/applications/drbd.inc.php b/includes/polling/applications/drbd.inc.php index 28824b9833..ab1a7dc2df 100644 --- a/includes/polling/applications/drbd.inc.php +++ b/includes/polling/applications/drbd.inc.php @@ -7,13 +7,13 @@ $app_instance = $app['app_instance']; $app_id = $app['app_id']; $drbd_data = $agent_data['app'][$name][$app_instance]; foreach (explode('|', $drbd_data) as $part) { - list($stat, $val) = explode('=', $part); - if (!empty($stat)) { + [$stat, $val] = explode('=', $part); + if (! empty($stat)) { $drbd[$stat] = $val; } } -$rrd_name = array('app', $name, $app_instance); +$rrd_name = ['app', $name, $app_instance]; $rrd_def = RrdDefinition::make() ->addDataset('ns', 'DERIVE', 0, 125000000000) ->addDataset('nr', 'DERIVE', 0, 125000000000) @@ -27,8 +27,7 @@ $rrd_def = RrdDefinition::make() ->addDataset('ap', 'GAUGE', 0, 125000000000) ->addDataset('oos', 'GAUGE', 0, 125000000000); - -$fields = array( +$fields = [ 'ns' => $drbd['ns'], 'nr' => $drbd['nr'], 'dw' => $drbd['dw'], @@ -40,9 +39,9 @@ $fields = array( 'ua' => $drbd['ua'], 'ap' => $drbd['ap'], 'oos' => $drbd['oos'], -); +]; -$tags = array('name', 'app_id', 'rrd_name', 'rrd_def'); +$tags = ['name', 'app_id', 'rrd_name', 'rrd_def']; data_update($device, 'app', $tags, $fields); update_application($app, $drbd_data, $fields); diff --git a/includes/polling/applications/entropy.inc.php b/includes/polling/applications/entropy.inc.php index dc223dd80d..35c4b0179f 100644 --- a/includes/polling/applications/entropy.inc.php +++ b/includes/polling/applications/entropy.inc.php @@ -1,4 +1,5 @@ addDataset('entropy', 'GAUGE', 0); $entropy_avail = snmp_get($device, $oid, $options, $mib); -$fields = array('entropy' => $entropy_avail,); +$fields = ['entropy' => $entropy_avail]; -$tags = array('name' => $name, 'app_id' => $app_id, 'rrd_def' => $rrd_def, 'rrd_name' => $rrd_name); +$tags = ['name' => $name, 'app_id' => $app_id, 'rrd_def' => $rrd_def, 'rrd_name' => $rrd_name]; data_update($device, 'app', $tags, $fields); update_application($app, $entropy_avail, $fields, $entropy_avail); diff --git a/includes/polling/applications/exim-stats.inc.php b/includes/polling/applications/exim-stats.inc.php index b421128c6d..a4af3b5efe 100644 --- a/includes/polling/applications/exim-stats.inc.php +++ b/includes/polling/applications/exim-stats.inc.php @@ -27,19 +27,19 @@ $app_id = $app['app_id']; $oid = '.1.3.6.1.4.1.8072.1.3.2.3.1.2.10.101.120.105.109.45.115.116.97.116.115'; $stats = snmp_get($device, $oid, '-Oqv'); -echo ' '.$name; +echo ' ' . $name; -list ($frozen, $queue) = explode("\n", $stats); +[$frozen, $queue] = explode("\n", $stats); -$rrd_name = array('app', $name, $app_id); +$rrd_name = ['app', $name, $app_id]; $rrd_def = RrdDefinition::make() ->addDataset('frozen', 'GAUGE', 0) ->addDataset('queue', 'GAUGE', 0); -$fields = array( +$fields = [ 'frozen' => intval(trim($frozen, '"')), - 'queue' => intval(trim($queue, '"')) -); + 'queue' => intval(trim($queue, '"')), +]; $tags = compact('name', 'app_id', 'rrd_name', 'rrd_def'); data_update($device, 'app', $tags, $fields); diff --git a/includes/polling/applications/fail2ban.inc.php b/includes/polling/applications/fail2ban.inc.php index 0707083a37..a84fa4c4e4 100644 --- a/includes/polling/applications/fail2ban.inc.php +++ b/includes/polling/applications/fail2ban.inc.php @@ -17,19 +17,20 @@ try { $f2b = [ 'data' => [ 'total' => array_shift($legacy), // total was first line in legacy app - 'jails' => [] - ] + 'jails' => [], + ], ]; foreach ($legacy as $jail_data) { - list($jail, $banned) = explode(" ", $jail_data); + [$jail, $banned] = explode(" ", $jail_data); if (isset($jail) && isset($banned)) { $f2b['data']['jails'][$jail] = $banned; } } } catch (JsonAppException $e) { - echo PHP_EOL . $name . ':' .$e->getCode().':'. $e->getMessage() . PHP_EOL; - update_application($app, $e->getCode().':'.$e->getMessage(), []); // Set empty metrics and error message + echo PHP_EOL . $name . ':' . $e->getCode() . ':' . $e->getMessage() . PHP_EOL; + update_application($app, $e->getCode() . ':' . $e->getMessage(), []); // Set empty metrics and error message + return; } @@ -37,26 +38,25 @@ $f2b = $f2b['data']; $metrics = []; -$rrd_name = array('app', $name, $app_id); +$rrd_name = ['app', $name, $app_id]; $rrd_def = RrdDefinition::make() ->addDataset('banned', 'GAUGE', 0) ->addDataset('firewalled', 'GAUGE', 0); - $fields = ['banned' => $f2b['total']]; $metrics['total'] = $fields; // don't include legacy ds in db $fields['firewalled'] = 'U'; // legacy ds -$tags = array('name' => $name, 'app_id' => $app_id, 'rrd_def' => $rrd_def, 'rrd_name' => $rrd_name); +$tags = ['name' => $name, 'app_id' => $app_id, 'rrd_def' => $rrd_def, 'rrd_name' => $rrd_name]; data_update($device, 'app', $tags, $fields); foreach ($f2b['jails'] as $jail => $banned) { - $rrd_name = array('app', $name, $app_id, $jail); + $rrd_name = ['app', $name, $app_id, $jail]; $rrd_def = RrdDefinition::make()->addDataset('banned', 'GAUGE', 0); - $fields = array('banned' => $banned); + $fields = ['banned' => $banned]; $metrics["jail_$jail"] = $fields; - $tags = array('name' => $name, 'app_id' => $app_id, 'rrd_def' => $rrd_def, 'rrd_name' => $rrd_name); + $tags = ['name' => $name, 'app_id' => $app_id, 'rrd_def' => $rrd_def, 'rrd_name' => $rrd_name]; data_update($device, 'app', $tags, $fields); } @@ -67,11 +67,11 @@ update_application($app, 'ok', $metrics); // $device_id = $device['device_id']; -$options=array( - 'filter' => array( - 'type' => array('=', 'fail2ban'), - ), -); +$options = [ + 'filter' => [ + 'type' => ['=', 'fail2ban'], + ], +]; $component = new LibreNMS\Component(); $f2b_components = $component->getComponents($device_id, $options); diff --git a/includes/polling/applications/fbsd-nfs-client.inc.php b/includes/polling/applications/fbsd-nfs-client.inc.php index be080553ba..9bdb8280bc 100644 --- a/includes/polling/applications/fbsd-nfs-client.inc.php +++ b/includes/polling/applications/fbsd-nfs-client.inc.php @@ -1,6 +1,7 @@ getOutput(); - $nfs=array( - 'data' => array(), - ); + $nfs = [ + 'data' => [], + ]; - list($nfs['data']['Getattr'], $nfs['data']['Setattr'], $nfs['data']['Lookup'], $nfs['data']['Readlink'], + [$nfs['data']['Getattr'], $nfs['data']['Setattr'], $nfs['data']['Lookup'], $nfs['data']['Readlink'], $nfs['data']['Read'], $nfs['data']['Write'], $nfs['data']['Create'], $nfs['data']['Remove'], $nfs['data']['Rename'], $nfs['data']['Link'], $nfs['data']['Symlink'], $nfs['data']['Mkdir'], $nfs['data']['Rmdir'], $nfs['data']['Readdir'], $nfs['data']['RdirPlus'], $nfs['data']['Access'], $nfs['data']['Mknod'], $nfs['data']['Fsstat'], $nfs['data']['Fsinfo'], @@ -27,14 +28,15 @@ try { $nfs['data']['LkupMisses'], $nfs['data']['BioRHits'], $nfs['data']['BioRMisses'], $nfs['data']['BioWHits'], $nfs['data']['BioWMisses'], $nfs['data']['BioRLHits'], $nfs['data']['BioRLMisses'], $nfs['data']['BioDHits'], $nfs['data']['BioDMisses'], $nfs['data']['DirEHits'], $nfs['data']['DirEMisses'], $nfs['data']['AccsHits'], - $nfs['data']['AccsMisses']) = explode("\n", $legacy); + $nfs['data']['AccsMisses']] = explode("\n", $legacy); } catch (JsonAppException $e) { - echo PHP_EOL . $name . ':' .$e->getCode().':'. $e->getMessage() . PHP_EOL; - update_application($app, $e->getCode().':'.$e->getMessage(), []); // Set empty metrics and error message + echo PHP_EOL . $name . ':' . $e->getCode() . ':' . $e->getMessage() . PHP_EOL; + update_application($app, $e->getCode() . ':' . $e->getMessage(), []); // Set empty metrics and error message + return; } -$rrd_name = array('app', $name, $app_id); +$rrd_name = ['app', $name, $app_id]; $rrd_def = RrdDefinition::make() ->addDataset('getattr', 'DERIVE', 0) ->addDataset('setattr', 'DERIVE', 0) @@ -79,7 +81,7 @@ $rrd_def = RrdDefinition::make() ->addDataset('accshits', 'DERIVE', 0) ->addDataset('accsmisses', 'DERIVE', 0); -$fields = array( +$fields = [ 'getattr' => $nfs['data']['Getattr'], 'setattr' => $nfs['data']['Setattr'], 'lookup' => $nfs['data']['Lookup'], @@ -122,8 +124,8 @@ $fields = array( 'diremisses' => $nfs['data']['DirEMisses'], 'accshits' => $nfs['data']['AccsHits'], 'accsmisses' => $nfs['data']['AccsMisses'], -); +]; -$tags = array('name' => $name, 'app_id' => $app_id, 'rrd_def' => $rrd_def, 'rrd_name' => $rrd_name); +$tags = ['name' => $name, 'app_id' => $app_id, 'rrd_def' => $rrd_def, 'rrd_name' => $rrd_name]; data_update($device, 'app', $tags, $fields); update_application($app, 'OK', $nfs['data']); diff --git a/includes/polling/applications/fbsd-nfs-server.inc.php b/includes/polling/applications/fbsd-nfs-server.inc.php index 7211702f32..ba96af96de 100644 --- a/includes/polling/applications/fbsd-nfs-server.inc.php +++ b/includes/polling/applications/fbsd-nfs-server.inc.php @@ -1,7 +1,7 @@ getOutput(); - $nfs=array( - 'data' => array(), - ); - list($nfs['data']['Getattr'], $nfs['data']['Setattr'], $nfs['data']['Lookup'], $nfs['data']['Readlink'], + $nfs = [ + 'data' => [], + ]; + [$nfs['data']['Getattr'], $nfs['data']['Setattr'], $nfs['data']['Lookup'], $nfs['data']['Readlink'], $nfs['data']['Read'], $nfs['data']['Write'], $nfs['data']['Create'], $nfs['data']['Remove'], $nfs['data']['Rename'], $nfs['data']['Link'], $nfs['data']['Symlink'], $nfs['data']['Mkdir'], $nfs['data']['Rmdir'], $nfs['data']['Readdir'], $nfs['data']['RdirPlus'], $nfs['data']['Access'], $nfs['data']['Mknod'], $nfs['data']['Fsstat'], $nfs['data']['Fsinfo'], $nfs['data']['PathConf'], $nfs['data']['Commit'], $nfs['data']['RetFailed'], $nfs['data']['Faults'], $nfs['data']['Inprog'], $nfs['data']['Idem'], $nfs['data']['Nonidem'], $nfs['data']['Misses'], $nfs['data']['WriteOps'], - $nfs['data']['WriteRPC'], $nfs['data']['Opsaved']) = explode("\n", $legacy); + $nfs['data']['WriteRPC'], $nfs['data']['Opsaved']] = explode("\n", $legacy); } catch (JsonAppException $e) { - echo PHP_EOL . $name . ':' .$e->getCode().':'. $e->getMessage() . PHP_EOL; - update_application($app, $e->getCode().':'.$e->getMessage(), []); // Set empty metrics and error message + echo PHP_EOL . $name . ':' . $e->getCode() . ':' . $e->getMessage() . PHP_EOL; + update_application($app, $e->getCode() . ':' . $e->getMessage(), []); // Set empty metrics and error message + return; } -$rrd_name = array('app', $name, $app_id); +$rrd_name = ['app', $name, $app_id]; $rrd_def = RrdDefinition::make() ->addDataset('getattr', 'DERIVE', 0) ->addDataset('setattr', 'DERIVE', 0) @@ -65,7 +66,7 @@ $rrd_def = RrdDefinition::make() ->addDataset('writerpc', 'DERIVE', 0) ->addDataset('opsaved', 'DERIVE', 0); -$fields = array( +$fields = [ 'getattr' => $nfs['data']['Getattr'], 'setattr' => $nfs['data']['Setattr'], 'lookup' => $nfs['data']['Lookup'], @@ -96,8 +97,8 @@ $fields = array( 'writeops' => $nfs['data']['WriteOps'], 'writerpc' => $nfs['data']['WriteRPC'], 'opsaved' => $nfs['data']['Opsaved'], -); +]; -$tags = array('name' => $name, 'app_id' => $app_id, 'rrd_def' => $rrd_def, 'rrd_name' => $rrd_name); +$tags = ['name' => $name, 'app_id' => $app_id, 'rrd_def' => $rrd_def, 'rrd_name' => $rrd_name]; data_update($device, 'app', $tags, $fields); update_application($app, 'OK', $nfs['data']); diff --git a/includes/polling/applications/freeradius.inc.php b/includes/polling/applications/freeradius.inc.php index 15975f8508..4479afaadc 100644 --- a/includes/polling/applications/freeradius.inc.php +++ b/includes/polling/applications/freeradius.inc.php @@ -7,42 +7,42 @@ $app_id = $app['app_id']; echo " $name"; -if (!empty($agent_data['app'][$name])) { +if (! empty($agent_data['app'][$name])) { $rawdata = $agent_data['app'][$name]; } else { $options = '-Oqv'; - $oid = '.1.3.6.1.4.1.8072.1.3.2.3.1.2.10.102.114.101.101.114.97.100.105.117.115'; - $rawdata = snmp_get($device, $oid, $options); + $oid = '.1.3.6.1.4.1.8072.1.3.2.3.1.2.10.102.114.101.101.114.97.100.105.117.115'; + $rawdata = snmp_get($device, $oid, $options); } -#Format Data +//Format Data $lines = explode("\n", $rawdata); -$freeradius = array(); -$metrics = array(); +$freeradius = []; +$metrics = []; foreach ($lines as $line) { - list($var,$value) = explode(' = ', $line); + [$var,$value] = explode(' = ', $line); $freeradius[$var] = $value; } -#FreeRADIUS-Total-Access -$rrd_name = array('app', $name,'access',$app_id); +//FreeRADIUS-Total-Access +$rrd_name = ['app', $name, 'access', $app_id]; $rrd_def = RrdDefinition::make() ->addDataset('requests', 'DERIVE', 0, 125000000000) ->addDataset('accepts', 'DERIVE', 0, 125000000000) ->addDataset('rejects', 'DERIVE', 0, 125000000000) ->addDataset('challenges', 'DERIVE', 0, 125000000000); -$fields = array ( +$fields = [ 'requests' => $freeradius['FreeRADIUS-Total-Access-Requests'], 'accepts' => $freeradius['FreeRADIUS-Total-Access-Accepts'], 'rejects' => $freeradius['FreeRADIUS-Total-Access-Rejects'], - 'challenges' => $freeradius['FreeRADIUS-Total-Access-Challenges'] - ); + 'challenges' => $freeradius['FreeRADIUS-Total-Access-Challenges'], +]; $metrics['access'] = $fields; $tags = compact('name', 'app_id', 'rrd_name', 'rrd_def'); data_update($device, 'app', $tags, $fields); -#FreeRADIUS-Total-Auth -$rrd_name = array('app', $name,'auth',$app_id); +//FreeRADIUS-Total-Auth +$rrd_name = ['app', $name, 'auth', $app_id]; $rrd_def = RrdDefinition::make() ->addDataset('responses', 'DERIVE', 0, 125000000000) ->addDataset('duplicate_requests', 'DERIVE', 0, 125000000000) @@ -50,20 +50,20 @@ $rrd_def = RrdDefinition::make() ->addDataset('invalid_requests', 'DERIVE', 0, 125000000000) ->addDataset('dropped_requests', 'DERIVE', 0, 125000000000) ->addDataset('unknown_types', 'DERIVE', 0, 125000000000); -$fields = array ( +$fields = [ 'responses' => $freeradius['FreeRADIUS-Total-Auth-Responses'], 'duplicate_requests' => $freeradius['FreeRADIUS-Total-Auth-Duplicate-Requests'], 'malformed_requests' => $freeradius['FreeRADIUS-Total-Auth-Malformed-Requests'], 'invalid_requests' => $freeradius['FreeRADIUS-Total-Auth-Invalid-Requests'], 'dropped_requests' => $freeradius['FreeRADIUS-Total-Auth-Dropped-Requests'], - 'unknown_types' => $freeradius['FreeRADIUS-Total-Auth-Unknown-Types'] - ); + 'unknown_types' => $freeradius['FreeRADIUS-Total-Auth-Unknown-Types'], +]; $metrics['auth'] = $fields; $tags = compact('name', 'app_id', 'rrd_name', 'rrd_def'); data_update($device, 'app', $tags, $fields); -#FreeRADIUS-Total-Acct -$rrd_name = array('app', $name,'acct',$app_id); +//FreeRADIUS-Total-Acct +$rrd_name = ['app', $name, 'acct', $app_id]; $rrd_def = RrdDefinition::make() ->addDataset('requests', 'DERIVE', 0, 125000000000) ->addDataset('responses', 'DERIVE', 0, 125000000000) @@ -72,38 +72,38 @@ $rrd_def = RrdDefinition::make() ->addDataset('invalid_requests', 'DERIVE', 0, 125000000000) ->addDataset('dropped_requests', 'DERIVE', 0, 125000000000) ->addDataset('unknown_types', 'DERIVE', 0, 125000000000); -$fields = array ( +$fields = [ 'requests' => $freeradius['FreeRADIUS-Total-Accounting-Requests'], 'responses' => $freeradius['FreeRADIUS-Total-Accounting-Responses'], 'duplicate_requests' => $freeradius['FreeRADIUS-Total-Acct-Duplicate-Requests'], 'malformed_requests' => $freeradius['FreeRADIUS-Total-Acct-Malformed-Requests'], 'invalid_requests' => $freeradius['FreeRADIUS-Total-Acct-Invalid-Requests'], 'dropped_requests' => $freeradius['FreeRADIUS-Total-Acct-Dropped-Requests'], - 'unknown_types' => $freeradius['FreeRADIUS-Total-Acct-Unknown-Types'] - ); + 'unknown_types' => $freeradius['FreeRADIUS-Total-Acct-Unknown-Types'], +]; $metrics['acct'] = $fields; $tags = compact('name', 'app_id', 'rrd_name', 'rrd_def'); data_update($device, 'app', $tags, $fields); -#FreeRADIUS-Total-Proxy-Access -$rrd_name = array('app', $name,'proxy_access',$app_id); +//FreeRADIUS-Total-Proxy-Access +$rrd_name = ['app', $name, 'proxy_access', $app_id]; $rrd_def = RrdDefinition::make() ->addDataset('requests', 'DERIVE', 0, 125000000000) ->addDataset('accepts', 'DERIVE', 0, 125000000000) ->addDataset('rejects', 'DERIVE', 0, 125000000000) ->addDataset('challenges', 'DERIVE', 0, 125000000000); -$fields = array ( +$fields = [ 'requests' => $freeradius['FreeRADIUS-Total-Proxy-Access-Requests'], 'accepts' => $freeradius['FreeRADIUS-Total-Proxy-Access-Accepts'], 'rejects' => $freeradius['FreeRADIUS-Total-Proxy-Access-Rejects'], - 'challenges' => $freeradius['FreeRADIUS-Total-Proxy-Access-Challenges'] - ); + 'challenges' => $freeradius['FreeRADIUS-Total-Proxy-Access-Challenges'], +]; $metrics['proxy_access'] = $fields; $tags = compact('name', 'app_id', 'rrd_name', 'rrd_def'); data_update($device, 'app', $tags, $fields); -#FreeRADIUS-Total-Proxy-Auth -$rrd_name = array('app', $name,'proxy_auth',$app_id); +//FreeRADIUS-Total-Proxy-Auth +$rrd_name = ['app', $name, 'proxy_auth', $app_id]; $rrd_def = RrdDefinition::make() ->addDataset('responses', 'DERIVE', 0, 125000000000) ->addDataset('duplicate_requests', 'DERIVE', 0, 125000000000) @@ -111,20 +111,20 @@ $rrd_def = RrdDefinition::make() ->addDataset('invalid_requests', 'DERIVE', 0, 125000000000) ->addDataset('dropped_requests', 'DERIVE', 0, 125000000000) ->addDataset('unknown_types', 'DERIVE', 0, 125000000000); -$fields = array ( +$fields = [ 'responses' => $freeradius['FreeRADIUS-Total-Proxy-Auth-Responses'], 'duplicate_requests' => $freeradius['FreeRADIUS-Total-Proxy-Auth-Duplicate-Requests'], 'malformed_requests' => $freeradius['FreeRADIUS-Total-Proxy-Auth-Malformed-Requests'], 'invalid_requests' => $freeradius['FreeRADIUS-Total-Proxy-Auth-Invalid-Requests'], 'dropped_requests' => $freeradius['FreeRADIUS-Total-Proxy-Auth-Dropped-Requests'], - 'unknown_types' => $freeradius['FreeRADIUS-Total-Proxy-Auth-Unknown-Types'] - ); + 'unknown_types' => $freeradius['FreeRADIUS-Total-Proxy-Auth-Unknown-Types'], +]; $metrics['proxy_auth'] = $fields; $tags = compact('name', 'app_id', 'rrd_name', 'rrd_def'); data_update($device, 'app', $tags, $fields); -#FreeRADIUS-Total-Proxy-Acct -$rrd_name = array('app', $name,'proxy_acct',$app_id); +//FreeRADIUS-Total-Proxy-Acct +$rrd_name = ['app', $name, 'proxy_acct', $app_id]; $rrd_def = RrdDefinition::make() ->addDataset('requests', 'DERIVE', 0, 125000000000) ->addDataset('responses', 'DERIVE', 0, 125000000000) @@ -133,21 +133,21 @@ $rrd_def = RrdDefinition::make() ->addDataset('invalid_requests', 'DERIVE', 0, 125000000000) ->addDataset('dropped_requests', 'DERIVE', 0, 125000000000) ->addDataset('unknown_types', 'DERIVE', 0, 125000000000); -$fields = array ( +$fields = [ 'requests' => $freeradius['FreeRADIUS-Total-Proxy-Accounting-Requests'], 'responses' => $freeradius['FreeRADIUS-Total-Proxy-Accounting-Responses'], 'duplicate_requests' => $freeradius['FreeRADIUS-Total-Proxy-Acct-Duplicate-Requests'], 'malformed_requests' => $freeradius['FreeRADIUS-Total-Proxy-Acct-Malformed-Requests'], 'invalid_requests' => $freeradius['FreeRADIUS-Total-Proxy-Acct-Invalid-Requests'], 'dropped_requests' => $freeradius['FreeRADIUS-Total-Proxy-Acct-Dropped-Requests'], - 'unknown_types' => $freeradius['FreeRADIUS-Total-Proxy-Acct-Unknown-Types'] - ); + 'unknown_types' => $freeradius['FreeRADIUS-Total-Proxy-Acct-Unknown-Types'], +]; $metrics['proxy_acct'] = $fields; $tags = compact('name', 'app_id', 'rrd_name', 'rrd_def'); data_update($device, 'app', $tags, $fields); -#FreeRADIUS-Queue -$rrd_name = array('app', $name,'queue',$app_id); +//FreeRADIUS-Queue +$rrd_name = ['app', $name, 'queue', $app_id]; $rrd_def = RrdDefinition::make() ->addDataset('len_internal', 'DERIVE', 0, 125000000000) ->addDataset('len_proxy', 'DERIVE', 0, 125000000000) @@ -156,15 +156,15 @@ $rrd_def = RrdDefinition::make() ->addDataset('len_detail', 'DERIVE', 0, 125000000000) ->addDataset('pps_in', 'DERIVE', 0, 125000000000) ->addDataset('pps_out', 'DERIVE', 0, 125000000000); -$fields = array ( +$fields = [ 'len_internal' => $freeradius['FreeRADIUS-Queue-Len-Internal'], 'len_proxy' => $freeradius['FreeRADIUS-Queue-Len-Proxy'], 'len_auth' => $freeradius['FreeRADIUS-Queue-Len-Auth'], 'len_acct' => $freeradius['FreeRADIUS-Queue-Len-Acct'], 'len_detail' => $freeradius['FreeRADIUS-Queue-Len-Detail'], 'pps_in' => $freeradius['FreeRADIUS-Queue-PPS-In'], - 'pps_out' => $freeradius['FreeRADIUS-Queue-PPS-Out'] - ); + 'pps_out' => $freeradius['FreeRADIUS-Queue-PPS-Out'], +]; $metrics['queue'] = $fields; $tags = compact('name', 'app_id', 'rrd_name', 'rrd_def'); data_update($device, 'app', $tags, $fields); diff --git a/includes/polling/applications/freeswitch.inc.php b/includes/polling/applications/freeswitch.inc.php index e06d49e60e..ee6e223d31 100644 --- a/includes/polling/applications/freeswitch.inc.php +++ b/includes/polling/applications/freeswitch.inc.php @@ -4,23 +4,23 @@ use LibreNMS\RRD\RrdDefinition; $name = 'freeswitch'; $app_id = $app['app_id']; -if (!empty($agent_data[$name])) { +if (! empty($agent_data[$name])) { $rawdata = $agent_data[$name]; } else { $options = '-Oqv'; $oid = '.1.3.6.1.4.1.8072.1.3.2.4.1.2.10.102.114.101.101.115.119.105.116.99.104'; $rawdata = snmp_walk($device, $oid, $options); - $rawdata = str_replace("<<>>\n", '', $rawdata); + $rawdata = str_replace("<<>>\n", '', $rawdata); } -# Format Data +// Format Data $lines = explode("\n", $rawdata); -$freeswitch = array(); +$freeswitch = []; foreach ($lines as $line) { - list($var,$value) = explode('=', $line); + [$var,$value] = explode('=', $line); $freeswitch[$var] = $value; } -# Freeswitch stats -$rrd_name = array('app', $name, 'stats', $app_id); +// Freeswitch stats +$rrd_name = ['app', $name, 'stats', $app_id]; $rrd_def = RrdDefinition::make() ->addDataset('calls', 'GAUGE', 0, 10000) ->addDataset('channels', 'GAUGE', 0, 10000) @@ -29,15 +29,15 @@ $rrd_def = RrdDefinition::make() ->addDataset('in_okay', 'COUNTER', 0, 4294967295) ->addDataset('out_failed', 'COUNTER', 0, 4294967295) ->addDataset('out_okay', 'COUNTER', 0, 4294967295); -$fields = array( +$fields = [ 'calls' => $freeswitch['Calls'], 'channels' => $freeswitch['Channels'], 'peak' => $freeswitch['Peak'], 'in_failed' => $freeswitch['InFailed'], 'in_okay' => $freeswitch['InTotal'] - $freeswitch['InFailed'], 'out_failed' => $freeswitch['OutFailed'], - 'out_okay' => $freeswitch['OutTotal'] - $freeswitch['OutFailed'] -); + 'out_okay' => $freeswitch['OutTotal'] - $freeswitch['OutFailed'], +]; $tags = compact('name', 'app_id', 'rrd_name', 'rrd_def'); data_update($device, 'app', $tags, $fields); update_application($app, $rawdata, $fields); diff --git a/includes/polling/applications/gpsd.inc.php b/includes/polling/applications/gpsd.inc.php index a626c19249..3f9be02098 100755 --- a/includes/polling/applications/gpsd.inc.php +++ b/includes/polling/applications/gpsd.inc.php @@ -52,8 +52,8 @@ } */ -use LibreNMS\Exceptions\JsonAppParsingFailedException; use LibreNMS\Exceptions\JsonAppException; +use LibreNMS\Exceptions\JsonAppParsingFailedException; use LibreNMS\RRD\RrdDefinition; $name = 'gpsd'; @@ -62,13 +62,13 @@ $app_id = $app['app_id']; echo " $name\n"; if ($app_id > 0) { - if (!empty($agent_data['app'][$name])) { + if (! empty($agent_data['app'][$name])) { $gpsd = $agent_data['app'][$name]; $gpsd_parsed = []; foreach (explode("\n", $gpsd) as $line) { - list ($field, $data) = explode(':', $line); + [$field, $data] = explode(':', $line); $gpsd_parsed[$field] = $data; } @@ -85,7 +85,7 @@ if ($app_id > 0) { $fields = []; foreach ($check_fields as $field) { - if (!empty($gpsd_parsed[$field])) { + if (! empty($gpsd_parsed[$field])) { $fields[$field] = $gpsd_parsed[$field]; } } @@ -100,14 +100,15 @@ if ($app_id > 0) { 'data' => [], ]; - list ($gpsd['data']['mode'], $gpsd['data']['hdop'], $gpsd['data']['vdop'], + [$gpsd['data']['mode'], $gpsd['data']['hdop'], $gpsd['data']['vdop'], $gpsd['data']['latitude'], $gpsd['data']['longitude'], $gpsd['data']['altitude'], - $gpsd['data']['satellites'], $gpsd['data']['satellites_used']) = explode("\n", $legacy); + $gpsd['data']['satellites'], $gpsd['data']['satellites_used']] = explode("\n", $legacy); } catch (JsonAppException $e) { // Set Empty metrics and error message echo PHP_EOL . $name . ':' . $e->getCode() . ':' . $e->getMessage() . PHP_EOL; update_application($app, $e->getCode() . ':' . $e->getMessage(), []); + return; } @@ -135,7 +136,7 @@ if ($app_id > 0) { $tags = compact('name', 'app_id', 'rrd_name', 'rrd_def'); data_update($device, 'app', $tags, $fields); - if (!empty($agent_data['app'][$name])) { + if (! empty($agent_data['app'][$name])) { update_application($app, $gpsd, $fields); } else { update_application($app, 'OK', $fields); diff --git a/includes/polling/applications/icecast.inc.php b/includes/polling/applications/icecast.inc.php index 8e05130a14..a43a70cddb 100644 --- a/includes/polling/applications/icecast.inc.php +++ b/includes/polling/applications/icecast.inc.php @@ -7,7 +7,7 @@ $app_id = $app['app_id']; echo "$name, app_id=$app_id "; -if (!empty($agent_data[$name])) { +if (! empty($agent_data[$name])) { $rawdata = $agent_data[$name]; } else { $options = '-Oqv'; @@ -15,31 +15,31 @@ if (!empty($agent_data[$name])) { $oid = '.1.3.6.1.4.1.8072.1.3.2.3.1.2.7.105.99.101.99.97.115.116'; $rawdata = snmp_get($device, $oid, $options, $mib); - $rawdata = str_replace("<<>>\n", '', $rawdata); + $rawdata = str_replace("<<>>\n", '', $rawdata); } $lines = explode("\n", $rawdata); -$icecast = array(); +$icecast = []; foreach ($lines as $line) { - list($var,$value) = explode('=', $line); + [$var,$value] = explode('=', $line); $icecast[$var] = $value; } unset($lines); -$rrd_name = array('app', $name, $app_id); +$rrd_name = ['app', $name, $app_id]; $rrd_def = RrdDefinition::make() ->addDataset('cpu', 'GAUGE', 0, 100) ->addDataset('kbyte', 'GAUGE', 0, 125000000000) ->addDataset('openfiles', 'GAUGE', 0, 125000000000); -$fields = array( - 'cpu' => (float)$icecast['CPU Load'], - 'kbyte' => (int)$icecast['Used Memory'], - 'openfiles' => (int)$icecast['Open files'] -); +$fields = [ + 'cpu' => (float) $icecast['CPU Load'], + 'kbyte' => (int) $icecast['Used Memory'], + 'openfiles' => (int) $icecast['Open files'], +]; $tags = compact('name', 'app_id', 'rrd_name', 'rrd_def'); diff --git a/includes/polling/applications/mailcow-postfix.inc.php b/includes/polling/applications/mailcow-postfix.inc.php index 094fa80b0c..4d0fca7eb5 100644 --- a/includes/polling/applications/mailcow-postfix.inc.php +++ b/includes/polling/applications/mailcow-postfix.inc.php @@ -32,10 +32,11 @@ try { } catch (JsonAppException $e) { echo PHP_EOL . $name . ':' . $e->getCode() . ':' . $e->getMessage() . PHP_EOL; update_application($app, $e->getCode() . ':' . $e->getMessage(), []); // Set empty metrics and error message + return; } -$rrd_name = array('app', $name, $app_id); +$rrd_name = ['app', $name, $app_id]; $rrd_def = RrdDefinition::make() ->addDataset('received', 'GAUGE', 0) @@ -54,8 +55,7 @@ $rrd_def = RrdDefinition::make() ->addDataset('recipients', 'GAUGE', 0) ->addDataset('recipienthostsdomains', 'GAUGE', 0); - -$fields = array( +$fields = [ 'received' => $mailcow_postfix['data']['received'], 'delivered' => $mailcow_postfix['data']['delivered'], 'forwarded' => $mailcow_postfix['data']['forwarded'], @@ -71,7 +71,7 @@ $fields = array( 'sendinghostsdomains' => $mailcow_postfix['data']['sendinghostsdomains'], 'recipients' => $mailcow_postfix['data']['recipients'], 'recipienthostsdomains' => $mailcow_postfix['data']['recipienthostsdomains'], -); +]; $tags = compact('name', 'app_id', 'rrd_name', 'rrd_def'); data_update($device, 'app', $tags, $fields); diff --git a/includes/polling/applications/mailscanner.inc.php b/includes/polling/applications/mailscanner.inc.php index 39e4399787..2bd6253629 100644 --- a/includes/polling/applications/mailscanner.inc.php +++ b/includes/polling/applications/mailscanner.inc.php @@ -4,18 +4,18 @@ use LibreNMS\RRD\RrdDefinition; -$options = '-Oqv'; -$oid = '.1.3.6.1.4.1.8072.1.3.2.3.1.2.11.109.97.105.108.115.99.97.110.110.101.114'; +$options = '-Oqv'; +$oid = '.1.3.6.1.4.1.8072.1.3.2.3.1.2.11.109.97.105.108.115.99.97.110.110.101.114'; $mailscanner = snmp_get($device, $oid, $options); echo ' mailscanner'; -list ($msg_recv, $msg_rejected, $msg_relay, $msg_sent, $msg_waiting, $spam, $virus) = explode("\n", $mailscanner); +[$msg_recv, $msg_rejected, $msg_relay, $msg_sent, $msg_waiting, $spam, $virus] = explode("\n", $mailscanner); $name = 'mailscannerV2'; $app_id = $app['app_id']; -$rrd_name = array('app', $name, $app_id); +$rrd_name = ['app', $name, $app_id]; $rrd_def = RrdDefinition::make() ->addDataset('msg_recv', 'COUNTER', 0, 125000000000) ->addDataset('msg_rejected', 'COUNTER', 0, 12500000000) @@ -25,7 +25,7 @@ $rrd_def = RrdDefinition::make() ->addDataset('spam', 'COUNTER', 0, 125000000000) ->addDataset('virus', 'COUNTER', 0, 125000000000); -$fields = array( +$fields = [ 'msg_recv' => $msg_recv, 'msg_rejected' => $msg_rejected, 'msg_relay' => $msg_relay, @@ -33,7 +33,7 @@ $fields = array( 'msg_waiting' => $msg_waiting, 'spam' => $spam, 'virus' => $virus, -); +]; $tags = compact('name', 'app_id', 'rrd_name', 'rrd_def'); data_update($device, 'app', $tags, $fields); diff --git a/includes/polling/applications/mdadm.inc.php b/includes/polling/applications/mdadm.inc.php index 9f43ee5291..330534b24b 100644 --- a/includes/polling/applications/mdadm.inc.php +++ b/includes/polling/applications/mdadm.inc.php @@ -1,6 +1,7 @@ getParsedJson(); } catch (JsonAppException $e) { - echo PHP_EOL . $name . ':' .$e->getCode().':'. $e->getMessage() . PHP_EOL; - update_application($app, $e->getCode().':'.$e->getMessage(), []); // Set empty metrics and error message + echo PHP_EOL . $name . ':' . $e->getCode() . ':' . $e->getMessage() . PHP_EOL; + update_application($app, $e->getCode() . ':' . $e->getMessage(), []); // Set empty metrics and error message + return; } -$rrd_name = array('app', $name, $app_id); +$rrd_name = ['app', $name, $app_id]; $rrd_def = RrdDefinition::make() ->addDataset('level', 'GAUGE', 0) ->addDataset('size', 'GAUGE', 0) @@ -27,7 +29,7 @@ $rrd_def = RrdDefinition::make() ->addDataset('sync_speed', 'GAUGE', 0) ->addDataset('sync_completed', 'GAUGE', 0); -$metrics = array(); +$metrics = []; foreach ($mdadm_data as $data) { $array_name = $data['name']; $level = $data['level']; @@ -40,22 +42,22 @@ foreach ($mdadm_data as $data) { $sync_speed = $data['sync_speed']; $sync_completed = $data['sync_completed']; - $rrd_name = array('app', $name, $app_id, $array_name); + $rrd_name = ['app', $name, $app_id, $array_name]; $array_level = str_replace('raid', '', $level); - $fields = array( + $fields = [ 'level' => $array_level, 'size' => $size, 'disc_count' => $disc_count, 'hotspare_count' => $hotspare_count, 'degraded' => $degraded, 'sync_speed' => $sync_speed, - 'sync_completed' => $sync_completed - ); + 'sync_completed' => $sync_completed, + ]; $metrics[$array_name] = $fields; - $tags = array('name' => $array_name, 'app_id' => $app_id, 'rrd_def' => $rrd_def, 'rrd_name' => $rrd_name); + $tags = ['name' => $array_name, 'app_id' => $app_id, 'rrd_def' => $rrd_def, 'rrd_name' => $rrd_name]; data_update($device, 'app', $tags, $fields); } update_application($app, $output, $metrics); diff --git a/includes/polling/applications/memcached.inc.php b/includes/polling/applications/memcached.inc.php index 6daee60093..e254a5419a 100644 --- a/includes/polling/applications/memcached.inc.php +++ b/includes/polling/applications/memcached.inc.php @@ -4,19 +4,19 @@ use LibreNMS\RRD\RrdDefinition; $name = 'memcached'; $app_id = $app['app_id']; -if (!empty($agent_data['app']['memcached'])) { +if (! empty($agent_data['app']['memcached'])) { $data = $agent_data['app']['memcached'][$app['app_instance']]; } else { - $oid = '.1.3.6.1.4.1.8072.1.3.2.3.1.2.9.109.101.109.99.97.99.104.101.100'; - $result = snmp_get($device, $oid, '-Oqv'); - $data = trim($result, '"'); - $data = unserialize(stripslashes(str_replace("<<>>\n", '', $data))); - $data = reset($data); + $oid = '.1.3.6.1.4.1.8072.1.3.2.3.1.2.9.109.101.109.99.97.99.104.101.100'; + $result = snmp_get($device, $oid, '-Oqv'); + $data = trim($result, '"'); + $data = unserialize(stripslashes(str_replace("<<>>\n", '', $data))); + $data = reset($data); } -echo ' memcached('.$app['app_instance'].')'; +echo ' memcached(' . $app['app_instance'] . ')'; -$rrd_name = array('app', $name, $app_id); +$rrd_name = ['app', $name, $app_id]; $rrd_def = RrdDefinition::make() ->addDataset('uptime', 'GAUGE', 0, 125000000000) ->addDataset('threads', 'GAUGE', 0, 125000000000) @@ -37,7 +37,7 @@ $rrd_def = RrdDefinition::make() ->addDataset('bytes_read', 'DERIVE', 0, 125000000000) ->addDataset('bytes_written', 'DERIVE', 0, 125000000000); -$fields = array( +$fields = [ 'uptime' => $data['uptime'], 'threads' => $data['threads'], 'rusage_user_ms' => $data['rusage_user_microseconds'], @@ -56,7 +56,7 @@ $fields = array( 'evictions' => $data['evictions'], 'bytes_read' => $data['bytes_read'], 'bytes_written' => $data['bytes_written'], -); +]; $tags = compact('name', 'app_id', 'rrd_name', 'rrd_def'); data_update($device, 'app', $tags, $fields); diff --git a/includes/polling/applications/mysql.inc.php b/includes/polling/applications/mysql.inc.php index 694a1a08cf..85174bee6a 100644 --- a/includes/polling/applications/mysql.inc.php +++ b/includes/polling/applications/mysql.inc.php @@ -5,7 +5,7 @@ use LibreNMS\RRD\RrdDefinition; $name = 'mysql'; $app_id = $app['app_id']; -if (!empty($agent_data['app'][$name])) { +if (! empty($agent_data['app'][$name])) { $mysql = $agent_data['app'][$name]; } else { // Polls MySQL statistics from script via SNMP @@ -13,10 +13,10 @@ if (!empty($agent_data['app'][$name])) { } echo ' mysql'; -$metrics = array(); +$metrics = []; // General Stats -$mapping = array( +$mapping = [ 'IDBLBSe' => 'cr', 'IBLFh' => 'ct', 'IBLWn' => 'cu', @@ -96,23 +96,23 @@ $mapping = array( 'CSt' => 'c5', 'CUe' => 'c3', 'CUMi' => 'c9', -); +]; $data = explode("\n", $mysql); -$map = array(); +$map = []; foreach ($data as $str) { - list($key, $value) = explode(':', $str); - $map[$key] = (float) trim($value); + [$key, $value] = explode(':', $str); + $map[$key] = (float) trim($value); } -$fields = array(); +$fields = []; foreach ($mapping as $k => $v) { $fields[$k] = (isset($map[$v]) && $map[$v] >= 0) ? $map[$v] : 'U'; } $metrics = $fields; -$rrd_name = array('app', $name, $app_id); +$rrd_name = ['app', $name, $app_id]; $rrd_def = RrdDefinition::make() ->addDataset('IDBLBSe', 'GAUGE', 0, 125000000000) ->addDataset('IBLFh', 'DERIVE', 0, 125000000000) @@ -198,7 +198,7 @@ $tags = compact('name', 'app_id', 'rrd_name', 'rrd_def'); data_update($device, 'app', $tags, $fields); // Process state statistics -$mapping_status = array( +$mapping_status = [ 'State_closing_tables' => 'd2', 'State_copying_to_tmp_table' => 'd3', 'State_end' => 'd4', @@ -215,14 +215,14 @@ $mapping_status = array( 'State_writing_to_net' => 'df', 'State_none' => 'dg', 'State_other' => 'dh', -); +]; -$rrd_name = array('app', $name, $app_id, 'status'); +$rrd_name = ['app', $name, $app_id, 'status']; $rrd_def = new RrdDefinition(); // because this sends different names for rrd and compared to other datastores, disable $fields name checks $rrd_def->disableNameChecking(); -$fields = array(); +$fields = []; foreach ($mapping_status as $desc => $id) { $fields[$desc] = (isset($map[$id]) && $map[$id] >= 0) ? $map[$id] : 'U'; $rrd_def->addDataset($id, 'GAUGE', 0, 125000000000); diff --git a/includes/polling/applications/nfs-server.inc.php b/includes/polling/applications/nfs-server.inc.php index d1b6c43f68..d5ceff9cfb 100644 --- a/includes/polling/applications/nfs-server.inc.php +++ b/includes/polling/applications/nfs-server.inc.php @@ -25,13 +25,12 @@ $nfsstats = snmp_get($device, $oid, '-Oqv'); $app_id = $app['app_id']; // rrd names -$rrd_name = array(); -$rrd_name['default'] = array('app', 'nfs-server-default', $app_id); -$rrd_name['proc2'] = array('app', 'nfs-server-proc2', $app_id); -$rrd_name['proc3'] = array('app', 'nfs-server-proc3', $app_id); -$rrd_name['proc4'] = array('app', 'nfs-server-proc4', $app_id); -$rrd_name['proc4ops'] = array('app', 'nfs-server-proc4ops', $app_id); - +$rrd_name = []; +$rrd_name['default'] = ['app', 'nfs-server-default', $app_id]; +$rrd_name['proc2'] = ['app', 'nfs-server-proc2', $app_id]; +$rrd_name['proc3'] = ['app', 'nfs-server-proc3', $app_id]; +$rrd_name['proc4'] = ['app', 'nfs-server-proc4', $app_id]; +$rrd_name['proc4ops'] = ['app', 'nfs-server-proc4ops', $app_id]; // rrd definitions $rrd_def_array['default'] = RrdDefinition::make() @@ -202,40 +201,39 @@ proc4 2 1 404 proc4ops 59 0 0 0 2 0 0 0 0 0 402 3 0 0 0 0 3 0 0 0 0 0 0 403 0 1 0 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 */ -$keys_nfs_server = array( - 'rc' => array('th_hits', 'th_misses', 'th_nocache'), - 'fh' => array('fh_lookup', 'fh_anon', 'fh_ncachedir', 'fh_ncachenondir', 'fh_stale'), - 'io' => array('io_read', 'io_write'), - 'th' => array('th_threads', 'th_fullcnt', 'th_range01', 'th_range02', 'th_range03', 'th_range04', 'th_range05', 'th_range06', 'th_range07', 'th_range08', 'th_range09', 'th_range10'), - 'ra' => array('ra_cachesize', 'ra_range01', 'ra_range02', 'ra_range03', 'ra_range04', 'ra_range05', 'ra_range06', 'ra_range07', 'ra_range08', 'ra_range09', 'ra_range10', 'ra_notfound'), - 'net' => array('net_cnt', 'net_udp', 'net_tcp', 'net_tcpconn'), - 'rpc' => array('rpc_calls', 'rpc_badcount', 'rpc_badfmt', 'rpc_badauth', 'rpc_badclnt'), - 'proc2' => array('proc2_null', 'proc2_getattr', 'proc2_setattr', 'proc2_root', 'proc2_lookup','proc2_readlink', 'proc2_read', 'proc2_wrcache', 'proc2_write', 'proc2_create','proc2_remove', 'proc2_rename', 'proc2_link', 'proc2_symlink', 'proc2_mkdir','proc2_rmdir', 'proc2_readdir', 'proc2_fsstat'), - 'proc3' => array('proc3_null', 'proc3_getattr', 'proc3_setattr', 'proc3_lookup', 'proc3_access','proc3_readlink', 'proc3_read', 'proc3_write', 'proc3_create', 'proc3_mkdir','proc3_symlink', 'proc3_mknod', 'proc3_remove', 'proc3_rmdir', 'proc3_rename','proc3_link', 'proc3_readdir', 'proc3_readdirplus', 'proc3_fsstat', 'proc3_fsinfo', 'proc3_pathconf', 'proc3_commit'), - 'proc4' => array('proc4_null', 'proc4_compound'), - 'proc4ops' => array( - 'v4_op0-unused','v4_op1-unused','v4_op2-future','v4_access','v4_close', - 'v4_commit','v4_create','v4_delegpurge','v4_delegreturn','v4_getattr','v4_getfh', - 'v4_link','v4_lock','v4_lockt','v4_locku','v4_lookup','v4_lookup_root','v4_nverify', - 'v4_open','v4_openattr','v4_open_conf','v4_open_dgrd','v4_putfh','v4_putpubfh','v4_putrootfh', - 'v4_read','v4_readdir','v4_readlink','v4_remove','v4_rename','v4_renew','v4_restorefh','v4_savefh', - 'v4_secinfo','v4_setattr','v4_setcltid','v4_setcltidconf','v4_verify','v4_write','v4_rellockowner', - 'v4_bc_ctl','v4_bind_conn','v4_exchange_id','v4_create_ses','v4_destroy_ses','v4_free_stateid', - 'v4_getdirdeleg','v4_getdevinfo','v4_getdevlist','v4_layoutcommit','v4_layoutget','v4_layoutreturn', - 'v4_secinfononam','v4_sequence','v4_set_ssv','v4_test_stateid','v4_want_deleg','v4_destroy_clid', - 'v4_reclaim_comp') - ); - +$keys_nfs_server = [ + 'rc' => ['th_hits', 'th_misses', 'th_nocache'], + 'fh' => ['fh_lookup', 'fh_anon', 'fh_ncachedir', 'fh_ncachenondir', 'fh_stale'], + 'io' => ['io_read', 'io_write'], + 'th' => ['th_threads', 'th_fullcnt', 'th_range01', 'th_range02', 'th_range03', 'th_range04', 'th_range05', 'th_range06', 'th_range07', 'th_range08', 'th_range09', 'th_range10'], + 'ra' => ['ra_cachesize', 'ra_range01', 'ra_range02', 'ra_range03', 'ra_range04', 'ra_range05', 'ra_range06', 'ra_range07', 'ra_range08', 'ra_range09', 'ra_range10', 'ra_notfound'], + 'net' => ['net_cnt', 'net_udp', 'net_tcp', 'net_tcpconn'], + 'rpc' => ['rpc_calls', 'rpc_badcount', 'rpc_badfmt', 'rpc_badauth', 'rpc_badclnt'], + 'proc2' => ['proc2_null', 'proc2_getattr', 'proc2_setattr', 'proc2_root', 'proc2_lookup', 'proc2_readlink', 'proc2_read', 'proc2_wrcache', 'proc2_write', 'proc2_create', 'proc2_remove', 'proc2_rename', 'proc2_link', 'proc2_symlink', 'proc2_mkdir', 'proc2_rmdir', 'proc2_readdir', 'proc2_fsstat'], + 'proc3' => ['proc3_null', 'proc3_getattr', 'proc3_setattr', 'proc3_lookup', 'proc3_access', 'proc3_readlink', 'proc3_read', 'proc3_write', 'proc3_create', 'proc3_mkdir', 'proc3_symlink', 'proc3_mknod', 'proc3_remove', 'proc3_rmdir', 'proc3_rename', 'proc3_link', 'proc3_readdir', 'proc3_readdirplus', 'proc3_fsstat', 'proc3_fsinfo', 'proc3_pathconf', 'proc3_commit'], + 'proc4' => ['proc4_null', 'proc4_compound'], + 'proc4ops' => [ + 'v4_op0-unused', 'v4_op1-unused', 'v4_op2-future', 'v4_access', 'v4_close', + 'v4_commit', 'v4_create', 'v4_delegpurge', 'v4_delegreturn', 'v4_getattr', 'v4_getfh', + 'v4_link', 'v4_lock', 'v4_lockt', 'v4_locku', 'v4_lookup', 'v4_lookup_root', 'v4_nverify', + 'v4_open', 'v4_openattr', 'v4_open_conf', 'v4_open_dgrd', 'v4_putfh', 'v4_putpubfh', 'v4_putrootfh', + 'v4_read', 'v4_readdir', 'v4_readlink', 'v4_remove', 'v4_rename', 'v4_renew', 'v4_restorefh', 'v4_savefh', + 'v4_secinfo', 'v4_setattr', 'v4_setcltid', 'v4_setcltidconf', 'v4_verify', 'v4_write', 'v4_rellockowner', + 'v4_bc_ctl', 'v4_bind_conn', 'v4_exchange_id', 'v4_create_ses', 'v4_destroy_ses', 'v4_free_stateid', + 'v4_getdirdeleg', 'v4_getdevinfo', 'v4_getdevlist', 'v4_layoutcommit', 'v4_layoutget', 'v4_layoutreturn', + 'v4_secinfononam', 'v4_sequence', 'v4_set_ssv', 'v4_test_stateid', 'v4_want_deleg', 'v4_destroy_clid', + 'v4_reclaim_comp', ], + ]; // parse each output line, by the id // then 'map' the values to the arrays from $keys_nfs_server -$lines = explode("\n", $nfsstats); -$default_fields = array(); -$metrics = array(); +$lines = explode("\n", $nfsstats); +$default_fields = []; +$metrics = []; foreach ($lines as $line) { - $line_values = explode(" ", $line); - $line_id = array_shift($line_values); + $line_values = explode(" ", $line); + $line_id = array_shift($line_values); switch ($line_id) { case 'rc': @@ -264,7 +262,7 @@ foreach ($lines as $line) { $fields = array_combine($keys_nfs_server[$line_id], $line_values); // create or push data to rrd - $tags = array('name' => $name, 'app_id' => $app['app_id'], 'rrd_name' => $rrd_name[$line_id], 'rrd_def' => $rrd_def_array[$line_id]); + $tags = ['name' => $name, 'app_id' => $app['app_id'], 'rrd_name' => $rrd_name[$line_id], 'rrd_def' => $rrd_def_array[$line_id]]; $metrics[$line_id] = $fields; data_update($device, 'app', $tags, $fields); } @@ -274,10 +272,9 @@ foreach ($lines as $line) { $metrics['none'] = $default_fields; // push the default nfs server data to rrd -$tags = array('name' => $name, 'app_id' => $app['app_id'], 'rrd_name' => $rrd_name['default'], 'rrd_def' => $rrd_def_array['default']); +$tags = ['name' => $name, 'app_id' => $app['app_id'], 'rrd_name' => $rrd_name['default'], 'rrd_def' => $rrd_def_array['default']]; data_update($device, 'app', $tags, $default_fields); update_application($app, $nfsstats, $metrics); - // clean up scope unset($nfsstats, $rrd_name, $rrd_def_array, $default_fields, $fields, $tags); diff --git a/includes/polling/applications/nfs-stats.inc.php b/includes/polling/applications/nfs-stats.inc.php index 1df0486f90..5453271f7a 100644 --- a/includes/polling/applications/nfs-stats.inc.php +++ b/includes/polling/applications/nfs-stats.inc.php @@ -10,7 +10,7 @@ echo ' ' . $name; $nfsstats = snmp_walk($device, $oid, '-Oqv', 'NET-SNMP-EXTEND-MIB'); -$rrd_name = array('app', $name, $app_id); +$rrd_name = ['app', $name, $app_id]; $rrd_def = RrdDefinition::make() ->addDataset('total', 'GAUGE', 0) ->addDataset('null', 'GAUGE', 0) @@ -29,7 +29,7 @@ $rrd_def = RrdDefinition::make() ->addDataset('fsstat', 'GAUGE', 0); $data = explode("\n", $nfsstats); -$fields = array( +$fields = [ 'total' => $data[0], 'null' => $data[1], 'getattr' => $data[2], @@ -45,7 +45,7 @@ $fields = array( 'rename' => $data[12], 'readdirplus' => $data[13], 'fsstat' => $data[14], -); +]; $tags = compact('name', 'app_id', 'rrd_name', 'rrd_def'); data_update($device, 'app', $tags, $fields); diff --git a/includes/polling/applications/nfs-v3-stats.inc.php b/includes/polling/applications/nfs-v3-stats.inc.php index 2ca9cbcd02..8dc1738b18 100644 --- a/includes/polling/applications/nfs-v3-stats.inc.php +++ b/includes/polling/applications/nfs-v3-stats.inc.php @@ -10,7 +10,7 @@ echo ' ' . $name; $nfsstats = snmp_walk($device, $oid, '-Oqv', 'NET-SNMP-EXTEND-MIB'); -$rrd_name = array('app', 'nfs-stats', $app_id); +$rrd_name = ['app', 'nfs-stats', $app_id]; $rrd_def = RrdDefinition::make() ->addDataset('rc_hits', 'GAUGE', 0) ->addDataset('rc_misses', 'GAUGE', 0) @@ -67,7 +67,7 @@ $rrd_def = RrdDefinition::make() ->addDataset('proc3_commit', 'GAUGE', 0); $data = explode("\n", $nfsstats); -$fields = array( +$fields = [ 'rc_hits' => $data[1], 'rc_misses' => $data[2], 'rc_nocache' => $data[3], @@ -121,7 +121,7 @@ $fields = array( 'proc3_fsinfo' => $data[50], 'proc3_pathconf' => $data[51], 'proc3_commit' => $data[52], -); +]; $tags = compact('name', 'app_id', 'rrd_name', 'rrd_def'); data_update($device, 'app', $tags, $fields); diff --git a/includes/polling/applications/nginx.inc.php b/includes/polling/applications/nginx.inc.php index 8910b9af87..bf7f1f32a9 100644 --- a/includes/polling/applications/nginx.inc.php +++ b/includes/polling/applications/nginx.inc.php @@ -4,7 +4,7 @@ use LibreNMS\RRD\RrdDefinition; $name = 'nginx'; $app_id = $app['app_id']; -if (!empty($agent_data['app'][$name])) { +if (! empty($agent_data['app'][$name])) { $nginx = $agent_data['app'][$name]; } else { // Polls nginx statistics from script via SNMP @@ -14,10 +14,10 @@ $nginx = trim($nginx, '"'); echo ' nginx'; -list($active, $reading, $writing, $waiting, $req) = array_map('rtrim', explode("\n", $nginx)); +[$active, $reading, $writing, $waiting, $req] = array_map('rtrim', explode("\n", $nginx)); d_echo("active: $active reading: $reading writing: $writing waiting: $waiting Requests: $req\n"); -$rrd_name = array('app', $name, $app_id); +$rrd_name = ['app', $name, $app_id]; $rrd_def = RrdDefinition::make() ->addDataset('Requests', 'DERIVE', 0, 125000000000) ->addDataset('Active', 'GAUGE', 0, 125000000000) @@ -25,13 +25,13 @@ $rrd_def = RrdDefinition::make() ->addDataset('Writing', 'GAUGE', 0, 125000000000) ->addDataset('Waiting', 'GAUGE', 0, 125000000000); -$fields = array( +$fields = [ 'Requests' => $req, 'Active' => $active, 'Reading' => $reading, 'Writing' => $writing, 'Waiting' => $waiting, -); +]; $tags = compact('name', 'app_id', 'rrd_name', 'rrd_def'); data_update($device, 'app', $tags, $fields); diff --git a/includes/polling/applications/ntp-client.inc.php b/includes/polling/applications/ntp-client.inc.php index bc69c29d4c..32983cd458 100644 --- a/includes/polling/applications/ntp-client.inc.php +++ b/includes/polling/applications/ntp-client.inc.php @@ -1,7 +1,7 @@ getOutput(); - $ntp=array( - data => array(), - ); - list ($ntp['data']['offset'], $ntp['data']['frequency'], $ntp['data']['sys_jitter'], - $ntp['data']['clk_jitter'], $ntp['data']['clk_wander']) = explode("\n", $legacy); + $ntp = [ + data => [], + ]; + [$ntp['data']['offset'], $ntp['data']['frequency'], $ntp['data']['sys_jitter'], + $ntp['data']['clk_jitter'], $ntp['data']['clk_wander']] = explode("\n", $legacy); } catch (JsonAppException $e) { - echo PHP_EOL . $name . ':' .$e->getCode().':'. $e->getMessage() . PHP_EOL; - update_application($app, $e->getCode().':'.$e->getMessage(), []); // Set empty metrics and error message + echo PHP_EOL . $name . ':' . $e->getCode() . ':' . $e->getMessage() . PHP_EOL; + update_application($app, $e->getCode() . ':' . $e->getMessage(), []); // Set empty metrics and error message + return; } -$rrd_name = array('app', $name, $app_id); +$rrd_name = ['app', $name, $app_id]; $rrd_def = RrdDefinition::make() ->addDataset('offset', 'GAUGE', -1000, 1000) ->addDataset('frequency', 'GAUGE', -1000, 1000) @@ -34,13 +35,13 @@ $rrd_def = RrdDefinition::make() ->addDataset('noise', 'GAUGE', -1000, 1000) ->addDataset('stability', 'GAUGE', -1000, 1000); -$fields = array( +$fields = [ 'offset' => $ntp['data']['offset'], 'frequency' => $ntp['data']['frequency'], 'jitter' => $ntp['data']['sys_jitter'], 'noise' => $ntp['data']['clk_jitter'], 'stability' => $ntp['data']['clk_wander'], -); +]; $tags = compact('name', 'app_id', 'rrd_name', 'rrd_def'); data_update($device, 'app', $tags, $fields); diff --git a/includes/polling/applications/ntp-server.inc.php b/includes/polling/applications/ntp-server.inc.php index 9719b35b0d..307d8f53d2 100644 --- a/includes/polling/applications/ntp-server.inc.php +++ b/includes/polling/applications/ntp-server.inc.php @@ -1,7 +1,7 @@ getOutput(); - $ntp=array( - data => array(), - ); + $ntp = [ + data => [], + ]; - list ($ntp['data']['stratum'], $ntp['data']['offset'], $ntp['data']['frequency'], $ntp['data']['jitter'], + [$ntp['data']['stratum'], $ntp['data']['offset'], $ntp['data']['frequency'], $ntp['data']['jitter'], $ntp['data']['noise'], $ntp['data']['stability'], $ntp['data']['uptime'], $ntp['data']['buffer_recv'], $ntp['data']['buffer_free'], $ntp['data']['buffer_used'], $ntp['data']['packets_drop'], - $ntp['data']['packets_ignore'], $ntp['data']['packets_recv'], $ntp['data']['packets_sent']) = explode("\n", $legacy); + $ntp['data']['packets_ignore'], $ntp['data']['packets_recv'], $ntp['data']['packets_sent']] = explode("\n", $legacy); } catch (JsonAppException $e) { - echo PHP_EOL . $name . ':' .$e->getCode().':'. $e->getMessage() . PHP_EOL; - update_application($app, $e->getCode().':'.$e->getMessage(), []); // Set empty metrics and error message + echo PHP_EOL . $name . ':' . $e->getCode() . ':' . $e->getMessage() . PHP_EOL; + update_application($app, $e->getCode() . ':' . $e->getMessage(), []); // Set empty metrics and error message + return; } - -$rrd_name = array('app', $name, $app_id); +$rrd_name = ['app', $name, $app_id]; $rrd_def = RrdDefinition::make() ->addDataset('stratum', 'GAUGE', 0, 1000) ->addDataset('offset', 'GAUGE', -1000, 1000) @@ -47,8 +47,7 @@ $rrd_def = RrdDefinition::make() ->addDataset('packets_recv', 'DERIVE', 0, 125000000000) ->addDataset('packets_sent', 'DERIVE', 0, 125000000000); - -$fields = array( +$fields = [ 'stratum' => $ntp['data']['stratum'], 'offset' => $ntp['data']['offset'], 'frequency' => $ntp['data']['frequency'], @@ -63,8 +62,7 @@ $fields = array( 'packets_ignore' => $ntp['data']['ignored_packets'], 'packets_recv' => $ntp['data']['received_packets'], 'packets_sent' => $ntp['data']['packets_sent'], -); - +]; $tags = compact('name', 'app_id', 'rrd_name', 'rrd_def'); data_update($device, 'app', $tags, $fields); diff --git a/includes/polling/applications/nvidia.inc.php b/includes/polling/applications/nvidia.inc.php index 5dec7f289a..87a019cbbc 100644 --- a/includes/polling/applications/nvidia.inc.php +++ b/includes/polling/applications/nvidia.inc.php @@ -5,8 +5,8 @@ use LibreNMS\RRD\RrdDefinition; $name = 'nvidia'; $app_id = $app['app_id']; -$options = '-Oqv'; -$oid = '.1.3.6.1.4.1.8072.1.3.2.3.1.2.6.110.118.105.100.105.97'; +$options = '-Oqv'; +$oid = '.1.3.6.1.4.1.8072.1.3.2.3.1.2.6.110.118.105.100.105.97'; $gpus = snmp_walk($device, $oid, $options); $gpuArray = explode("\n", $gpus); @@ -31,23 +31,23 @@ $rrd_def = RrdDefinition::make() ->addDataset('txpci', 'GAUGE', 0); $sm_total = 0; -$metrics = array(); +$metrics = []; foreach ($gpuArray as $index => $gpu) { $stats = explode(",", $gpu); if (count($stats) == 19) { - list($gpu, $pwr, $temp, $memtemp, $sm, $mem, $enc, $dec, $mclk, $pclk, $pviol, $tviol, - $fb, $bar1, $sbecc, $dbecc, $pci, $rxpci, $txpci)=$stats; + [$gpu, $pwr, $temp, $memtemp, $sm, $mem, $enc, $dec, $mclk, $pclk, $pviol, $tviol, + $fb, $bar1, $sbecc, $dbecc, $pci, $rxpci, $txpci] = $stats; } else { - list($gpu, $pwr, $temp, $sm, $mem, $enc, $dec, $mclk, $pclk, $pviol, $tviol, - $fb, $bar1, $sbecc, $dbecc, $pci, $rxpci, $txpci)=$stats; + [$gpu, $pwr, $temp, $sm, $mem, $enc, $dec, $mclk, $pclk, $pviol, $tviol, + $fb, $bar1, $sbecc, $dbecc, $pci, $rxpci, $txpci] = $stats; } $sm_total += $sm; - $rrd_name = array('app', $name, $app_id, $index); + $rrd_name = ['app', $name, $app_id, $index]; - $fields = array( + $fields = [ 'pwr' => $pwr, 'temp' => $temp, 'sm' => $sm, @@ -64,11 +64,11 @@ foreach ($gpuArray as $index => $gpu) { 'dbecc' => $dbecc, 'pci' => $pci, 'rxpci' => $rxpci, - 'txpci' => $txpci - ); + 'txpci' => $txpci, + ]; $metrics[$index] = $fields; - $tags = array('name' => $name, 'app_id' => $app_id, 'rrd_def' => $rrd_def, 'rrd_name' => $rrd_name); + $tags = ['name' => $name, 'app_id' => $app_id, 'rrd_def' => $rrd_def, 'rrd_name' => $rrd_name]; data_update($device, 'app', $tags, $fields); } $sm_average = ($sm_total ? ($sm_total / count($gpuArray)) : 0); diff --git a/includes/polling/applications/opengridscheduler.inc.php b/includes/polling/applications/opengridscheduler.inc.php index 38994dea95..a854179c32 100644 --- a/includes/polling/applications/opengridscheduler.inc.php +++ b/includes/polling/applications/opengridscheduler.inc.php @@ -25,7 +25,7 @@ echo ' ' . $name; $ogs_data = snmp_get($device, $oid, '-Oqv'); // define the rrd -$rrd_name = array('app', $name, $app_id); +$rrd_name = ['app', $name, $app_id]; $rrd_def = RrdDefinition::make() ->addDataset('running_jobs', 'GAUGE', 0) ->addDataset('pending_jobs', 'GAUGE', 0) @@ -34,18 +34,17 @@ $rrd_def = RrdDefinition::make() // parse the data from the script $data = explode("\n", $ogs_data); -$fields = array( +$fields = [ 'running_jobs' => $data[0], 'pending_jobs' => $data[1], 'suspend_jobs' => $data[2], 'zombie_jobs' => $data[3], -); +]; // push the data in an array and into the rrd $tags = compact('name', 'app_id', 'rrd_name', 'rrd_def'); data_update($device, 'app', $tags, $fields); update_application($app, $ogs_data, $fields); - // cleanup unset($ogs_data, $rrd_name, $rrd_def, $data, $fields, $tags); diff --git a/includes/polling/applications/opensips.inc.php b/includes/polling/applications/opensips.inc.php index ca87281bce..a0c46d908c 100644 --- a/includes/polling/applications/opensips.inc.php +++ b/includes/polling/applications/opensips.inc.php @@ -7,7 +7,7 @@ $app_id = $app['app_id']; echo "$name, app_id=$app_id "; -if (!empty($agent_data[$name])) { +if (! empty($agent_data[$name])) { $rawdata = $agent_data[$name]; } else { $options = '-Oqv'; @@ -17,22 +17,19 @@ if (!empty($agent_data[$name])) { $rawdata = snmp_get($device, $oid, $options, $mib); } - - -# Format Data +// Format Data $lines = explode("\n", $rawdata); -$opensips = array(); +$opensips = []; foreach ($lines as $line) { - list($var,$value) = explode('=', $line); + [$var,$value] = explode('=', $line); $opensips[$var] = $value; } - unset($lines); -$rrd_name = array('app', $name, $app_id); +$rrd_name = ['app', $name, $app_id]; $rrd_def = RrdDefinition::make() ->addDataset('load', 'GAUGE', 0, 100) @@ -41,13 +38,13 @@ $rrd_def = RrdDefinition::make() ->addDataset('free_memory', 'GAUGE', 0, 125000000000) ->addDataset('openfiles', 'GAUGE', 0, 125000000000); -$fields = array( - 'load' => (float)$opensips['Load Average'], - 'total_memory' => (int)$opensips['Total Memory'], - 'used_memory' => (int)$opensips['Used Memory'], - 'free_memory' => (int)$opensips['Free Memory'], - 'openfiles' => (int)$opensips['Open files'] -); +$fields = [ + 'load' => (float) $opensips['Load Average'], + 'total_memory' => (int) $opensips['Total Memory'], + 'used_memory' => (int) $opensips['Used Memory'], + 'free_memory' => (int) $opensips['Free Memory'], + 'openfiles' => (int) $opensips['Open files'], +]; $tags = compact('name', 'app_id', 'rrd_name', 'rrd_def'); diff --git a/includes/polling/applications/os-updates.inc.php b/includes/polling/applications/os-updates.inc.php index c61c903ba8..0f5c6d225f 100644 --- a/includes/polling/applications/os-updates.inc.php +++ b/includes/polling/applications/os-updates.inc.php @@ -1,4 +1,5 @@ addDataset('packages', 'GAUGE', 0); $osupdates = snmp_get($device, $oid, $options, $mib); -$fields = array('packages' => $osupdates,); +$fields = ['packages' => $osupdates]; -$tags = array('name' => $name, 'app_id' => $app_id, 'rrd_def' => $rrd_def, 'rrd_name' => $rrd_name); +$tags = ['name' => $name, 'app_id' => $app_id, 'rrd_def' => $rrd_def, 'rrd_name' => $rrd_name]; data_update($device, 'app', $tags, $fields); update_application($app, $osupdates, $fields, $osupdates); diff --git a/includes/polling/applications/php-fpm.inc.php b/includes/polling/applications/php-fpm.inc.php index 2506556831..918980810f 100644 --- a/includes/polling/applications/php-fpm.inc.php +++ b/includes/polling/applications/php-fpm.inc.php @@ -5,14 +5,14 @@ use LibreNMS\RRD\RrdDefinition; $name = 'php-fpm'; $app_id = $app['app_id']; -$options = '-Oqv'; -$oid = '.1.3.6.1.4.1.8072.1.3.2.3.1.2.8.112.104.112.102.112.109.115.112'; +$options = '-Oqv'; +$oid = '.1.3.6.1.4.1.8072.1.3.2.3.1.2.8.112.104.112.102.112.109.115.112'; $phpfpm = snmp_walk($device, $oid, $options); -list($pool,$start_time,$start_since,$accepted_conn,$listen_queue,$max_listen_queue,$listen_queue_len,$idle_processes, - $active_processes,$total_processes,$max_active_processes,$max_children_reached,$slow_requests) = explode("\n", $phpfpm); +[$pool,$start_time,$start_since,$accepted_conn,$listen_queue,$max_listen_queue,$listen_queue_len,$idle_processes, + $active_processes,$total_processes,$max_active_processes,$max_children_reached,$slow_requests] = explode("\n", $phpfpm); -$rrd_name = array('app', $name, $app_id); +$rrd_name = ['app', $name, $app_id]; $rrd_def = RrdDefinition::make() ->addDataset('lq', 'GAUGE', 0) ->addDataset('mlq', 'GAUGE', 0) @@ -23,7 +23,7 @@ $rrd_def = RrdDefinition::make() ->addDataset('mcr', 'GAUGE', 0) ->addDataset('sr', 'GAUGE', 0); -$fields = array( +$fields = [ 'lq' => $listen_queue, 'mlq' => $max_listen_queue, 'ip' => $idle_processes, @@ -31,9 +31,9 @@ $fields = array( 'tp' => $total_processes, 'map' => $max_active_processes, 'mcr' => $max_children_reached, - 'sr' => $slow_requests -); + 'sr' => $slow_requests, +]; -$tags = array('name' => $name, 'app_id' => $app_id, 'rrd_def' => $rrd_def, 'rrd_name' => $rrd_name); +$tags = ['name' => $name, 'app_id' => $app_id, 'rrd_def' => $rrd_def, 'rrd_name' => $rrd_name]; data_update($device, 'app', $tags, $fields); update_application($app, $phpfpm, $fields); diff --git a/includes/polling/applications/pi-hole.inc.php b/includes/polling/applications/pi-hole.inc.php index e4c32b67db..7ba3204af7 100644 --- a/includes/polling/applications/pi-hole.inc.php +++ b/includes/polling/applications/pi-hole.inc.php @@ -23,9 +23,9 @@ $oid = '.1.3.6.1.4.1.8072.1.3.2.4.1.2.7.112.105.45.104.111.108.101'; $pihole = snmp_walk($device, $oid, $options); if ($pihole) { - list($domains_blocked, $dns_query, $ads_blocked, $ads_percentage, $unique_domains, $queries_forwarded, $queries_cached, $query_a, $query_aaaa, $query_ptr, $query_srv) = explode("\n", $pihole); + [$domains_blocked, $dns_query, $ads_blocked, $ads_percentage, $unique_domains, $queries_forwarded, $queries_cached, $query_a, $query_aaaa, $query_ptr, $query_srv] = explode("\n", $pihole); - $rrd_name = array('app', $name, $app_id); + $rrd_name = ['app', $name, $app_id]; $rrd_def = RrdDefinition::make() ->addDataset('domains_blocked', 'GAUGE', 0) ->addDataset('dns_query', 'GAUGE', 0) @@ -39,7 +39,7 @@ if ($pihole) { ->addDataset('query_ptr', 'GAUGE', 0) ->addDataset('query_srv', 'GAUGE', 0); - $fields = array( + $fields = [ 'domains_blocked' => $domains_blocked, 'dns_query' => $dns_query, 'ads_blocked' => $ads_blocked, @@ -51,9 +51,9 @@ if ($pihole) { 'query_aaaa' => $query_aaaa, 'query_ptr' => $query_ptr, 'query_srv' => $query_srv, - ); + ]; - $tags = array('name' => $name, 'app_id' => $app_id, 'rrd_def' => $rrd_def, 'rrd_name' => $rrd_name); + $tags = ['name' => $name, 'app_id' => $app_id, 'rrd_def' => $rrd_def, 'rrd_name' => $rrd_name]; data_update($device, 'app', $tags, $fields); update_application($app, $pihole, $fields); } diff --git a/includes/polling/applications/portactivity.inc.php b/includes/polling/applications/portactivity.inc.php index d5e0199117..a17f62b753 100644 --- a/includes/polling/applications/portactivity.inc.php +++ b/includes/polling/applications/portactivity.inc.php @@ -1,7 +1,7 @@ getCode().':'. $e->getMessage() . PHP_EOL; - update_application($app, $e->getCode().':'.$e->getMessage(), []); // Set empty metrics and error message + echo PHP_EOL . $name . ':' . $e->getCode() . ':' . $e->getMessage() . PHP_EOL; + update_application($app, $e->getCode() . ':' . $e->getMessage(), []); // Set empty metrics and error message + return; } -$ports=$returned['data']; +$ports = $returned['data']; $ports_rrd_def = RrdDefinition::make() ->addDataset('total_conns', 'GAUGE', 0) @@ -66,11 +67,11 @@ $ports_rrd_def = RrdDefinition::make() // update the RRD files for each port // -$ports_keys=array_keys($ports); -$ports_keys_int=0; +$ports_keys = array_keys($ports); +$ports_keys_int = 0; while (isset($ports[$ports_keys[$ports_keys_int]])) { - $rrd_name = array('app', $name, $app_id, $ports_keys[$ports_keys_int]); - $fields = array( + $rrd_name = ['app', $name, $app_id, $ports_keys[$ports_keys_int]]; + $fields = [ 'total_conns' => $ports[$ports_keys[$ports_keys_int]]['total_conns'], 'total_to' => $ports[$ports_keys[$ports_keys_int]]['total_to'], 'total_from' => $ports[$ports_keys[$ports_keys_int]]['total_from'], @@ -113,8 +114,8 @@ while (isset($ports[$ports_keys[$ports_keys_int]])) { 'fromTIME_WAIT' => $ports[$ports_keys[$ports_keys_int]]['from']['TIME_WAIT'], 'fromUNKNOWN' => $ports[$ports_keys[$ports_keys_int]]['from']['UNKNOWN'], 'fromother' => $ports[$ports_keys[$ports_keys_int]]['from']['other'], - ); - $tags = array('name' => $name, 'app_id' => $app_id, 'rrd_def' => $ports_rrd_def, 'rrd_name' => $rrd_name); + ]; + $tags = ['name' => $name, 'app_id' => $app_id, 'rrd_def' => $ports_rrd_def, 'rrd_name' => $rrd_name]; data_update($device, 'app', $tags, $fields); $ports_keys_int++; @@ -123,25 +124,25 @@ while (isset($ports[$ports_keys[$ports_keys_int]])) { // // component processing for portsactivity // -$device_id=$device['device_id']; -$options=array( - 'filter' => array( - 'device_id' => array('=', $device_id), - 'type' => array('=', 'portsactivity'), - ), -); +$device_id = $device['device_id']; +$options = [ + 'filter' => [ + 'device_id' => ['=', $device_id], + 'type' => ['=', 'portsactivity'], + ], +]; -$component=new LibreNMS\Component(); -$components=$component->getComponents($device_id, $options); +$component = new LibreNMS\Component(); +$components = $component->getComponents($device_id, $options); //delete portsactivity component if nothing is found if (empty($ports_keys)) { if (isset($components[$device_id])) { foreach ($components[$device_id] as $component_id => $_unused) { - $component->deleteComponent($component_id); + $component->deleteComponent($component_id); } } -//add portsactivity component if found + //add portsactivity component if found } else { if (isset($components[$device_id])) { $portsc = $components[$device_id]; diff --git a/includes/polling/applications/postfix.inc.php b/includes/polling/applications/postfix.inc.php index 4915daa450..9483f653d3 100644 --- a/includes/polling/applications/postfix.inc.php +++ b/includes/polling/applications/postfix.inc.php @@ -1,22 +1,23 @@ addDataset('incomingq', 'GAUGE', 0) ->addDataset('activeq', 'GAUGE', 0) @@ -54,7 +55,7 @@ $rrd_def = RrdDefinition::make() ->addDataset('scp', 'GAUGE', 0) ->addDataset('urr', 'GAUGE', 0); -$fields = array( +$fields = [ 'incomingq' => $incomingq, 'activeq' => $activeq, 'deferredq' => $deferredq, @@ -89,9 +90,9 @@ $fields = array( 'iuscp' => $iuscp, 'sce' => $sce, 'scp' => $scp, - 'urr' => $urr -); + 'urr' => $urr, +]; -$tags = array('name' => $name, 'app_id' => $app_id, 'rrd_def' => $rrd_def, 'rrd_name' => $rrd_name); +$tags = ['name' => $name, 'app_id' => $app_id, 'rrd_def' => $rrd_def, 'rrd_name' => $rrd_name]; data_update($device, 'app', $tags, $fields); update_application($app, $mailq, $fields); diff --git a/includes/polling/applications/postgres.inc.php b/includes/polling/applications/postgres.inc.php index e182209692..872c7b028f 100644 --- a/includes/polling/applications/postgres.inc.php +++ b/includes/polling/applications/postgres.inc.php @@ -1,4 +1,5 @@ addDataset('backends', 'GAUGE', 0) @@ -35,7 +36,7 @@ $rrd_def = RrdDefinition::make() ->addDataset('upd', 'DERIVE', 0) ->addDataset('del', 'DERIVE', 0); -$fields = array( +$fields = [ 'backends' => $backends, 'commits' => $commits, 'rollbacks' => $rollbacks, @@ -52,27 +53,27 @@ $fields = array( 'fetch' => $fetch, 'ins' => $ins, 'upd' => $upd, - 'del' => $del -); + 'del' => $del, +]; $metrics['none'] = $fields; -$tags = array('name' => $name, 'app_id' => $app_id, 'rrd_def' => $rrd_def, 'rrd_name' => $rrd_name); +$tags = ['name' => $name, 'app_id' => $app_id, 'rrd_def' => $rrd_def, 'rrd_name' => $rrd_name]; data_update($device, 'app', $tags, $fields); //process each database -$db_lines=explode("\n", $postgres); -$db_lines_int=17; -$found_dbs=array(); +$db_lines = explode("\n", $postgres); +$db_lines_int = 17; +$found_dbs = []; while (isset($db_lines[$db_lines_int])) { - list($backends, $commits, $rollbacks, $read, $hit, $idxscan, $idxtupread, $idxtupfetch, $idxblksread, - $idxblkshit, $seqscan, $seqtupread, $ret, $fetch, $ins, $upd, $del, $dbname) = explode(" ", $db_lines[$db_lines_int]); + [$backends, $commits, $rollbacks, $read, $hit, $idxscan, $idxtupread, $idxtupfetch, $idxblksread, + $idxblkshit, $seqscan, $seqtupread, $ret, $fetch, $ins, $upd, $del, $dbname] = explode(" ", $db_lines[$db_lines_int]); - $rrd_name = array('app', $name, $app_id, $dbname); + $rrd_name = ['app', $name, $app_id, $dbname]; - $found_dbs[]=$dbname; + $found_dbs[] = $dbname; - $fields = array( + $fields = [ 'backends' => $backends, 'commits' => $commits, 'rollbacks' => $rollbacks, @@ -89,11 +90,11 @@ while (isset($db_lines[$db_lines_int])) { 'fetch' => $fetch, 'ins' => $ins, 'upd' => $upd, - 'del' => $del - ); + 'del' => $del, + ]; $metrics[$dbname] = $fields; - $tags = array('name' => $name, 'app_id' => $app_id, 'rrd_def' => $rrd_def, 'rrd_name' => $rrd_name); + $tags = ['name' => $name, 'app_id' => $app_id, 'rrd_def' => $rrd_def, 'rrd_name' => $rrd_name]; data_update($device, 'app', $tags, $fields); $db_lines_int++; @@ -103,22 +104,22 @@ update_application($app, $postgres, $metrics); // // component processing for postgres // -$device_id=$device['device_id']; +$device_id = $device['device_id']; -$options=array( - 'filter' => array( - 'device_id' => array('=', $device_id), - 'type' => array('=', 'postgres'), - ), -); +$options = [ + 'filter' => [ + 'device_id' => ['=', $device_id], + 'type' => ['=', 'postgres'], + ], +]; -$component=new LibreNMS\Component(); -$pg_components=$component->getComponents($device_id, $options); +$component = new LibreNMS\Component(); +$pg_components = $component->getComponents($device_id, $options); if (empty($found_dbs)) { if (isset($pg_components[$device_id])) { foreach ($pg_components[$device_id] as $component_id => $_unused) { - $component->deleteComponent($component_id); + $component->deleteComponent($component_id); } } } else { diff --git a/includes/polling/applications/powerdns-dnsdist.inc.php b/includes/polling/applications/powerdns-dnsdist.inc.php index 8f8cb1eca4..ac908c6dc2 100644 --- a/includes/polling/applications/powerdns-dnsdist.inc.php +++ b/includes/polling/applications/powerdns-dnsdist.inc.php @@ -32,9 +32,9 @@ d_echo($name); $powerdns_dnsdist = snmp_walk($device, $oid, $options); if (is_string($powerdns_dnsdist)) { - list($cache_hits, $cache_miss, $downstream_err, $downstream_timeout, $dynamic_block_size, $dynamic_blocked, $queries_count, $queries_recursive, $queries_empty, $queries_drop_no_policy, $queries_drop_nc, $queries_drop_nc_answer, $queries_self_answer, $queries_serv_fail, $queries_failure, $queries_acl_drop, $rule_drop, $rule_nxdomain, $rule_refused, $latency_100, $latency_1000, $latency_10000, $latency_1000000, $latency_slow, $latency_0_1, $latency_1_10, $latency_10_50, $latency_50_100, $latency_100_1000) = explode("\n", $powerdns_dnsdist); + [$cache_hits, $cache_miss, $downstream_err, $downstream_timeout, $dynamic_block_size, $dynamic_blocked, $queries_count, $queries_recursive, $queries_empty, $queries_drop_no_policy, $queries_drop_nc, $queries_drop_nc_answer, $queries_self_answer, $queries_serv_fail, $queries_failure, $queries_acl_drop, $rule_drop, $rule_nxdomain, $rule_refused, $latency_100, $latency_1000, $latency_10000, $latency_1000000, $latency_slow, $latency_0_1, $latency_1_10, $latency_10_50, $latency_50_100, $latency_100_1000] = explode("\n", $powerdns_dnsdist); - $rrd_name = array('app', $name, $app_id); + $rrd_name = ['app', $name, $app_id]; $rrd_def = RrdDefinition::make() ->addDataset('cache_hits', 'COUNTER', 0) @@ -67,8 +67,7 @@ if (is_string($powerdns_dnsdist)) { ->addDataset('latency_50_100', 'COUNTER', 0) ->addDataset('latency_100_1000', 'COUNTER', 0); - - $fields = array( + $fields = [ 'cache_hits' => $cache_hits, 'cache_miss' => $cache_miss, 'downstream_err' => $downstream_err, @@ -98,9 +97,9 @@ if (is_string($powerdns_dnsdist)) { 'latency_10_50' => $latency_10_50, 'latency_50_100' => $latency_50_100, 'latency_100_1000' => $latency_100_1000, - ); + ]; - $tags = array('name' => $name, 'app_id' => $app_id, 'rrd_def' => $rrd_def, 'rrd_name' => $rrd_name); + $tags = ['name' => $name, 'app_id' => $app_id, 'rrd_def' => $rrd_def, 'rrd_name' => $rrd_name]; data_update($device, 'app', $tags, $fields); update_application($app, $powerdns_dnsdist, $fields); } diff --git a/includes/polling/applications/powerdns-recursor.inc.php b/includes/polling/applications/powerdns-recursor.inc.php index fea5800df4..9784665368 100644 --- a/includes/polling/applications/powerdns-recursor.inc.php +++ b/includes/polling/applications/powerdns-recursor.inc.php @@ -51,8 +51,8 @@ if ($agent_data['app'][$name]) { $data = stripslashes(snmp_get($device, $oid, '-Oqv')); } -if (!empty($data)) { - $ds_list = array( +if (! empty($data)) { + $ds_list = [ 'all-outqueries' => 'DERIVE', 'answers-slow' => 'DERIVE', 'answers0-1' => 'DERIVE', @@ -111,10 +111,10 @@ if (!empty($data)) { 'unreachables' => 'DERIVE', 'uptime' => 'DERIVE', 'user-msec' => 'DERIVE', - ); + ]; //decode and flatten the data - $stats = array(); + $stats = []; foreach (json_decode($data, true) as $stat) { $stats[$stat['name']] = $stat['value']; } @@ -122,7 +122,7 @@ if (!empty($data)) { // only the stats we store in rrd $rrd_def = new RrdDefinition(); - $fields = array(); + $fields = []; foreach ($ds_list as $key => $type) { $rrd_def->addDataset($key, $type, 0); @@ -133,7 +133,7 @@ if (!empty($data)) { } } - $rrd_name = array('app', 'powerdns', 'recursor', $app_id); + $rrd_name = ['app', 'powerdns', 'recursor', $app_id]; $tags = compact('name', 'app_id', 'rrd_name', 'rrd_def'); data_update($device, 'app', $tags, $fields); update_application($app, $data, $fields); diff --git a/includes/polling/applications/powerdns.inc.php b/includes/polling/applications/powerdns.inc.php index f79c479b24..304a026010 100644 --- a/includes/polling/applications/powerdns.inc.php +++ b/includes/polling/applications/powerdns.inc.php @@ -50,15 +50,16 @@ if (isset($agent_data) && isset($agent_data['app'][$name])) { } catch (JsonAppParsingFailedException $e) { $legacy = $e->getOutput(); } catch (JsonAppException $e) { - echo PHP_EOL . $name . ':' .$e->getCode().':'. $e->getMessage() . PHP_EOL; - update_application($app, $e->getCode().':'.$e->getMessage(), []); // Set empty metrics and error message + echo PHP_EOL . $name . ':' . $e->getCode() . ':' . $e->getMessage() . PHP_EOL; + update_application($app, $e->getCode() . ':' . $e->getMessage(), []); // Set empty metrics and error message + return; } } if (isset($legacy)) { // Legacy script, build compatible array - list( + [ $powerdns['corrupt-packets'], $powerdns['deferred-cache-inserts'], $powerdns['deferred-cache-lookup'], @@ -81,7 +82,7 @@ if (isset($legacy)) { $powerdns['udp4-queries'], $powerdns['udp6-answers'], $powerdns['udp6-queries'], - ) = explode("\n", $legacy); + ] = explode("\n", $legacy); } d_echo($powerdns); diff --git a/includes/polling/applications/proxmox.inc.php b/includes/polling/applications/proxmox.inc.php index ff50f5cad6..3471cfc33b 100644 --- a/includes/polling/applications/proxmox.inc.php +++ b/includes/polling/applications/proxmox.inc.php @@ -2,13 +2,13 @@ use LibreNMS\RRD\RrdDefinition; -if (!function_exists('proxmox_port_exists')) { +if (! function_exists('proxmox_port_exists')) { /** * Check if a port on a Proxmox VM exists * @param string $p Port name * @param string $c Clustername - * @param integer $i VM ID - * @return integer|boolean The port-ID if the port exists, false if it doesn't exist + * @param int $i VM ID + * @return int|bool The port-ID if the port exists, false if it doesn't exist */ function proxmox_port_exists($i, $c, $p) { @@ -20,22 +20,22 @@ if (!function_exists('proxmox_port_exists')) { } } -if (!function_exists('proxmox_vm_exists')) { +if (! function_exists('proxmox_vm_exists')) { /** * Check if a Proxmox VM exists - * @param integer $i VM ID + * @param int $i VM ID * @param string $c Clustername * @param array $pmxcache Reference to the Proxmox VM Cache - * @return boolean true if the VM exists, false if it doesn't + * @return bool true if the VM exists, false if it doesn't */ function proxmox_vm_exists($i, $c, &$pmxcache) { - if (isset($pmxcache[$c][$i]) && $pmxcache[$c][$i] > 0) { return true; } if ($row = dbFetchRow("SELECT id FROM proxmox WHERE vmid = ? AND cluster = ?", [$i, $c])) { - $pmxcache[$c][$i] = (integer)$row['id']; + $pmxcache[$c][$i] = (int) $row['id']; + return true; } @@ -46,11 +46,11 @@ if (!function_exists('proxmox_vm_exists')) { $name = 'proxmox'; $app_id = $app['app_id']; -if (\LibreNMS\Config::get('enable_proxmox') && !empty($agent_data['app'][$name])) { +if (\LibreNMS\Config::get('enable_proxmox') && ! empty($agent_data['app'][$name])) { $proxmox = $agent_data['app'][$name]; } elseif (\LibreNMS\Config::get('enable_proxmox')) { $options = '-Oqv'; - $oid = '.1.3.6.1.4.1.8072.1.3.2.3.1.2.7.112.114.111.120.109.111.120'; + $oid = '.1.3.6.1.4.1.8072.1.3.2.3.1.2.7.112.114.111.120.109.111.120'; $proxmox = snmp_get($device, $oid, $options); $proxmox = preg_replace('/^.+\n/', '', $proxmox); $proxmox = str_replace("<<>>\n", '', $proxmox); @@ -60,33 +60,33 @@ if ($proxmox) { $pmxlines = explode("\n", $proxmox); $pmxcluster = array_shift($pmxlines); dbUpdate( - array('device_id' => $device['device_id'], 'app_type' => $name, 'app_instance' => $pmxcluster), + ['device_id' => $device['device_id'], 'app_type' => $name, 'app_instance' => $pmxcluster], 'applications', '`device_id` = ? AND `app_type` = ?', - array($device['device_id'], $name) + [$device['device_id'], $name] ); - $metrics = array(); + $metrics = []; if (count($pmxlines) > 0) { - $pmxcache = array(); + $pmxcache = []; foreach ($pmxlines as $vm) { $vm = str_replace('"', '', $vm); - list($vmid, $vmport, $vmpin, $vmpout, $vmdesc) = explode('/', $vm, 5); - print "Proxmox ($pmxcluster): $vmdesc: $vmpin/$vmpout/$vmport\n"; + [$vmid, $vmport, $vmpin, $vmpout, $vmdesc] = explode('/', $vm, 5); + echo "Proxmox ($pmxcluster): $vmdesc: $vmpin/$vmpout/$vmport\n"; - $rrd_proxmox_name = array( + $rrd_proxmox_name = [ 'pmxcluster' => $pmxcluster, 'vmid' => $vmid, - 'vmport' => $vmport - ); + 'vmport' => $vmport, + ]; $rrd_def = RrdDefinition::make() ->addDataset('INOCTETS', 'DERIVE', 0, 12500000000) ->addDataset('OUTOCTETS', 'DERIVE', 0, 12500000000); - $fields = array( + $fields = [ 'INOCTETS' => $vmpin, - 'OUTOCTETS' => $vmpout - ); + 'OUTOCTETS' => $vmpout, + ]; $proxmox_metric_prefix = "pmxcluster{$pmxcluster}_vmid{$vmid}_vmport$vmport"; $metrics[$proxmox_metric_prefix] = $fields; @@ -94,29 +94,29 @@ if ($proxmox) { data_update($device, 'app', $tags, $fields); if (proxmox_vm_exists($vmid, $pmxcluster, $pmxcache) === true) { - dbUpdate(array( + dbUpdate([ 'device_id' => $device['device_id'], - 'last_seen' => array('NOW()'), - 'description' => $vmdesc - ), $name, '`vmid` = ? AND `cluster` = ?', array($vmid, $pmxcluster)); + 'last_seen' => ['NOW()'], + 'description' => $vmdesc, + ], $name, '`vmid` = ? AND `cluster` = ?', [$vmid, $pmxcluster]); } else { - $pmxcache[$pmxcluster][$vmid] = dbInsert(array( + $pmxcache[$pmxcluster][$vmid] = dbInsert([ 'cluster' => $pmxcluster, 'vmid' => $vmid, 'description' => $vmdesc, - 'device_id' => $device['device_id'] - ), $name); + 'device_id' => $device['device_id'], + ], $name); } if ($portid = proxmox_port_exists($vmid, $pmxcluster, $vmport) !== false) { dbUpdate( - array('last_seen' => array('NOW()')), + ['last_seen' => ['NOW()']], 'proxmox_ports', '`vm_id` = ? AND `port` = ?', - array($pmxcache[$pmxcluster][$vmid], $vmport) + [$pmxcache[$pmxcluster][$vmid], $vmport] ); } else { - dbInsert(array('vm_id' => $pmxcache[$pmxcluster][$vmid], 'port' => $vmport), 'proxmox_ports'); + dbInsert(['vm_id' => $pmxcache[$pmxcluster][$vmid], 'port' => $vmport], 'proxmox_ports'); } } } diff --git a/includes/polling/applications/puppet-agent.inc.php b/includes/polling/applications/puppet-agent.inc.php index 615452e438..5762f02c7a 100644 --- a/includes/polling/applications/puppet-agent.inc.php +++ b/includes/polling/applications/puppet-agent.inc.php @@ -1,6 +1,7 @@ getParsedJson(); } catch (JsonAppException $e) { - echo PHP_EOL . $name . ':' .$e->getCode().':'. $e->getMessage() . PHP_EOL; - update_application($app, $e->getCode().':'.$e->getMessage(), []); // Set empty metrics and error message + echo PHP_EOL . $name . ':' . $e->getCode() . ':' . $e->getMessage() . PHP_EOL; + update_application($app, $e->getCode() . ':' . $e->getMessage(), []); // Set empty metrics and error message + return; } - $puppet_changes = $puppet_agent_data['changes']; $puppet_events = $puppet_agent_data['events']; $puppet_resources = $puppet_agent_data['resources']; $puppet_time = $puppet_agent_data['time']; -$metrics = array(); +$metrics = []; // // Changes Processing // -$rrd_name = array('app', $name, $app_id, 'changes'); +$rrd_name = ['app', $name, $app_id, 'changes']; $rrd_def = RrdDefinition::make() ->addDataset('total', 'GAUGE', 0); -$fields = array( +$fields = [ 'total' => $puppet_changes['total'], -); +]; $metrics['changes'] = $fields; -$tags = array('name' => $name, 'app_id' => $app_id, 'rrd_def' => $rrd_def, 'rrd_name' => $rrd_name); +$tags = ['name' => $name, 'app_id' => $app_id, 'rrd_def' => $rrd_def, 'rrd_name' => $rrd_name]; data_update($device, 'app', $tags, $fields); // // Events Processing // -$rrd_name = array('app', $name, $app_id, 'events'); +$rrd_name = ['app', $name, $app_id, 'events']; $rrd_def = RrdDefinition::make() ->addDataset('success', 'GAUGE', 0) ->addDataset('failure', 'GAUGE', 0) ->addDataset('total', 'GAUGE', 0); -$fields = array( +$fields = [ 'success' => $puppet_events['success'], 'failure' => $puppet_events['failure'], 'total' => $puppet_events['total'], -); +]; $metrics['events'] = $fields; -$tags = array('name' => $name, 'app_id' => $app_id, 'rrd_def' => $rrd_def, 'rrd_name' => $rrd_name); +$tags = ['name' => $name, 'app_id' => $app_id, 'rrd_def' => $rrd_def, 'rrd_name' => $rrd_name]; data_update($device, 'app', $tags, $fields); // // Resources Processing // -$rrd_name = array('app', $name, $app_id, 'resources'); +$rrd_name = ['app', $name, $app_id, 'resources']; $rrd_def = RrdDefinition::make() ->addDataset('changed', 'GAUGE', 0) ->addDataset('corrective_change', 'GAUGE', 0) @@ -74,7 +75,7 @@ $rrd_def = RrdDefinition::make() ->addDataset('skipped', 'GAUGE', 0) ->addDataset('total', 'GAUGE', 0); -$fields = array( +$fields = [ 'changed' => $puppet_resources['changed'], 'corrective_change' => $puppet_resources['corrective_change'], 'failed' => $puppet_resources['failed'], @@ -84,16 +85,16 @@ $fields = array( 'scheduled' => $puppet_resources['scheduled'], 'skipped' => $puppet_resources['skipped'], 'total' => $puppet_resources['total'], -); +]; $metrics['resources'] = $fields; -$tags = array('name' => $name, 'app_id' => $app_id, 'rrd_def' => $rrd_def, 'rrd_name' => $rrd_name); +$tags = ['name' => $name, 'app_id' => $app_id, 'rrd_def' => $rrd_def, 'rrd_name' => $rrd_name]; data_update($device, 'app', $tags, $fields); // // Time Processing // -$rrd_name = array('app', $name, $app_id, 'time'); +$rrd_name = ['app', $name, $app_id, 'time']; $rrd_def = RrdDefinition::make() ->addDataset('catalog_application', 'GAUGE', 0) ->addDataset('config_retrieval', 'GAUGE', 0) @@ -105,7 +106,7 @@ $rrd_def = RrdDefinition::make() ->addDataset('transaction_evaluation', 'GAUGE', 0) ->addDataset('total', 'GAUGE', 0); -$fields = array( +$fields = [ 'catalog_application' => $puppet_time['catalog_application'], 'config_retrieval' => $puppet_time['config_retrieval'], 'convert_catalog' => $puppet_time['convert_catalog'], @@ -115,25 +116,25 @@ $fields = array( 'schedule' => $puppet_time['schedule'], 'transaction_evaluation' => $puppet_time['transaction_evaluation'], 'total' => $puppet_time['total'], -); +]; $metrics['time'] = $fields; -$tags = array('name' => $name, 'app_id' => $app_id, 'rrd_def' => $rrd_def, 'rrd_name' => $rrd_name); +$tags = ['name' => $name, 'app_id' => $app_id, 'rrd_def' => $rrd_def, 'rrd_name' => $rrd_name]; data_update($device, 'app', $tags, $fields); // // Last Rung Processing // -$rrd_name = array('app', $name, $app_id, 'last_run'); +$rrd_name = ['app', $name, $app_id, 'last_run']; $rrd_def = RrdDefinition::make() ->addDataset('last_run', 'GAUGE', 0); -$fields = array( - 'last_run' => round(intval($puppet_time['last_run'])/60, 0), # diff seconds to minutes -); +$fields = [ + 'last_run' => round(intval($puppet_time['last_run']) / 60, 0), // diff seconds to minutes +]; $metrics['last_run'] = $fields; -$tags = array('name' => $name, 'app_id' => $app_id, 'rrd_def' => $rrd_def, 'rrd_name' => $rrd_name); +$tags = ['name' => $name, 'app_id' => $app_id, 'rrd_def' => $rrd_def, 'rrd_name' => $rrd_name]; data_update($device, 'app', $tags, $fields); update_application($app, $output, $metrics); diff --git a/includes/polling/applications/pureftpd.inc.php b/includes/polling/applications/pureftpd.inc.php index 60e06d8010..e2b2937f32 100644 --- a/includes/polling/applications/pureftpd.inc.php +++ b/includes/polling/applications/pureftpd.inc.php @@ -1,7 +1,7 @@ getParsedJson(); } catch (JsonAppException $e) { - echo PHP_EOL . $name . ':' .$e->getCode().':'. $e->getMessage() . PHP_EOL; - update_application($app, $e->getCode().':'.$e->getMessage(), []); // Set empty metrics and error message + echo PHP_EOL . $name . ':' . $e->getCode() . ':' . $e->getMessage() . PHP_EOL; + update_application($app, $e->getCode() . ':' . $e->getMessage(), []); // Set empty metrics and error message + return; } @@ -48,47 +49,47 @@ foreach ($pureftpd_data as $client) { } } -$metrics = array(); -#PureFTPd - Connections +$metrics = []; +//PureFTPd - Connections $dataset = 'connections'; -$rrd_name = array('app', $name, $app_id, $dataset); +$rrd_name = ['app', $name, $app_id, $dataset]; $rrd_def = RrdDefinition::make() ->addDataset('download', 'GAUGE', 0) ->addDataset('upload', 'GAUGE', 0) ->addDataset('idle', 'GAUGE', 0); -$fields = array ( +$fields = [ 'download' => $dl_connections, 'upload' => $ul_connections, - 'idle' => $idle_connections - ); + 'idle' => $idle_connections, +]; $metrics[$dataset] = $fields; -$tags = array('name' => $dataset, 'app_id' => $app_id, 'rrd_def' => $rrd_def, 'rrd_name' => $rrd_name); +$tags = ['name' => $dataset, 'app_id' => $app_id, 'rrd_def' => $rrd_def, 'rrd_name' => $rrd_name]; data_update($device, 'app', $tags, $fields); -#PureFTPd - connected Users +//PureFTPd - connected Users $dataset = 'users'; -$rrd_name = array('app', $name, $app_id, $dataset); +$rrd_name = ['app', $name, $app_id, $dataset]; $rrd_def = RrdDefinition::make() ->addDataset('total', 'GAUGE', 0); -$fields = array ( - 'total' => $users_connected - ); +$fields = [ + 'total' => $users_connected, +]; $metrics[$dataset] = $fields; -$tags = array('name' => $dataset, 'app_id' => $app_id, 'rrd_def' => $rrd_def, 'rrd_name' => $rrd_name); +$tags = ['name' => $dataset, 'app_id' => $app_id, 'rrd_def' => $rrd_def, 'rrd_name' => $rrd_name]; data_update($device, 'app', $tags, $fields); -#PureFTPd - Bitrate +//PureFTPd - Bitrate $dataset = 'bitrate'; -$rrd_name = array('app', $name, $app_id, $dataset); +$rrd_name = ['app', $name, $app_id, $dataset]; $rrd_def = RrdDefinition::make() ->addDataset('download', 'GAUGE', 0) ->addDataset('upload', 'GAUGE', 0); -$fields = array ( +$fields = [ 'download' => $dl_bitrate, 'upload' => $ul_bitrate, - ); +]; $metrics[$dataset] = $fields; -$tags = array('name' => $dataset, 'app_id' => $app_id, 'rrd_def' => $rrd_def, 'rrd_name' => $rrd_name); +$tags = ['name' => $dataset, 'app_id' => $app_id, 'rrd_def' => $rrd_def, 'rrd_name' => $rrd_name]; data_update($device, 'app', $tags, $fields); update_application($app, $output, $metrics); diff --git a/includes/polling/applications/redis.inc.php b/includes/polling/applications/redis.inc.php index b72db97bc3..32d41ca36f 100644 --- a/includes/polling/applications/redis.inc.php +++ b/includes/polling/applications/redis.inc.php @@ -1,6 +1,7 @@ getParsedJson(); } catch (JsonAppException $e) { - echo PHP_EOL . $name . ':' .$e->getCode().':'. $e->getMessage() . PHP_EOL; - update_application($app, $e->getCode().':'.$e->getMessage(), []); // Set empty metrics and error message + echo PHP_EOL . $name . ':' . $e->getCode() . ':' . $e->getMessage() . PHP_EOL; + update_application($app, $e->getCode() . ':' . $e->getMessage(), []); // Set empty metrics and error message + return; } @@ -21,72 +23,68 @@ $client_data = $redis_data['Clients']; $memory_data = $redis_data['Memory']; $stats_data = $redis_data['Stats']; -$metrics = array(); +$metrics = []; $category = 'clients'; -$fields = array( +$fields = [ 'connected' => $client_data['connected_clients'], 'blocked' => $client_data['blocked_clients'], -); +]; $rrd_def = RrdDefinition::make() ->addDataset('connected', 'GAUGE', 0) ->addDataset('blocked', 'GAUGE', 0); -$rrd_name = array('app', $name, $app_id, $category); +$rrd_name = ['app', $name, $app_id, $category]; $metrics[$category] = $fields; -$tags = array('name' => $name, 'app_id' => $app_id, 'rrd_def' => $rrd_def, 'rrd_name' => $rrd_name); +$tags = ['name' => $name, 'app_id' => $app_id, 'rrd_def' => $rrd_def, 'rrd_name' => $rrd_name]; data_update($device, 'app', $tags, $fields); - $category = 'memory'; -$fields = array( +$fields = [ 'active' => $memory_data['allocator'], 'allocated' => $memory_data['allocator_allocated'], 'resident' => $memory_data['allocator_resident'], 'frag_bytes' => $memory_data['allocator_frag_bytes'], 'rss_bytes' => $memory_data['allocator_rss_bytes'], -); +]; $rrd_def = RrdDefinition::make() ->addDataset('active', 'GAUGE', 0) ->addDataset('allocated', 'GAUGE', 0) ->addDataset('resident', 'GAUGE', 0) ->addDataset('frag_bytes', 'GAUGE', 0) ->addDataset('rss_bytes', 'GAUGE', 0); -$rrd_name = array('app', $name, $app_id, $category); +$rrd_name = ['app', $name, $app_id, $category]; $metrics[$category] = $fields; -$tags = array('name' => $name, 'app_id' => $app_id, 'rrd_def' => $rrd_def, 'rrd_name' => $rrd_name); +$tags = ['name' => $name, 'app_id' => $app_id, 'rrd_def' => $rrd_def, 'rrd_name' => $rrd_name]; data_update($device, 'app', $tags, $fields); - $category = 'objects'; -$fields = array( +$fields = [ 'pending' => $memory_data['lazyfree_pending_objects'], -); +]; $rrd_def = RrdDefinition::make() ->addDataset('pending', 'GAUGE', 0); -$rrd_name = array('app', $name, $app_id, $category); +$rrd_name = ['app', $name, $app_id, $category]; $metrics[$category] = $fields; -$tags = array('name' => $name, 'app_id' => $app_id, 'rrd_def' => $rrd_def, 'rrd_name' => $rrd_name); +$tags = ['name' => $name, 'app_id' => $app_id, 'rrd_def' => $rrd_def, 'rrd_name' => $rrd_name]; data_update($device, 'app', $tags, $fields); - $category = 'fragmentation'; -$fields = array( +$fields = [ 'bytes' => $memory_data['mem_fragmentation_bytes'], -); +]; $rrd_def = RrdDefinition::make() ->addDataset('bytes', 'GAUGE', 0); -$rrd_name = array('app', $name, $app_id, $category); +$rrd_name = ['app', $name, $app_id, $category]; $metrics[$category] = $fields; -$tags = array('name' => $name, 'app_id' => $app_id, 'rrd_def' => $rrd_def, 'rrd_name' => $rrd_name); +$tags = ['name' => $name, 'app_id' => $app_id, 'rrd_def' => $rrd_def, 'rrd_name' => $rrd_name]; data_update($device, 'app', $tags, $fields); - $category = 'usage'; -$fields = array( +$fields = [ 'allocated' => $memory_data['used_memory'], 'dataset' => $memory_data['used_memory_dataset'], 'lua' => $memory_data['used_memory_lua'], @@ -95,7 +93,7 @@ $fields = array( 'rss' => $memory_data['used_memory_rss'], 'scripts' => $memory_data['used_memory_scripts'], 'startup' => $memory_data['used_memory_startup'], -); +]; $rrd_def = RrdDefinition::make() ->addDataset('allocated', 'COUNTER', 0) ->addDataset('dataset', 'GAUGE', 0) @@ -105,104 +103,98 @@ $rrd_def = RrdDefinition::make() ->addDataset('rss', 'GAUGE', 0) ->addDataset('scripts', 'GAUGE', 0) ->addDataset('startup', 'GAUGE', 0); -$rrd_name = array('app', $name, $app_id, $category); +$rrd_name = ['app', $name, $app_id, $category]; $metrics[$category] = $fields; -$tags = array('name' => $name, 'app_id' => $app_id, 'rrd_def' => $rrd_def, 'rrd_name' => $rrd_name); +$tags = ['name' => $name, 'app_id' => $app_id, 'rrd_def' => $rrd_def, 'rrd_name' => $rrd_name]; data_update($device, 'app', $tags, $fields); - $category = 'defrag'; -$fields = array( +$fields = [ 'hits' => $stats_data['active_defrag_hits'], 'misses' => $stats_data['active_defrag_misses'], 'key_hits' => $stats_data['active_defrag_key_hits'], 'key_misses' => $stats_data['active_defrag_key_misses'], -); +]; $rrd_def = RrdDefinition::make() ->addDataset('hits', 'GAUGE', 0) ->addDataset('misses', 'GAUGE', 0) ->addDataset('key_hits', 'GAUGE', 0) ->addDataset('key_misses', 'GAUGE', 0); -$rrd_name = array('app', $name, $app_id, $category); +$rrd_name = ['app', $name, $app_id, $category]; $metrics[$category] = $fields; -$tags = array('name' => $name, 'app_id' => $app_id, 'rrd_def' => $rrd_def, 'rrd_name' => $rrd_name); +$tags = ['name' => $name, 'app_id' => $app_id, 'rrd_def' => $rrd_def, 'rrd_name' => $rrd_name]; data_update($device, 'app', $tags, $fields); - $category = 'keyspace'; -$fields = array( +$fields = [ 'hits' => $stats_data['keyspace_hits'], 'misses' => $stats_data['keyspace_misses'], -); +]; $rrd_def = RrdDefinition::make() ->addDataset('hits', 'COUNTER', 0) ->addDataset('misses', 'COUNTER', 0); -$rrd_name = array('app', $name, $app_id, $category); +$rrd_name = ['app', $name, $app_id, $category]; $metrics[$category] = $fields; -$tags = array('name' => $name, 'app_id' => $app_id, 'rrd_def' => $rrd_def, 'rrd_name' => $rrd_name); +$tags = ['name' => $name, 'app_id' => $app_id, 'rrd_def' => $rrd_def, 'rrd_name' => $rrd_name]; data_update($device, 'app', $tags, $fields); - $category = 'sync'; -$fields = array( +$fields = [ 'full' => $stats_data['sync_full'], 'ok' => $stats_data['sync_partial_ok'], 'err' => $stats_data['sync_partial_err'], -); +]; $rrd_def = RrdDefinition::make() ->addDataset('full', 'GAUGE', 0) ->addDataset('ok', 'GAUGE', 0) ->addDataset('err', 'GAUGE', 0); -$rrd_name = array('app', $name, $app_id, $category); +$rrd_name = ['app', $name, $app_id, $category]; $metrics[$category] = $fields; -$tags = array('name' => $name, 'app_id' => $app_id, 'rrd_def' => $rrd_def, 'rrd_name' => $rrd_name); +$tags = ['name' => $name, 'app_id' => $app_id, 'rrd_def' => $rrd_def, 'rrd_name' => $rrd_name]; data_update($device, 'app', $tags, $fields); - $category = 'commands'; -$fields = array( +$fields = [ 'processed' => $stats_data['total_commands_processed'], -); +]; $rrd_def = RrdDefinition::make() ->addDataset('processed', 'COUNTER', 0); -$rrd_name = array('app', $name, $app_id, $category); +$rrd_name = ['app', $name, $app_id, $category]; $metrics[$category] = $fields; -$tags = array('name' => $name, 'app_id' => $app_id, 'rrd_def' => $rrd_def, 'rrd_name' => $rrd_name); +$tags = ['name' => $name, 'app_id' => $app_id, 'rrd_def' => $rrd_def, 'rrd_name' => $rrd_name]; data_update($device, 'app', $tags, $fields); - $category = 'connections'; -$fields = array( +$fields = [ 'received' => $stats_data['total_connections_received'], 'rejected' => $stats_data['rejected_connections'], -); +]; $rrd_def = RrdDefinition::make() ->addDataset('received', 'COUNTER', 0) ->addDataset('rejected', 'COUNTER', 0); -$rrd_name = array('app', $name, $app_id, $category); +$rrd_name = ['app', $name, $app_id, $category]; $metrics[$category] = $fields; -$tags = array('name' => $name, 'app_id' => $app_id, 'rrd_def' => $rrd_def, 'rrd_name' => $rrd_name); +$tags = ['name' => $name, 'app_id' => $app_id, 'rrd_def' => $rrd_def, 'rrd_name' => $rrd_name]; data_update($device, 'app', $tags, $fields); - $category = 'net'; -$fields = array( +$fields = [ 'input_bytes' => $stats_data['total_net_input_bytes'], 'output_bytes' => $stats_data['total_net_output_bytes'], -); +]; $rrd_def = RrdDefinition::make() ->addDataset('input_bytes', 'COUNTER', 0) ->addDataset('output_bytes', 'COUNTER', 0); -$rrd_name = array('app', $name, $app_id, $category); +$rrd_name = ['app', $name, $app_id, $category]; $metrics[$category] = $fields; -$tags = array('name' => $name, 'app_id' => $app_id, 'rrd_def' => $rrd_def, 'rrd_name' => $rrd_name); +$tags = ['name' => $name, 'app_id' => $app_id, 'rrd_def' => $rrd_def, 'rrd_name' => $rrd_name]; data_update($device, 'app', $tags, $fields); update_application($app, $output, $metrics); diff --git a/includes/polling/applications/rrdcached.inc.php b/includes/polling/applications/rrdcached.inc.php index 0f93160a31..0d6db48492 100644 --- a/includes/polling/applications/rrdcached.inc.php +++ b/includes/polling/applications/rrdcached.inc.php @@ -40,7 +40,7 @@ if ($agent_data['app'][$name]) { $sock = fsockopen($device['hostname'], 42217, $errno, $errstr, 5); - if (!$sock) { + if (! $sock) { $socket = \LibreNMS\Config::get('rrdcached'); if (substr($socket, 0, 6) == 'unix:/') { $socket_file = substr($socket, 5); @@ -57,7 +57,7 @@ if ($agent_data['app'][$name]) { $data .= fgets($sock, 128); if ($max == -1) { $tmp_max = explode(' ', $data); - $max = $tmp_max[0]+1; + $max = $tmp_max[0] + 1; } $count++; } @@ -67,7 +67,7 @@ if ($agent_data['app'][$name]) { } } -$rrd_name = array('app', $name, $app_id); +$rrd_name = ['app', $name, $app_id]; $rrd_def = RrdDefinition::make() ->addDataset('queue_length', 'GAUGE', 0) ->addDataset('updates_received', 'COUNTER', 0) @@ -79,7 +79,7 @@ $rrd_def = RrdDefinition::make() ->addDataset('journal_bytes', 'COUNTER', 0) ->addDataset('journal_rotate', 'COUNTER', 0); -$fields = array(); +$fields = []; foreach (explode("\n", $data) as $line) { $split = explode(': ', $line); if (count($split) == 2) { diff --git a/includes/polling/applications/sdfsinfo.inc.php b/includes/polling/applications/sdfsinfo.inc.php index f170f78f72..a6c797109f 100644 --- a/includes/polling/applications/sdfsinfo.inc.php +++ b/includes/polling/applications/sdfsinfo.inc.php @@ -31,7 +31,7 @@ d_echo($name); $sdfsinfo = snmp_walk($device, $oid, $options); if (is_string($sdfsinfo)) { - $rrd_name = array('app', $name, $app_id); + $rrd_name = ['app', $name, $app_id]; $rrd_def = RrdDefinition::make() ->addDataset('files', 'GAUGE', 0) @@ -46,9 +46,9 @@ if (is_string($sdfsinfo)) { ->addDataset('actual_savings', 'GAUGE', 0) ->addDataset('comp_rate', 'GAUGE', 0); - list($files, $vol_capacity, $vol_logic_size, $vol_max_load, $dup_data, $blocks_unique, $blocks_compressed, $cluster_copies, $dedup_rate, $actual_savings, $comp_rate) = explode(" ", $sdfsinfo); + [$files, $vol_capacity, $vol_logic_size, $vol_max_load, $dup_data, $blocks_unique, $blocks_compressed, $cluster_copies, $dedup_rate, $actual_savings, $comp_rate] = explode(" ", $sdfsinfo); - $fields = array( + $fields = [ 'files' => $files, 'vol_capacity' => $vol_capacity, 'vol_logic_size' => $vol_logic_size, @@ -60,9 +60,9 @@ if (is_string($sdfsinfo)) { 'dedup_rate' => $dedup_rate, 'actual_savings' => $actual_savings, 'comp_rate' => $comp_rate, - ); + ]; - $tags = array('name' => $name, 'app_id' => $app_id, 'rrd_def' => $rrd_def, 'rrd_name' => $rrd_name); + $tags = ['name' => $name, 'app_id' => $app_id, 'rrd_def' => $rrd_def, 'rrd_name' => $rrd_name]; data_update($device, 'app', $tags, $fields); update_application($app, $sdfsinfo, $fields); diff --git a/includes/polling/applications/seafile.inc.php b/includes/polling/applications/seafile.inc.php index 1abd7c9ac7..4ea2e30015 100644 --- a/includes/polling/applications/seafile.inc.php +++ b/includes/polling/applications/seafile.inc.php @@ -1,6 +1,7 @@ getParsedJson(); } catch (JsonAppException $e) { - echo PHP_EOL . $name . ':' .$e->getCode().':'. $e->getMessage() . PHP_EOL; - update_application($app, $e->getCode().':'.$e->getMessage(), []); // Set empty metrics and error message + echo PHP_EOL . $name . ':' . $e->getCode() . ':' . $e->getMessage() . PHP_EOL; + update_application($app, $e->getCode() . ':' . $e->getMessage(), []); // Set empty metrics and error message + return; } @@ -23,7 +25,7 @@ $client_platform = $seafile_data['devices']['platform']; $group_data = $seafile_data['groups']; $sysinfo_data = $seafile_data['sysinfo']; -$rrd_name = array('app', $name, $app_id); +$rrd_name = ['app', $name, $app_id]; $rrd_def = RrdDefinition::make() ->addDataset('enabled', 'GAUGE', 0) ->addDataset('libraries', 'GAUGE', 0) @@ -31,31 +33,30 @@ $rrd_def = RrdDefinition::make() ->addDataset('size_consumption', 'GAUGE', 0); $category = 'acc'; -$metrics = array(); -# handling accounts +$metrics = []; +// handling accounts foreach ($account_data as $data) { $owner_name = str_replace(' ', '_', $data['owner']); - $enabled = $data['is_active'] ? 1: 0; + $enabled = $data['is_active'] ? 1 : 0; $libraries = $data['repos']; $trashed_libraries = $data['trash_repos']; $size_consumption = $data['usage']; - $rrd_name = array('app', $name, $app_id, $category, $owner_name); + $rrd_name = ['app', $name, $app_id, $category, $owner_name]; - $fields = array( + $fields = [ 'enabled' => $enabled, 'libraries' => $libraries, 'trashed_libraries' => $trashed_libraries, - 'size_consumption' => $size_consumption - ); + 'size_consumption' => $size_consumption, + ]; - $metrics[$owner_name.'_'.$category] = $fields; - $tags = array('name' => $owner_name, 'app_id' => $app_id, 'rrd_def' => $rrd_def, 'rrd_name' => $rrd_name); + $metrics[$owner_name . '_' . $category] = $fields; + $tags = ['name' => $owner_name, 'app_id' => $app_id, 'rrd_def' => $rrd_def, 'rrd_name' => $rrd_name]; data_update($device, 'app', $tags, $fields); } - -# handling groups +// handling groups $rrd_def = RrdDefinition::make() ->addDataset('count', 'GAUGE', 0); $category = 'grp'; @@ -63,18 +64,17 @@ $category = 'grp'; $group_name = 'groups'; $group_count = $group_data['count']; -$rrd_name = array('app', $name, $app_id, $category, $group_name); +$rrd_name = ['app', $name, $app_id, $category, $group_name]; -$fields = array( +$fields = [ 'count' => $group_count, -); +]; -$metrics[$group_name.'_'.$category] = $fields; -$tags = array('name' => $group_name, 'app_id' => $app_id, 'rrd_def' => $rrd_def, 'rrd_name' => $rrd_name); +$metrics[$group_name . '_' . $category] = $fields; +$tags = ['name' => $group_name, 'app_id' => $app_id, 'rrd_def' => $rrd_def, 'rrd_name' => $rrd_name]; data_update($device, 'app', $tags, $fields); - -# handling client version +// handling client version $rrd_def = RrdDefinition::make() ->addDataset('version', 'GAUGE', 0); $category = 'cltver'; @@ -83,19 +83,18 @@ foreach ($client_version as $data) { $version_name = $data['client_version']; $version_count = $data['clients']; - $rrd_name = array('app', $name, $app_id, $category, $version_name); + $rrd_name = ['app', $name, $app_id, $category, $version_name]; - $fields = array( + $fields = [ 'version' => $version_count, - ); + ]; - $metrics[$version_name.'_'.$category] = $fields; - $tags = array('name' => $version_name, 'app_id' => $app_id, 'rrd_def' => $rrd_def, 'rrd_name' => $rrd_name); + $metrics[$version_name . '_' . $category] = $fields; + $tags = ['name' => $version_name, 'app_id' => $app_id, 'rrd_def' => $rrd_def, 'rrd_name' => $rrd_name]; data_update($device, 'app', $tags, $fields); } - -# handling client platform +// handling client platform $rrd_def = RrdDefinition::make() ->addDataset('platform', 'GAUGE', 0); $category = 'cltos'; @@ -104,19 +103,18 @@ foreach ($client_platform as $data) { $os_name = $data['os_name']; $os_count = $data['clients']; - $rrd_name = array('app', $name, $app_id, $category, $os_name); + $rrd_name = ['app', $name, $app_id, $category, $os_name]; - $fields = array( + $fields = [ 'platform' => $os_count, - ); + ]; - $metrics[$os_name.'_'.$category] = $fields; - $tags = array('name' => $os_name, 'app_id' => $app_id, 'rrd_def' => $rrd_def, 'rrd_name' => $rrd_name); + $metrics[$os_name . '_' . $category] = $fields; + $tags = ['name' => $os_name, 'app_id' => $app_id, 'rrd_def' => $rrd_def, 'rrd_name' => $rrd_name]; data_update($device, 'app', $tags, $fields); } - -# handling sysinfo +// handling sysinfo $rrd_def = RrdDefinition::make() ->addDataset('connected', 'GAUGE', 0); $category = 'sysinfo'; @@ -124,14 +122,14 @@ $category = 'sysinfo'; $sysinfo_name = 'devices'; $sysinfo_connected_devices = $sysinfo_data['current_connected_devices_count']; -$rrd_name = array('app', $name, $app_id, $category, $sysinfo_name); +$rrd_name = ['app', $name, $app_id, $category, $sysinfo_name]; -$fields = array( +$fields = [ 'connected' => $sysinfo_connected_devices, -); +]; -$metrics[$sysinfo_name.'_'.$category] = $fields; -$tags = array('name' => $sysinfo_name, 'app_id' => $app_id, 'rrd_def' => $rrd_def, 'rrd_name' => $rrd_name); +$metrics[$sysinfo_name . '_' . $category] = $fields; +$tags = ['name' => $sysinfo_name, 'app_id' => $app_id, 'rrd_def' => $rrd_def, 'rrd_name' => $rrd_name]; data_update($device, 'app', $tags, $fields); update_application($app, $output, $metrics); diff --git a/includes/polling/applications/shoutcast.inc.php b/includes/polling/applications/shoutcast.inc.php index e8f92091ee..274f3209f1 100644 --- a/includes/polling/applications/shoutcast.inc.php +++ b/includes/polling/applications/shoutcast.inc.php @@ -8,22 +8,22 @@ $name = 'shoutcast'; $app_id = $app['app_id']; $options = '-Oqv'; -$oid = '.1.3.6.1.4.1.8072.1.3.2.3.1.2.9.115.104.111.117.116.99.97.115.116'; +$oid = '.1.3.6.1.4.1.8072.1.3.2.3.1.2.9.115.104.111.117.116.99.97.115.116'; $shoutcast = snmp_get($device, $oid, $options); echo ' shoutcast'; $servers = explode("\n", $shoutcast); -$metrics = array(); +$metrics = []; foreach ($servers as $item => $server) { $server = trim($server); - if (!empty($server)) { + if (! empty($server)) { $data = explode(';', $server); - list($host, $port) = explode(':', $data['0'], 2); + [$host, $port] = explode(':', $data['0'], 2); - $rrd_name = array('app', $name, $app_id, $host . '_' . $port); + $rrd_name = ['app', $name, $app_id, $host . '_' . $port]; $rrd_def = RrdDefinition::make() ->addDataset('bitrate', 'GAUGE', 0, 125000000000) ->addDataset('traf_in', 'GAUGE', 0, 125000000000) @@ -34,7 +34,7 @@ foreach ($servers as $item => $server) { ->addDataset('max', 'GAUGE', 0, 125000000000) ->addDataset('unique', 'GAUGE', 0, 125000000000); - $fields = array( + $fields = [ 'bitrate' => $data['1'], 'traf_in' => $data['2'], 'traf_out' => $data['3'], @@ -43,7 +43,7 @@ foreach ($servers as $item => $server) { 'peak' => $data['6'], 'max' => $data['7'], 'unique' => $data['8'], - ); + ]; $metrics[$server] = $fields; $tags = compact('name', 'app_id', 'host', 'port', 'rrd_name', 'rrd_def'); diff --git a/includes/polling/applications/smart.inc.php b/includes/polling/applications/smart.inc.php index 23f76f9267..905d7881c6 100644 --- a/includes/polling/applications/smart.inc.php +++ b/includes/polling/applications/smart.inc.php @@ -2,18 +2,18 @@ use LibreNMS\RRD\RrdDefinition; -echo('SMART'); +echo 'SMART'; $name = 'smart'; $app_id = $app['app_id']; -$options = '-Oqv'; -$oid = '.1.3.6.1.4.1.8072.1.3.2.3.1.2.5.115.109.97.114.116'; +$options = '-Oqv'; +$oid = '.1.3.6.1.4.1.8072.1.3.2.3.1.2.5.115.109.97.114.116'; $output = snmp_walk($device, $oid, $options); $lines = explode("\n", $output); -$rrd_name = array('app', $name, $app_id); +$rrd_name = ['app', $name, $app_id]; $rrd_def = RrdDefinition::make() ->addDataset('id5', 'GAUGE', 0) ->addDataset('id10', 'GAUGE', 0) @@ -40,14 +40,14 @@ $rrd_def = RrdDefinition::make() ->addDataset('conveyance', 'GAUGE', 0) ->addDataset('selective', 'GAUGE', 0); -$int=0; -$metrics = array(); +$int = 0; +$metrics = []; while (isset($lines[$int])) { - list($disk, $id5, $id10, $id173, $id177, $id183, $id184, $id187, $id188, $id190, $id194, + [$disk, $id5, $id10, $id173, $id177, $id183, $id184, $id187, $id188, $id190, $id194, $id196, $id197, $id198, $id199, $id231, $id233, $completed, $interrupted, $read_failure, - $unknown_failure, $extended, $short, $conveyance, $selective)=explode(",", $lines[$int]); + $unknown_failure, $extended, $short, $conveyance, $selective] = explode(",", $lines[$int]); - $rrd_name = array('app', $name, $app_id, $disk); + $rrd_name = ['app', $name, $app_id, $disk]; $fields = [ 'id5' => is_numeric($id5) ? $id5 : null, @@ -73,32 +73,31 @@ while (isset($lines[$int])) { 'extended' => is_numeric($extended) ? $extended : null, 'short' => is_numeric($short) ? $short : null, 'conveyance' => is_numeric($conveyance) ? $conveyance : null, - 'selective' => is_numeric($selective) ? $selective : null + 'selective' => is_numeric($selective) ? $selective : null, ]; $metrics[$disk] = $fields; - $tags = array('name' => $name, 'app_id' => $app_id, 'rrd_def' => $rrd_def, 'rrd_name' => $rrd_name); + $tags = ['name' => $name, 'app_id' => $app_id, 'rrd_def' => $rrd_def, 'rrd_name' => $rrd_name]; data_update($device, 'app', $tags, $fields); $int++; } - -# smart enhancement id9 -$rrd_name = array('app', $name, $app_id); +// smart enhancement id9 +$rrd_name = ['app', $name, $app_id]; $rrd_def = RrdDefinition::make() ->addDataset('id9', 'GAUGE', 0); -$int=0; +$int = 0; while (isset($lines[$int])) { - list($disk, , , , , , , , , , , , , , , , , , , , , , , , , $id9)=explode(",", $lines[$int]); + [$disk, , , , , , , , , , , , , , , , , , , , , , , , , $id9] = explode(",", $lines[$int]); - $rrd_name = array('app', $name.'_id9', $app_id, $disk); + $rrd_name = ['app', $name . '_id9', $app_id, $disk]; $fields = ['id9' => $id9]; $metrics[$disk]['id9'] = $id9; - $tags = array('name' => $name, 'app_id' => $app_id, 'rrd_def' => $rrd_def, 'rrd_name' => $rrd_name); + $tags = ['name' => $name, 'app_id' => $app_id, 'rrd_def' => $rrd_def, 'rrd_name' => $rrd_name]; data_update($device, 'app', $tags, $fields); $int++; diff --git a/includes/polling/applications/squid.inc.php b/includes/polling/applications/squid.inc.php index 0383084b3d..6c052b801f 100644 --- a/includes/polling/applications/squid.inc.php +++ b/includes/polling/applications/squid.inc.php @@ -5,7 +5,7 @@ use LibreNMS\RRD\RrdDefinition; $name = 'squid'; $app_id = $app['app_id']; -$oids=array( +$oids = [ '.1.3.6.1.4.1.3495.1.2.5.1.0', '.1.3.6.1.4.1.3495.1.2.5.2.0', '.1.3.6.1.4.1.3495.1.2.5.3.0', @@ -43,9 +43,9 @@ $oids=array( '.1.3.6.1.4.1.3495.1.3.2.2.1.9.60', '.1.3.6.1.4.1.3495.1.3.2.2.1.10.1', '.1.3.6.1.4.1.3495.1.3.2.2.1.10.5', - '.1.3.6.1.4.1.3495.1.3.2.2.1.10.60' -); -$returnedoids=snmp_get_multi_oid($device, $oids); + '.1.3.6.1.4.1.3495.1.3.2.2.1.10.60', +]; +$returnedoids = snmp_get_multi_oid($device, $oids); $memmaxsize = $returnedoids['.1.3.6.1.4.1.3495.1.2.5.1.0']; $swapmaxsize = $returnedoids['.1.3.6.1.4.1.3495.1.2.5.2.0']; @@ -86,7 +86,7 @@ $requestbyteratio1 = $returnedoids['.1.3.6.1.4.1.3495.1.3.2.2.1.10.1']; $requestbyteratio5 = $returnedoids['.1.3.6.1.4.1.3495.1.3.2.2.1.10.5']; $requestbyteratio60 = $returnedoids['.1.3.6.1.4.1.3495.1.3.2.2.1.10.60']; -$rrd_name = array('app', $name, $app_id); +$rrd_name = ['app', $name, $app_id]; $rrd_def = RrdDefinition::make() ->addDataset('memmaxsize', 'GAUGE', 0) @@ -127,12 +127,12 @@ $rrd_def = RrdDefinition::make() ->addDataset('reqbyteratio5', 'GAUGE', 0) ->addDataset('reqbyteratio60', 'GAUGE', 0); -$memmaxsize=$memmaxsize*1000; -$swapmaxsize=$swapmaxsize*1000; -$swaphighwm=$swaphighwm*1000; -$swaplowwm=$swaplowwm*1000; +$memmaxsize = $memmaxsize * 1000; +$swapmaxsize = $swapmaxsize * 1000; +$swaphighwm = $swaphighwm * 1000; +$swaplowwm = $swaplowwm * 1000; -$fields = array( +$fields = [ "memmaxsize" => $memmaxsize, "swapmaxsize" => $swapmaxsize, "swaphighwm" => $swaphighwm, @@ -170,9 +170,9 @@ $fields = array( "reqbyteratio1" => $requestbyteratio1, "reqbyteratio5" => $requestbyteratio5, "reqbyteratio60" => $requestbyteratio60, -); +]; -$tags = array('name' => $name, 'app_id' => $app_id, 'rrd_def' => $rrd_def, 'rrd_name' => $rrd_name); +$tags = ['name' => $name, 'app_id' => $app_id, 'rrd_def' => $rrd_def, 'rrd_name' => $rrd_name]; data_update($device, 'app', $tags, $fields); $squid_app_status = ($returnedoids == false) ? false : 'Data ok'; diff --git a/includes/polling/applications/tinydns.inc.php b/includes/polling/applications/tinydns.inc.php index f2678a7a24..1505314f19 100644 --- a/includes/polling/applications/tinydns.inc.php +++ b/includes/polling/applications/tinydns.inc.php @@ -28,9 +28,9 @@ use LibreNMS\RRD\RrdDefinition; $name = 'tinydns'; $app_id = $app['app_id']; -if (!empty($agent_data['app'][$name]) && $app_id > 0) { +if (! empty($agent_data['app'][$name]) && $app_id > 0) { echo ' tinydns'; - $rrd_name = array('app', $name, $app_id); + $rrd_name = ['app', $name, $app_id]; $rrd_def = RrdDefinition::make() ->addDataset('a', 'COUNTER', 0, 125000000000) ->addDataset('ns', 'COUNTER', 0, 125000000000) @@ -53,12 +53,12 @@ if (!empty($agent_data['app'][$name]) && $app_id > 0) { ->addDataset('badclass', 'COUNTER', 0, 125000000000) ->addDataset('noquery', 'COUNTER', 0, 125000000000); - list( + [ $a, $ns, $cname, $soa, $ptr, $hinfo, $mx, $txt, $rp, $sig, $key, $aaaa, $axfr, $any, $total, $other, $notauth, $notimpl, $badclass, $noquery - ) = explode(':', $agent_data['app'][$name]); + ] = explode(':', $agent_data['app'][$name]); - $fields = array( + $fields = [ 'a' => $a, 'ns' => $ns, 'cname' => $cname, @@ -78,8 +78,8 @@ if (!empty($agent_data['app'][$name]) && $app_id > 0) { 'notauth' => $notauth, 'notimpl' => $notimpl, 'badclass' => $badclass, - 'noquery' => $noquery - ); + 'noquery' => $noquery, + ]; $tags = compact('name', 'app_id', 'rrd_name', 'rrd_def'); data_update($device, 'app', $tags, $fields); diff --git a/includes/polling/applications/unbound.inc.php b/includes/polling/applications/unbound.inc.php index 7039fec1f3..8639a7e5f7 100644 --- a/includes/polling/applications/unbound.inc.php +++ b/includes/polling/applications/unbound.inc.php @@ -4,23 +4,23 @@ use LibreNMS\RRD\RrdDefinition; $name = 'unbound'; $app_id = $app['app_id']; -if (!empty($agent_data['app'][$name])) { +if (! empty($agent_data['app'][$name])) { $rawdata = $agent_data['app'][$name]; } else { $options = '-Oqv'; - $oid = '.1.3.6.1.4.1.8072.1.3.2.3.1.2.7.117.110.98.111.117.110.100'; - $rawdata = snmp_get($device, $oid, $options); + $oid = '.1.3.6.1.4.1.8072.1.3.2.3.1.2.7.117.110.98.111.117.110.100'; + $rawdata = snmp_get($device, $oid, $options); } -#Format Data +//Format Data $lines = explode("\n", $rawdata); -$unbound = array(); -$metrics = array(); +$unbound = []; +$metrics = []; foreach ($lines as $line) { - list($var,$value) = explode('=', $line); + [$var,$value] = explode('=', $line); $unbound[$var] = $value; } -#Unbound Queries -$rrd_name = array('app', $name,'queries',$app_id); +//Unbound Queries +$rrd_name = ['app', $name, 'queries', $app_id]; $rrd_def = RrdDefinition::make() ->addDataset('type0', 'DERIVE', 0, 125000000000) ->addDataset('A', 'DERIVE', 0, 125000000000) @@ -40,7 +40,7 @@ $rrd_def = RrdDefinition::make() ->addDataset('SPF', 'DERIVE', 0, 125000000000) ->addDataset('ANY', 'DERIVE', 0, 125000000000) ->addDataset('other', 'DERIVE', 0, 125000000000); -$fields = array ( +$fields = [ 'type0' => $unbound['num.query.type.TYPE0'], 'a' => $unbound['num.query.type.A'], 'ns' => $unbound['num.query.type.NS'], @@ -58,66 +58,66 @@ $fields = array ( 'dnskey' => $unbound['num.query.type.DNSKEY'], 'spf' => $unbound['num.query.type.SPF'], 'any' => $unbound['num.query.type.ANY'], - 'other' => $unbound['num.query.type.other'] - ); + 'other' => $unbound['num.query.type.other'], +]; $metrics['queries'] = $fields; $tags = compact('name', 'app_id', 'rrd_name', 'rrd_def'); data_update($device, 'app', $tags, $fields); -#Unbound Cache -$rrd_name = array('app', $name,'cache',$app_id); +//Unbound Cache +$rrd_name = ['app', $name, 'cache', $app_id]; $rrd_def = RrdDefinition::make() ->addDataset('queries', 'DERIVE', 0, 125000000000) ->addDataset('hits', 'DERIVE', 0, 125000000000) ->addDataset('misses', 'DERIVE', 0, 125000000000); -$fields = array ( +$fields = [ 'queries' => $unbound['total.num.queries'], 'hits' => $unbound['total.num.cachehits'], - 'misses' => $unbound['total.num.cachemiss'] - ); + 'misses' => $unbound['total.num.cachemiss'], +]; $metrics['cache'] = $fields; $tags = compact('name', 'app_id', 'rrd_name', 'rrd_def'); data_update($device, 'app', $tags, $fields); -#Unbound Operations - Total opcodes and three valuable return codes -$rrd_name = array('app', $name,'operations',$app_id); +//Unbound Operations - Total opcodes and three valuable return codes +$rrd_name = ['app', $name, 'operations', $app_id]; $rrd_def = RrdDefinition::make() ->addDataset('opcodeQuery', 'DERIVE', 0, 125000000000) ->addDataset('rcodeNOERROR', 'DERIVE', 0, 125000000000) ->addDataset('rcodeNXDOMAIN', 'DERIVE', 0, 125000000000) ->addDataset('rcodeNodata', 'DERIVE', 0, 125000000000); -$fields = array ( +$fields = [ 'opcodeQuery' => $unbound['num.query.opcode.QUERY'], 'rcodeNOERROR' => $unbound['num.answer.rcode.NOERROR'], 'rcodeNXDOMAIN' => $unbound['num.answer.rcode.NXDOMAIN'], - 'rcodeNodata' => $unbound['num.answer.rcode.nodata'] - ); + 'rcodeNodata' => $unbound['num.answer.rcode.nodata'], +]; $metrics['operations'] = $fields; $tags = compact('name', 'app_id', 'rrd_name', 'rrd_def'); data_update($device, 'app', $tags, $fields); - -#Unbound requestlist -$rrd_name = array('app', $name,'requestlist',$app_id); + +//Unbound requestlist +$rrd_name = ['app', $name, 'requestlist', $app_id]; $rrd_def = RrdDefinition::make() ->addDataset('max', 'DERIVE', 0, 125000000000) ->addDataset('overwritten', 'DERIVE', 0, 125000000000) ->addDataset('exceeded', 'DERIVE', 0, 125000000000); -$fields = array ( +$fields = [ 'max' => $unbound['total.requestlist.max'], 'overwritten' => $unbound['total.requestlist.overwritten'], - 'exceeded' => $unbound['total.requestlist.exceeded'] - ); + 'exceeded' => $unbound['total.requestlist.exceeded'], +]; $metrics['requestlist'] = $fields; $tags = compact('name', 'app_id', 'rrd_name', 'rrd_def'); data_update($device, 'app', $tags, $fields); -#Unbound recursiontime -$rrd_name = array('app', $name,'recursiontime',$app_id); +//Unbound recursiontime +$rrd_name = ['app', $name, 'recursiontime', $app_id]; $rrd_def = RrdDefinition::make() ->addDataset('avg', 'GAUGE', 0, 125000000000) ->addDataset('median', 'GAUGE', 0, 125000000000); -$fields = array ( +$fields = [ 'avg' => $unbound['total.recursion.time.avg'], - 'median' => $unbound['total.recursion.time.median'] - ); + 'median' => $unbound['total.recursion.time.median'], +]; $metrics['recursiontime'] = $fields; $tags = compact('name', 'app_id', 'rrd_name', 'rrd_def'); data_update($device, 'app', $tags, $fields); diff --git a/includes/polling/applications/ups-apcups.inc.php b/includes/polling/applications/ups-apcups.inc.php index 1d272239bd..3b4c23552e 100644 --- a/includes/polling/applications/ups-apcups.inc.php +++ b/includes/polling/applications/ups-apcups.inc.php @@ -19,42 +19,43 @@ * @author Cercel Valentin */ -use LibreNMS\Exceptions\JsonAppParsingFailedException; use LibreNMS\Exceptions\JsonAppException; +use LibreNMS\Exceptions\JsonAppParsingFailedException; use LibreNMS\RRD\RrdDefinition; //NET-SNMP-EXTEND-MIB::nsExtendOutputFull."ups-apcups" $name = 'ups-apcups'; $app_id = $app['app_id']; -echo ' '.$name; +echo ' ' . $name; try { - $json_return=json_app_get($device, $name); + $json_return = json_app_get($device, $name); } catch (JsonAppParsingFailedException $e) { // Legacy script, build compatible array $legacy = trim($e->getOutput()); // pull apart the legacy info and create the basic required hash with it - list ($line_volt, $load, $charge, $remaining, $bat_volt, $line_nominal, $bat_nominal) = explode("\n", $legacy); - $json_return=array( - 'data' => array( + [$line_volt, $load, $charge, $remaining, $bat_volt, $line_nominal, $bat_nominal] = explode("\n", $legacy); + $json_return = [ + 'data' => [ 'charge' => $charge, 'time_remaining' => $remaining, 'battery_nominal' => $bat_nominal, 'battery_voltage' => $bat_volt, 'input_voltage' => $line_volt, 'nominal_voltage' => $line_nominal, - 'load' => $load - ) - ); + 'load' => $load, + ], + ]; } catch (JsonAppException $e) { - echo PHP_EOL . $name . ':' .$e->getCode().':'. $e->getMessage() . PHP_EOL; - update_application($app, $e->getCode().':'.$e->getMessage(), []); // Set empty metrics and error message + echo PHP_EOL . $name . ':' . $e->getCode() . ':' . $e->getMessage() . PHP_EOL; + update_application($app, $e->getCode() . ':' . $e->getMessage(), []); // Set empty metrics and error message + return; } -$rrd_name = array('app', $name, $app_id); +$rrd_name = ['app', $name, $app_id]; $rrd_def = RrdDefinition::make() ->addDataset('charge', 'GAUGE', 0, 100) ->addDataset('time_remaining', 'GAUGE', 0) @@ -64,15 +65,15 @@ $rrd_def = RrdDefinition::make() ->addDataset('nominal_voltage', 'GAUGE', 0) ->addDataset('load', 'GAUGE', 0, 100); -$fields = array( - 'charge' => $json_return['data']['charge'], - 'time_remaining' => $json_return['data']['time_remaining'], - 'battery_nominal' => $json_return['data']['battery_nominal'], - 'battery_voltage' => $json_return['data']['battery_voltage'], - 'input_voltage' => $json_return['data']['input_voltage'], - 'nominal_voltage' => $json_return['data']['nominal_voltage'], - 'load' => $json_return['data']['load'], - ); +$fields = [ + 'charge' => $json_return['data']['charge'], + 'time_remaining' => $json_return['data']['time_remaining'], + 'battery_nominal' => $json_return['data']['battery_nominal'], + 'battery_voltage' => $json_return['data']['battery_voltage'], + 'input_voltage' => $json_return['data']['input_voltage'], + 'nominal_voltage' => $json_return['data']['nominal_voltage'], + 'load' => $json_return['data']['load'], +]; $tags = compact('name', 'app_id', 'rrd_name', 'rrd_def'); data_update($device, 'app', $tags, $fields); diff --git a/includes/polling/applications/ups-nut.inc.php b/includes/polling/applications/ups-nut.inc.php index 3a4e3e25ca..9f9c492ff1 100644 --- a/includes/polling/applications/ups-nut.inc.php +++ b/includes/polling/applications/ups-nut.inc.php @@ -33,17 +33,17 @@ $ups_nut = snmp_get($device, $oid, '-Oqv'); // If "extend" (used above) fails, try "exec" support. // Note, exec always splits outputs on newline, so need to use snmp_walk (not a single SNMP entry!) -if (!$ups_nut) { +if (! $ups_nut) { // Data is in an array, due to how "exec" works with ups-nut.sh output, so snmp_walk to retrieve it $oid = '.1.3.6.1.4.1.2021.7890.2.101'; - $ups_nut=snmp_walk($device, $oid, '-Oqv'); + $ups_nut = snmp_walk($device, $oid, '-Oqv'); } //print_r(array_values(explode("\n", $ups_nut))); -echo ' '.$name; +echo ' ' . $name; // (2020-05-13, Jon.W) Added ups status data and updated ups-nut.sh script. -list ( +[ $charge, $battery_low, $remaining, @@ -66,9 +66,9 @@ list ( $UPSUPSBuck, $UPSUPSBoost, $UPSForcedShutdown - ) = explode("\n", $ups_nut); + ] = explode("\n", $ups_nut); -$rrd_name = array('app', $name, $app_id); +$rrd_name = ['app', $name, $app_id]; $rrd_def = RrdDefinition::make() ->addDataset('charge', 'GAUGE', 0, 100) ->addDataset('battery_low', 'GAUGE', 0, 100) @@ -79,37 +79,37 @@ $rrd_def = RrdDefinition::make() ->addDataset('input_voltage', 'GAUGE', 0) ->addDataset('load', 'GAUGE', 0, 100); -$fields = array( +$fields = [ 'charge' => $charge, 'battery_low' => $battery_low, - 'time_remaining' => $remaining/60, + 'time_remaining' => $remaining / 60, 'battery_voltage' => $bat_volt, 'battery_nominal' => $bat_nom, 'line_nominal' => $line_nom, 'input_voltage' => $input_volt, - 'load' => $load -); + 'load' => $load, +]; $sensors = [ - ['state_name' => 'UPSOnLine' , 'value' => $UPSOnLine], - ['state_name' => 'UPSOnBattery' , 'value' => $UPSOnBattery], - ['state_name' => 'UPSLowBattery' , 'value' => $UPSLowBattery], - ['state_name' => 'UPSHighBattery' , 'value' => $UPSHighBattery], - ['state_name' => 'UPSBatteryReplace' , 'value' => $UPSBatteryReplace], - ['state_name' => 'UPSBatteryCharging' , 'value' => $UPSBatteryCharging], + ['state_name' => 'UPSOnLine', 'value' => $UPSOnLine], + ['state_name' => 'UPSOnBattery', 'value' => $UPSOnBattery], + ['state_name' => 'UPSLowBattery', 'value' => $UPSLowBattery], + ['state_name' => 'UPSHighBattery', 'value' => $UPSHighBattery], + ['state_name' => 'UPSBatteryReplace', 'value' => $UPSBatteryReplace], + ['state_name' => 'UPSBatteryCharging', 'value' => $UPSBatteryCharging], ['state_name' => 'UPSBatteryDischarging', 'value' => $UPSBatteryDischarging], - ['state_name' => 'UPSUPSBypass' , 'value' => $UPSUPSBypass], + ['state_name' => 'UPSUPSBypass', 'value' => $UPSUPSBypass], ['state_name' => 'UPSRuntimeCalibration', 'value' => $UPSRuntimeCalibration], - ['state_name' => 'UPSOffline' , 'value' => $UPSOffline], - ['state_name' => 'UPSUPSOverloaded' , 'value' => $UPSUPSOverloaded], - ['state_name' => 'UPSUPSBuck' , 'value' => $UPSUPSBuck], - ['state_name' => 'UPSUPSBoost' , 'value' => $UPSUPSBoost], - ['state_name' => 'UPSForcedShutdown' , 'value' => $UPSForcedShutdown] + ['state_name' => 'UPSOffline', 'value' => $UPSOffline], + ['state_name' => 'UPSUPSOverloaded', 'value' => $UPSUPSOverloaded], + ['state_name' => 'UPSUPSBuck', 'value' => $UPSUPSBuck], + ['state_name' => 'UPSUPSBoost', 'value' => $UPSUPSBoost], + ['state_name' => 'UPSForcedShutdown', 'value' => $UPSForcedShutdown], ]; foreach ($sensors as $index => $sensor) { $rrd_def->addDataset($sensor['state_name'], 'GAUGE', 0); - $fields[$sensor['state_name']]= $sensor['value']; + $fields[$sensor['state_name']] = $sensor['value']; } $tags = compact('name', 'app_id', 'rrd_name', 'rrd_def'); diff --git a/includes/polling/applications/voip-monitor.inc.php b/includes/polling/applications/voip-monitor.inc.php index abdaefad97..425d91b7ca 100644 --- a/includes/polling/applications/voip-monitor.inc.php +++ b/includes/polling/applications/voip-monitor.inc.php @@ -7,7 +7,7 @@ $app_id = $app['app_id']; echo "$name, app_id=$app_id "; -if (!empty($agent_data[$name])) { +if (! empty($agent_data[$name])) { $rawdata = $agent_data[$name]; } else { $options = '-Oqv'; @@ -17,30 +17,30 @@ if (!empty($agent_data[$name])) { $rawdata = snmp_get($device, $oid, $options, $mib); } -# Format Data +// Format Data $lines = explode("\n", $rawdata); -$voip = array(); +$voip = []; foreach ($lines as $line) { - list($var,$value) = explode('=', $line); + [$var,$value] = explode('=', $line); $voip[$var] = $value; } unset($lines); -$rrd_name = array('app', $name, $app_id); +$rrd_name = ['app', $name, $app_id]; $rrd_def = RrdDefinition::make() ->addDataset('cpu', 'GAUGE', 0, 100) ->addDataset('kbyte', 'GAUGE', 0, 125000000000) ->addDataset('openfiles', 'GAUGE', 0, 125000000000); -$fields = array( - 'cpu' => (float)$voip['CPU Load'], - 'kbyte' => (int)$voip['Used Memory'], - 'openfiles' => (int)$voip['Open files'] -); +$fields = [ + 'cpu' => (float) $voip['CPU Load'], + 'kbyte' => (int) $voip['Used Memory'], + 'openfiles' => (int) $voip['Open files'], +]; $tags = compact('name', 'app_id', 'rrd_name', 'rrd_def'); diff --git a/includes/polling/applications/zfs.inc.php b/includes/polling/applications/zfs.inc.php index 6b5b4e4be2..84725d0c90 100644 --- a/includes/polling/applications/zfs.inc.php +++ b/includes/polling/applications/zfs.inc.php @@ -1,7 +1,7 @@ getParsedJson(); } catch (JsonAppException $e) { - echo PHP_EOL . $name . ':' .$e->getCode().':'. $e->getMessage() . PHP_EOL; - update_application($app, $e->getCode().':'.$e->getMessage(), []); // Set empty metrics and error message + echo PHP_EOL . $name . ':' . $e->getCode() . ':' . $e->getMessage() . PHP_EOL; + update_application($app, $e->getCode() . ':' . $e->getMessage(), []); // Set empty metrics and error message + return; } @@ -180,22 +181,22 @@ foreach ($zfs['pools'] as $pool) { // // component processing for ZFS // -$device_id=$device['device_id']; -$options= [ +$device_id = $device['device_id']; +$options = [ 'filter' => [ 'device_id' => ['=', $device_id], 'type' => ['=', 'zfs'], ], ]; -$component=new LibreNMS\Component(); -$components=$component->getComponents($device_id, $options); +$component = new LibreNMS\Component(); +$components = $component->getComponents($device_id, $options); // if no pools, delete zfs components if (empty($pools)) { if (isset($components[$device_id])) { foreach ($components[$device_id] as $component_id => $_unused) { - $component->deleteComponent($component_id); + $component->deleteComponent($component_id); } } } else { diff --git a/includes/polling/aruba-controller.inc.php b/includes/polling/aruba-controller.inc.php index 8c4df13301..bb28fdef4b 100644 --- a/includes/polling/aruba-controller.inc.php +++ b/includes/polling/aruba-controller.inc.php @@ -7,27 +7,25 @@ if ($device['type'] == 'wireless' && $device['os'] == 'arubaos') { // Build SNMP Cache Array // stuff about the controller - $switch_info_oids = array( + $switch_info_oids = [ 'wlsxSwitchRole', 'wlsxSwitchMasterIp', - ); - $switch_counter_oids = array( + ]; + $switch_counter_oids = [ 'wlsxSwitchTotalNumAccessPoints.0', 'wlsxSwitchTotalNumStationsAssociated.0', - ); + ]; - - $switch_apinfo_oids = array( + $switch_apinfo_oids = [ 'wlsxWlanRadioEntry', 'wlanAPChInterferenceIndex', - ); - $switch_apname_oids = array('wlsxWlanRadioEntry.16'); - + ]; + $switch_apname_oids = ['wlsxWlanRadioEntry.16']; // initialize arrays to avoid overwriting them in foreach loops below - $aruba_stats = array(); - $aruba_apstats = array(); - $aruba_apnames = array(); + $aruba_stats = []; + $aruba_apstats = []; + $aruba_apnames = []; $aruba_oids = array_merge($switch_info_oids, $switch_counter_oids); echo 'Caching Oids: '; @@ -46,7 +44,6 @@ if ($device['type'] == 'wireless' && $device['os'] == 'arubaos') { $aruba_apnames = snmpwalk_cache_numerical_oid($device, $oid, $aruba_apnames, 'WLSX-WLAN-MIB'); } - echo "\n"; $rrd_name = 'aruba-controller'; @@ -54,50 +51,48 @@ if ($device['type'] == 'wireless' && $device['os'] == 'arubaos') { ->addDataset('NUMAPS', 'GAUGE', 0, 12500000000) ->addDataset('NUMCLIENTS', 'GAUGE', 0, 12500000000); - $fields = array( + $fields = [ 'NUMAPS' => $aruba_stats[0]['wlsxSwitchTotalNumAccessPoints'], 'NUMCLIENTS' => $aruba_stats[0]['wlsxSwitchTotalNumStationsAssociated'], - ); + ]; $tags = compact('rrd_name', 'rrd_def'); data_update($device, 'aruba-controller', $tags, $fields); - - $ap_db = dbFetchRows('SELECT * FROM `access_points` WHERE `device_id` = ?', array($device['device_id'])); - + $ap_db = dbFetchRows('SELECT * FROM `access_points` WHERE `device_id` = ?', [$device['device_id']]); foreach ($aruba_apnames as $key1 => $value1) { foreach ($value1 as $key => $value) { - $radioid = str_replace('.1.3.6.1.4.1.14823.2.2.1.5.2.1.5.1.16.', '', $key); - $name = $value; - $type = $aruba_apstats[$key1][".1.3.6.1.4.1.14823.2.2.1.5.2.1.5.1.2.$radioid"]; - $channel = ($aruba_apstats[$key1][".1.3.6.1.4.1.14823.2.2.1.5.2.1.5.1.3.$radioid"] + 0); - $txpow = ($aruba_apstats[$key1][".1.3.6.1.4.1.14823.2.2.1.5.2.1.5.1.4.$radioid"] + 0)/2; - $radioutil = ($aruba_apstats[$key1][".1.3.6.1.4.1.14823.2.2.1.5.2.1.5.1.6.$radioid"] + 0); + $radioid = str_replace('.1.3.6.1.4.1.14823.2.2.1.5.2.1.5.1.16.', '', $key); + $name = $value; + $type = $aruba_apstats[$key1][".1.3.6.1.4.1.14823.2.2.1.5.2.1.5.1.2.$radioid"]; + $channel = ($aruba_apstats[$key1][".1.3.6.1.4.1.14823.2.2.1.5.2.1.5.1.3.$radioid"] + 0); + $txpow = ($aruba_apstats[$key1][".1.3.6.1.4.1.14823.2.2.1.5.2.1.5.1.4.$radioid"] + 0) / 2; + $radioutil = ($aruba_apstats[$key1][".1.3.6.1.4.1.14823.2.2.1.5.2.1.5.1.6.$radioid"] + 0); $numasoclients = ($aruba_apstats[$key1][".1.3.6.1.4.1.14823.2.2.1.5.2.1.5.1.7.$radioid"] + 0); $nummonclients = ($aruba_apstats[$key1][".1.3.6.1.4.1.14823.2.2.1.5.2.1.5.1.8.$radioid"] + 0); - $numactbssid = ($aruba_apstats[$key1][".1.3.6.1.4.1.14823.2.2.1.5.2.1.5.1.9.$radioid"] + 0); - $nummonbssid = ($aruba_apstats[$key1][".1.3.6.1.4.1.14823.2.2.1.5.2.1.5.1.10.$radioid"] + 0); - $interference = ($aruba_apstats[$key1][".1.3.6.1.4.1.14823.2.2.1.5.3.1.6.1.11.$radioid"] + 0); + $numactbssid = ($aruba_apstats[$key1][".1.3.6.1.4.1.14823.2.2.1.5.2.1.5.1.9.$radioid"] + 0); + $nummonbssid = ($aruba_apstats[$key1][".1.3.6.1.4.1.14823.2.2.1.5.2.1.5.1.10.$radioid"] + 0); + $interference = ($aruba_apstats[$key1][".1.3.6.1.4.1.14823.2.2.1.5.3.1.6.1.11.$radioid"] + 0); $radionum = substr($radioid, (strlen($radioid) - 1), 1); - d_echo($key.PHP_EOL); - d_echo($value.PHP_EOL); - d_echo('* radioid: '.$radioid.PHP_EOL); - d_echo(' radionum: '.$radionum.PHP_EOL); - d_echo(' name: '.$name.PHP_EOL); - d_echo(' type: '.$type.PHP_EOL); - d_echo(' channel: '.$channel.PHP_EOL); - d_echo(' txpow: '.$txpow.PHP_EOL); - d_echo(' radioutil: '.$radioutil.PHP_EOL); - d_echo(' numasoclients: '.$numasoclients.PHP_EOL); - d_echo(' interference: '.$interference.PHP_EOL); + d_echo($key . PHP_EOL); + d_echo($value . PHP_EOL); + d_echo('* radioid: ' . $radioid . PHP_EOL); + d_echo(' radionum: ' . $radionum . PHP_EOL); + d_echo(' name: ' . $name . PHP_EOL); + d_echo(' type: ' . $type . PHP_EOL); + d_echo(' channel: ' . $channel . PHP_EOL); + d_echo(' txpow: ' . $txpow . PHP_EOL); + d_echo(' radioutil: ' . $radioutil . PHP_EOL); + d_echo(' numasoclients: ' . $numasoclients . PHP_EOL); + d_echo(' interference: ' . $interference . PHP_EOL); d_echo(PHP_EOL); // if there is a numeric channel, assume the rest of the data is valid, I guess if (is_numeric($channel)) { - $rrd_name = array('arubaap', $name.$radionum); + $rrd_name = ['arubaap', $name . $radionum]; $rrd_def = RrdDefinition::make() ->addDataset('channel', 'GAUGE', 0, 200) @@ -108,7 +103,7 @@ if ($device['type'] == 'wireless' && $device['os'] == 'arubaos') { ->addDataset('numasoclients', 'GAUGE', 0, 500) ->addDataset('interference', 'GAUGE', 0, 2000); - $fields = array( + $fields = [ 'channel' => $channel, 'txpow' => $txpow, 'radioutil' => $radioutil, @@ -116,43 +111,40 @@ if ($device['type'] == 'wireless' && $device['os'] == 'arubaos') { 'nummonbssid' => $nummonbssid, 'numasoclients' => $numasoclients, 'interference' => $interference, - ); + ]; - $tags = array( + $tags = [ 'name' => $name, 'radionum' => $radionum, 'rrd_name' => $rrd_name, - 'rrd_def' => $rrd_def - ); + 'rrd_def' => $rrd_def, + ]; data_update($device, 'aruba', $tags, $fields); } // generate the mac address $macparts = explode('.', $radioid, -1); - $mac = ''; + $mac = ''; foreach ($macparts as $part) { - $mac .= sprintf('%02x', $part).':'; + $mac .= sprintf('%02x', $part) . ':'; } $mac = rtrim($mac, ':'); - $foundid = 0; for ($z = 0; $z < sizeof($ap_db); $z++) { if ($ap_db[$z]['name'] == $name && $ap_db[$z]['radio_number'] == $radionum) { - $foundid = $ap_db[$z]['accesspoint_id']; + $foundid = $ap_db[$z]['accesspoint_id']; $ap_db[$z]['seen'] = 1; continue; } } - - if ($foundid == 0) { $ap_id = dbInsert( - array( + [ 'channel' => $channel, 'deleted' => 0, 'device_id' => $device['device_id'], @@ -166,13 +158,13 @@ if ($device['type'] == 'wireless' && $device['os'] == 'arubaos') { 'radio_number' => $radionum, 'radioutil' => $radioutil, 'txpow' => $txpow, - 'type' => $type - ), + 'type' => $type, + ], 'access_points' ); } else { dbUpdate( - array( + [ 'channel' => $channel, 'deleted' => 0, 'interference' => $interference, @@ -185,11 +177,11 @@ if ($device['type'] == 'wireless' && $device['os'] == 'arubaos') { 'radio_number' => $radionum, 'radioutil' => $radioutil, 'txpow' => $txpow, - 'type' => $type - ), + 'type' => $type, + ], 'access_points', '`accesspoint_id` = ?', - array($foundid) + [$foundid] ); } }//end foreach @@ -197,8 +189,8 @@ if ($device['type'] == 'wireless' && $device['os'] == 'arubaos') { // mark APs which are not on this controller anymore as deleted for ($z = 0; $z < sizeof($ap_db); $z++) { - if (!isset($ap_db[$z]['seen']) && $ap_db[$z]['deleted'] == 0) { - dbUpdate(array('deleted' => 1), 'access_points', '`accesspoint_id` = ?', array($ap_db[$z]['accesspoint_id'])); + if (! isset($ap_db[$z]['seen']) && $ap_db[$z]['deleted'] == 0) { + dbUpdate(['deleted' => 1], 'access_points', '`accesspoint_id` = ?', [$ap_db[$z]['accesspoint_id']]); } } }//end if diff --git a/includes/polling/availability.inc.php b/includes/polling/availability.inc.php index 62967a0724..8625bc59d2 100644 --- a/includes/polling/availability.inc.php +++ b/includes/polling/availability.inc.php @@ -5,40 +5,40 @@ use LibreNMS\RRD\RrdDefinition; $os->enableGraph('availability'); -$col = dbFetchColumn('SELECT duration FROM availability WHERE device_id = ?', array($device['device_id'])); +$col = dbFetchColumn('SELECT duration FROM availability WHERE device_id = ?', [$device['device_id']]); foreach (Config::get('graphing.availability') as $duration) { - if (!in_array($duration, $col)) { + if (! in_array($duration, $col)) { $data = ['device_id' => $device['device_id'], - 'duration' => $duration]; + 'duration' => $duration, ]; dbInsert($data, 'availability'); } } echo 'Availability: ' . PHP_EOL; -foreach (dbFetchRows('SELECT * FROM availability WHERE device_id = ?', array($device['device_id'])) as $row) { +foreach (dbFetchRows('SELECT * FROM availability WHERE device_id = ?', [$device['device_id']]) as $row) { //delete not more interested availabilities - if (!in_array($row['duration'], Config::get('graphing.availability'))) { - dbDelete('availability', 'availability_id=?', array($row['availability_id'])); + if (! in_array($row['duration'], Config::get('graphing.availability'))) { + dbDelete('availability', 'availability_id=?', [$row['availability_id']]); continue; } $avail = \LibreNMS\Device\Availability::availability($device, $row['duration']); $human_time = \LibreNMS\Util\Time::humanTime($row['duration']); - $rrd_name = array('availability', $row['duration']); + $rrd_name = ['availability', $row['duration']]; $rrd_def = RrdDefinition::make() ->addDataset('availability', 'GAUGE', 0); - $fields = array( - 'availability' => $avail, - ); + $fields = [ + 'availability' => $avail, + ]; - $tags = array('name' => $row['duration'], 'rrd_def' => $rrd_def, 'rrd_name' => $rrd_name); - data_update($device, 'availability', $tags, $fields); + $tags = ['name' => $row['duration'], 'rrd_def' => $rrd_def, 'rrd_name' => $rrd_name]; + data_update($device, 'availability', $tags, $fields); - dbUpdate(array('availability_perc' => $avail), 'availability', '`availability_id` = ?', array($row['availability_id'])); + dbUpdate(['availability_perc' => $avail], 'availability', '`availability_id` = ?', [$row['availability_id']]); - echo $human_time . ' : ' . $avail . '%'. PHP_EOL; + echo $human_time . ' : ' . $avail . '%' . PHP_EOL; } unset($duration); diff --git a/includes/polling/bgp-peers.inc.php b/includes/polling/bgp-peers.inc.php index 56bdbb3fb4..41c6a34632 100644 --- a/includes/polling/bgp-peers.inc.php +++ b/includes/polling/bgp-peers.inc.php @@ -6,19 +6,19 @@ use LibreNMS\RRD\RrdDefinition; use LibreNMS\Util\IP; if (\LibreNMS\Config::get('enable_bgp')) { - $peers = dbFetchRows('SELECT * FROM `bgpPeers` AS B LEFT JOIN `vrfs` AS V ON `B`.`vrf_id` = `V`.`vrf_id` WHERE `B`.`device_id` = ?', array($device['device_id'])); + $peers = dbFetchRows('SELECT * FROM `bgpPeers` AS B LEFT JOIN `vrfs` AS V ON `B`.`vrf_id` = `V`.`vrf_id` WHERE `B`.`device_id` = ?', [$device['device_id']]); - if (!empty($peers)) { + if (! empty($peers)) { if ($device['os'] == 'junos') { $peer_data_check = snmpwalk_cache_long_oid($device, 'jnxBgpM2PeerIndex', '.1.3.6.1.4.1.2636.5.1.1.2.1.1.1.14', $peer_data_tmp, 'BGP4-V2-MIB-JUNIPER', 'junos'); } elseif ($device['os_group'] === 'arista') { - $peer_data_check = snmpwalk_cache_oid($device, 'aristaBgp4V2PeerRemoteAs', array(), 'ARISTA-BGP4V2-MIB'); + $peer_data_check = snmpwalk_cache_oid($device, 'aristaBgp4V2PeerRemoteAs', [], 'ARISTA-BGP4V2-MIB'); } elseif ($device['os'] === 'timos') { $peer_data_check = snmpwalk_cache_multi_oid($device, 'tBgpInstanceRowStatus', [], 'TIMETRA-BGP-MIB', 'nokia'); } elseif ($device['os'] === 'vrp') { $peer_data_check = snmpwalk_cache_multi_oid($device, 'hwBgpPeerEntry', [], 'HUAWEI-BGP-VPN-MIB', 'huawei'); } else { - $peer_data_check = snmpwalk_cache_oid($device, 'cbgpPeer2RemoteAs', array(), 'CISCO-BGP4-MIB'); + $peer_data_check = snmpwalk_cache_oid($device, 'cbgpPeer2RemoteAs', [], 'CISCO-BGP4-MIB'); } foreach ($peers as $peer) { @@ -35,7 +35,7 @@ if (\LibreNMS\Config::get('enable_bgp')) { // --- Collect BGP data --- if (count($peer_data_check) > 0) { if ($device['os'] == 'junos') { - if (!isset($junos)) { + if (! isset($junos)) { echo "\nCaching Oids..."; foreach ($peer_data_check as $hash => $index) { @@ -43,7 +43,7 @@ if (\LibreNMS\Config::get('enable_bgp')) { $exploded_ip = explode('.', $peer_ip_snmp); if (count($exploded_ip) > 11) { // ipv6 - $tmp_peer_ip = (string)IP::parse(snmp2ipv6($peer_ip_snmp), true); + $tmp_peer_ip = (string) IP::parse(snmp2ipv6($peer_ip_snmp), true); } else { // ipv4 $tmp_peer_ip = implode('.', array_slice($exploded_ip, -4)); @@ -53,7 +53,7 @@ if (\LibreNMS\Config::get('enable_bgp')) { } } - if (!isset($peer_data_tmp)) { + if (! isset($peer_data_tmp)) { $peer_data_tmp = snmpwalk_cache_long_oid($device, 'jnxBgpM2PeerState', '.1.3.6.1.4.1.2636.5.1.1.2.1.1.1.2', $peer_data_tmp, 'BGP4-V2-MIB-JUNIPER', 'junos'); $peer_data_tmp = snmpwalk_cache_long_oid($device, 'jnxBgpM2PeerStatus', '.1.3.6.1.4.1.2636.5.1.1.2.1.1.1.3', $peer_data_tmp, 'BGP4-V2-MIB-JUNIPER', 'junos'); $peer_data_tmp = snmpwalk_cache_long_oid($device, 'jnxBgpM2PeerInUpdates', '.1.3.6.1.4.1.2636.5.1.1.2.6.1.1.1', $peer_data_tmp, 'BGP4-V2-MIB-JUNIPER', 'junos'); @@ -69,7 +69,7 @@ if (\LibreNMS\Config::get('enable_bgp')) { d_echo($peer_data_tmp); } - $peer_hash = $junos[(string)$peer_ip]['hash']; + $peer_hash = $junos[(string) $peer_ip]['hash']; $peer_data = []; $peer_data['bgpPeerState'] = $peer_data_tmp[$peer_hash]['jnxBgpM2PeerState']; $peer_data['bgpPeerAdminStatus'] = $peer_data_tmp[$peer_hash]['jnxBgpM2PeerStatus']; @@ -92,7 +92,7 @@ if (\LibreNMS\Config::get('enable_bgp')) { d_echo("State = {$peer_data['bgpPeerState']} - AdminStatus: {$peer_data['bgpPeerAdminStatus']}\n"); } elseif ($device['os'] == 'vrp') { echo "\nCaching Oids VRP..."; - if (!isset($bgpPeers)) { + if (! isset($bgpPeers)) { //if not available, we timeout each time, to be fixed when split $bgpPeersCache = snmpwalk_cache_oid($device, 'hwBgpPeerEntry', [], 'HUAWEI-BGP-VPN-MIB', 'huawei'); $bgpPeersStats = snmpwalk_cache_oid($device, 'hwBgpPeerStatisticTable', [], 'HUAWEI-BGP-VPN-MIB', 'huawei', '-OQUbs'); @@ -107,7 +107,7 @@ if (\LibreNMS\Config::get('enable_bgp')) { if (strlen($address) > 15) { $address = IP::fromHexString($address)->compressed(); } - if (!isset($bgpPeers[$address][$vrfInstance])) { + if (! isset($bgpPeers[$address][$vrfInstance])) { $bgpPeers[$address][$vrfInstance] = []; } $bgpPeers[$address][$vrfInstance] = array_merge($bgpPeers[$address][$vrfInstance], $value); @@ -128,10 +128,10 @@ if (\LibreNMS\Config::get('enable_bgp')) { //d_echo($bgpPeersStats); } //d_echo($bgpPeers); - $address = (string)$peer_ip; + $address = (string) $peer_ip; $bgpPeer = $bgpPeers[$address]; $peer_data = []; - if (count(array_keys($bgpPeer))==1) { // We have only one vrf with a peer with this IP + if (count(array_keys($bgpPeer)) == 1) { // We have only one vrf with a peer with this IP $vrfInstance = array_keys($bgpPeer)[0]; $peer_data['bgpPeerState'] = $bgpPeers[$address][$vrfInstance]['hwBgpPeerState']; $peer_data['bgpPeerInUpdates'] = $bgpPeers[$address][$vrfInstance]['hwBgpPeerInUpdateMsgs']; @@ -165,21 +165,21 @@ if (\LibreNMS\Config::get('enable_bgp')) { $peer_data['bgpPeerLastErrorSubCode'] = intval($error_data[1]); unset($peer_data['bgpPeerLastError']); } elseif ($device['os'] == 'timos') { - if (!isset($bgpPeers)) { + if (! isset($bgpPeers)) { echo "\nCaching Oids..."; $bgpPeersCache = snmpwalk_cache_multi_oid($device, 'tBgpPeerNgTable', [], 'TIMETRA-BGP-MIB', 'nokia'); $bgpPeersCache = snmpwalk_cache_multi_oid($device, 'tBgpPeerNgOperEntry', $bgpPeersCache, 'TIMETRA-BGP-MIB', 'nokia'); foreach ($bgpPeersCache as $key => $value) { $oid = explode(".", $key); $vrfInstance = $oid[0]; - $address = str_replace($oid[0].".".$oid[1].".", '', $key); + $address = str_replace($oid[0] . "." . $oid[1] . ".", '', $key); if (strlen($address) > 15) { $address = IP::fromHexString($address)->compressed(); } $bgpPeers[$vrfInstance][$address] = $value; } } - $address = (string)$peer_ip; + $address = (string) $peer_ip; $tmpTime = $bgpPeers[$vrfOid][$address]['tBgpPeerNgLastChanged']; $tmpTime = explode(".", $tmpTime); $tmpTime = explode(":", $tmpTime[0]); @@ -195,7 +195,7 @@ if (\LibreNMS\Config::get('enable_bgp')) { $peer_data['bgpPeerInTotalMessages'] = $bgpPeers[$vrfOid][$address]['tBgpPeerNgOperMsgOctetsRcvd']; // That are actually only octets available, $peer_data['bgpPeerOutTotalMessages'] = $bgpPeers[$vrfOid][$address]['tBgpPeerNgOperMsgOctetsSent']; // not messages $peer_data['bgpPeerFsmEstablishedTime'] = $establishedTime; - // ToDo, It seems that bgpPeer(In|Out)Updates, bgpPeerInUpdateElapsedTime and bgpLocalAddr are actually not available over SNMP + // ToDo, It seems that bgpPeer(In|Out)Updates, bgpPeerInUpdateElapsedTime and bgpLocalAddr are actually not available over SNMP } else { $bgp_peer_ident = $peer_ip->toSnmpIndex(); $ip_ver = $peer_ip->getFamily(); @@ -224,7 +224,7 @@ if (\LibreNMS\Config::get('enable_bgp')) { 'aristaBgp4V2PeerLastErrorCodeReceived' => 'bgpPeerLastErrorCode', 'aristaBgp4V2PeerLastErrorSubCodeReceived' => 'bgpPeerLastErrorSubCode', 'aristaBgp4V2PeerLastErrorReceivedText' => 'bgpPeerLastErrorText', - ]; + ]; } else { $peer_identifier = $ip_type . '.' . $ip_len . '.' . $bgp_peer_ident; $mib = 'CISCO-BGP4-MIB'; @@ -270,7 +270,7 @@ if (\LibreNMS\Config::get('enable_bgp')) { $peer_data_raw = snmp_get_multi($device, $get_oids, '-OQUs', $mib); $peer_data_raw = reset($peer_data_raw); // get the first element of the array - $peer_data = array(); + $peer_data = []; foreach ($oid_map as $source => $target) { $v = isset($peer_data_raw[$source]) ? $peer_data_raw[$source] : ''; @@ -302,23 +302,23 @@ if (\LibreNMS\Config::get('enable_bgp')) { // --- Send event log notices --- if ($peer_data['bgpPeerFsmEstablishedTime']) { - if (!(is_array(\LibreNMS\Config::get('alerts.bgp.whitelist')) - && !in_array($peer['bgpPeerRemoteAs'], \LibreNMS\Config::get('alerts.bgp.whitelist'))) + if (! (is_array(\LibreNMS\Config::get('alerts.bgp.whitelist')) + && ! in_array($peer['bgpPeerRemoteAs'], \LibreNMS\Config::get('alerts.bgp.whitelist'))) && ($peer_data['bgpPeerFsmEstablishedTime'] < $peer['bgpPeerFsmEstablishedTime'] || $peer_data['bgpPeerState'] != $peer['bgpPeerState']) ) { if ($peer['bgpPeerState'] == $peer_data['bgpPeerState']) { - log_event('BGP Session Flap: ' . $peer['bgpPeerIdentifier'] . ' (AS' . $peer['bgpPeerRemoteAs'] . '), last error: '. describe_bgp_error_code($peer['bgpPeerLastErrorCode'], $peer['bgpPeerLastErrorSubCode']), $device, 'bgpPeer', 4, $peer_ip); + log_event('BGP Session Flap: ' . $peer['bgpPeerIdentifier'] . ' (AS' . $peer['bgpPeerRemoteAs'] . '), last error: ' . describe_bgp_error_code($peer['bgpPeerLastErrorCode'], $peer['bgpPeerLastErrorSubCode']), $device, 'bgpPeer', 4, $peer_ip); } elseif ($peer_data['bgpPeerState'] == 'established') { log_event('BGP Session Up: ' . $peer['bgpPeerIdentifier'] . ' (AS' . $peer['bgpPeerRemoteAs'] . ')', $device, 'bgpPeer', 1, $peer_ip); } elseif ($peer['bgpPeerState'] == 'established') { - log_event('BGP Session Down: ' . $peer['bgpPeerIdentifier'] . ' (AS' . $peer['bgpPeerRemoteAs'] . '), last error: '. describe_bgp_error_code($peer['bgpPeerLastErrorCode'], $peer['bgpPeerLastErrorSubCode']), $device, 'bgpPeer', 5, $peer_ip); + log_event('BGP Session Down: ' . $peer['bgpPeerIdentifier'] . ' (AS' . $peer['bgpPeerRemoteAs'] . '), last error: ' . describe_bgp_error_code($peer['bgpPeerLastErrorCode'], $peer['bgpPeerLastErrorSubCode']), $device, 'bgpPeer', 5, $peer_ip); } } } // --- Update rrd data --- - $peer_rrd_name = safename('bgp-'.$peer['bgpPeerIdentifier']); + $peer_rrd_name = safename('bgp-' . $peer['bgpPeerIdentifier']); $peer_rrd_def = RrdDefinition::make() ->addDataset('bgpPeerOutUpdates', 'COUNTER', null, 100000000000) ->addDataset('bgpPeerInUpdates', 'COUNTER', null, 100000000000) @@ -341,7 +341,7 @@ if (\LibreNMS\Config::get('enable_bgp')) { $tags = [ 'bgpPeerIdentifier' => $peer['bgpPeerIdentifier'], 'rrd_name' => $peer_rrd_name, - 'rrd_def' => $peer_rrd_def + 'rrd_def' => $peer_rrd_def, ]; data_update($device, 'bgp', $tags, $fields); @@ -351,18 +351,18 @@ if (\LibreNMS\Config::get('enable_bgp')) { if ($peer['update']) { if ($vrfId) { - dbUpdate($peer['update'], 'bgpPeers', '`device_id` = ? AND `bgpPeerIdentifier` = ? AND `vrf_id` = ?', array($device['device_id'], $peer['bgpPeerIdentifier'], $vrfId)); + dbUpdate($peer['update'], 'bgpPeers', '`device_id` = ? AND `bgpPeerIdentifier` = ? AND `vrf_id` = ?', [$device['device_id'], $peer['bgpPeerIdentifier'], $vrfId]); } else { - dbUpdate($peer['update'], 'bgpPeers', '`device_id` = ? AND `bgpPeerIdentifier` = ?', array($device['device_id'], $peer['bgpPeerIdentifier'])); + dbUpdate($peer['update'], 'bgpPeers', '`device_id` = ? AND `bgpPeerIdentifier` = ?', [$device['device_id'], $peer['bgpPeerIdentifier']]); } } // --- Populate cbgp data --- if ($device['os_group'] == 'vrp' || $device['os_group'] == 'cisco' || $device['os'] == 'junos' || $device['os_group'] === 'arista') { // Poll each AFI/SAFI for this peer (using CISCO-BGP4-MIB or BGP4-V2-JUNIPER MIB) - $peer_afis = dbFetchRows('SELECT * FROM bgpPeers_cbgp WHERE `device_id` = ? AND bgpPeerIdentifier = ?', array($device['device_id'], $peer['bgpPeerIdentifier'])); + $peer_afis = dbFetchRows('SELECT * FROM bgpPeers_cbgp WHERE `device_id` = ? AND bgpPeerIdentifier = ?', [$device['device_id'], $peer['bgpPeerIdentifier']]); foreach ($peer_afis as $peer_afi) { - $afi = $peer_afi['afi']; + $afi = $peer_afi['afi']; $safi = $peer_afi['safi']; d_echo("$afi $safi\n"); @@ -372,10 +372,10 @@ if (\LibreNMS\Config::get('enable_bgp')) { $ip_ver = $peer_ip->getFamily(); if ($ip_ver == 'ipv6') { $ip_type = 2; - $ip_len = 16; + $ip_len = 16; } else { $ip_type = 1; - $ip_len = 4; + $ip_len = 4; } $ip_cast = 1; @@ -387,10 +387,10 @@ if (\LibreNMS\Config::get('enable_bgp')) { $ip_cast = 128; } - $check = snmp_get($device, 'cbgpPeer2AcceptedPrefixes.'.$ip_type.'.'.$ip_len.'.'.$bgp_peer_ident.'.'.$ip_type.'.'.$ip_cast, '', 'CISCO-BGP4-MIB'); + $check = snmp_get($device, 'cbgpPeer2AcceptedPrefixes.' . $ip_type . '.' . $ip_len . '.' . $bgp_peer_ident . '.' . $ip_type . '.' . $ip_cast, '', 'CISCO-BGP4-MIB'); - if (!empty($check)) { - $cgp_peer_identifier = $ip_type.'.'.$ip_len.'.'.$bgp_peer_ident.'.'.$ip_type.'.'.$ip_cast; + if (! empty($check)) { + $cgp_peer_identifier = $ip_type . '.' . $ip_len . '.' . $bgp_peer_ident . '.' . $ip_type . '.' . $ip_cast; $cbgp2_oids = [ 'cbgpPeer2AcceptedPrefixes.' . $cgp_peer_identifier, 'cbgpPeer2DeniedPrefixes.' . $cgp_peer_identifier, @@ -402,7 +402,7 @@ if (\LibreNMS\Config::get('enable_bgp')) { 'cbgpPeer2WithdrawnPrefixes.' . $cgp_peer_identifier, ]; $cbgp_data_tmp = snmp_get_multi($device, $cbgp2_oids, '-OQUs', 'CISCO-BGP4-MIB'); - $ident = "$ip_ver.\"".$peer['bgpPeerIdentifier'].'"'.'.'.$ip_type.'.'.$ip_cast; + $ident = "$ip_ver.\"" . $peer['bgpPeerIdentifier'] . '"' . '.' . $ip_type . '.' . $ip_cast; $key = key($cbgp_data_tmp); // get key of item $cbgp_data = [ @@ -444,37 +444,37 @@ if (\LibreNMS\Config::get('enable_bgp')) { }//end if if ($device['os'] == 'junos') { - $afis['ipv4'] = 1; - $afis['ipv6'] = 2; - $afis['l2vpn'] = 25; - $safis['unicast'] = 1; - $safis['multicast'] = 2; + $afis['ipv4'] = 1; + $afis['ipv6'] = 2; + $afis['l2vpn'] = 25; + $safis['unicast'] = 1; + $safis['multicast'] = 2; $safis['unicastAndMulticast'] = 3; - $safis['labeledUnicast'] = 4; - $safis['mvpn'] = 5; - $safis['vpls'] = 65; - $safis['evpn'] = 70; - $safis['vpn'] = 128; - $safis['rtfilter'] = 132; - $safis['flow'] = 133; + $safis['labeledUnicast'] = 4; + $safis['mvpn'] = 5; + $safis['vpls'] = 65; + $safis['evpn'] = 70; + $safis['vpn'] = 128; + $safis['rtfilter'] = 132; + $safis['flow'] = 133; - if (!isset($j_prefixes)) { + if (! isset($j_prefixes)) { $j_prefixes = snmpwalk_cache_multi_oid($device, 'jnxBgpM2PrefixInPrefixesAccepted', $j_prefixes, 'BGP4-V2-MIB-JUNIPER', 'junos', '-OQnU'); $j_prefixes = snmpwalk_cache_multi_oid($device, 'jnxBgpM2PrefixInPrefixesRejected', $j_prefixes, 'BGP4-V2-MIB-JUNIPER', 'junos', '-OQnU'); $j_prefixes = snmpwalk_cache_multi_oid($device, 'jnxBgpM2PrefixOutPrefixes', $j_prefixes, 'BGP4-V2-MIB-JUNIPER', 'junos', '-OQnU'); d_echo($j_prefixes); } - $cbgpPeerAcceptedPrefixes = array_shift($j_prefixes['1.3.6.1.4.1.2636.5.1.1.2.6.2.1.8.'.$junos[(string)$peer_ip]['index'].".$afis[$afi].".$safis[$safi]]); - $cbgpPeerDeniedPrefixes = array_shift($j_prefixes['1.3.6.1.4.1.2636.5.1.1.2.6.2.1.9.'.$junos[(string)$peer_ip]['index'].".$afis[$afi].".$safis[$safi]]); - $cbgpPeerAdvertisedPrefixes = array_shift($j_prefixes['1.3.6.1.4.1.2636.5.1.1.2.6.2.1.10.'.$junos[(string)$peer_ip]['index'].".$afis[$afi].".$safis[$safi]]); + $cbgpPeerAcceptedPrefixes = array_shift($j_prefixes['1.3.6.1.4.1.2636.5.1.1.2.6.2.1.8.' . $junos[(string) $peer_ip]['index'] . ".$afis[$afi]." . $safis[$safi]]); + $cbgpPeerDeniedPrefixes = array_shift($j_prefixes['1.3.6.1.4.1.2636.5.1.1.2.6.2.1.9.' . $junos[(string) $peer_ip]['index'] . ".$afis[$afi]." . $safis[$safi]]); + $cbgpPeerAdvertisedPrefixes = array_shift($j_prefixes['1.3.6.1.4.1.2636.5.1.1.2.6.2.1.10.' . $junos[(string) $peer_ip]['index'] . ".$afis[$afi]." . $safis[$safi]]); }//end if if ($device['os_group'] === 'arista') { - $safis['unicast'] = 1; + $safis['unicast'] = 1; $safis['multicast'] = 2; - $afis['ipv4'] = 1; - $afis['ipv6'] = 2; + $afis['ipv4'] = 1; + $afis['ipv6'] = 2; if (preg_match('/:/', $peer['bgpPeerIdentifier'])) { $tmp_peer = str_replace(':', '', $peer['bgpPeerIdentifier']); $tmp_peer = preg_replace('/([\w\d]{2})/', '\1:', $tmp_peer); @@ -495,28 +495,28 @@ if (\LibreNMS\Config::get('enable_bgp')) { // only works in global routing table, as the vpnInstanceId is not available // for now in the VRF discovery of VRP devices - $key4 = $vrfInstance.'.'.$afi.'.'.$safi.'.ipv4.'.$peer['bgpPeerIdentifier']; - $key6 = $vrfInstance.'.'.$afi.'.'.$safi.'.ipv6.'.$peer['bgpPeerIdentifier']; + $key4 = $vrfInstance . '.' . $afi . '.' . $safi . '.ipv4.' . $peer['bgpPeerIdentifier']; + $key6 = $vrfInstance . '.' . $afi . '.' . $safi . '.ipv6.' . $peer['bgpPeerIdentifier']; if (isset($vrpPrefixes[$key4])) { $cbgpPeerAcceptedPrefixes = $vrpPrefixes[$key4]['hwBgpPeerPrefixRcvCounter']; - $cbgpPeerAdvertisedPrefixes = $vrpPrefixes[$key4]['hwBgpPeerPrefixAdvCounter']; + $cbgpPeerAdvertisedPrefixes = $vrpPrefixes[$key4]['hwBgpPeerPrefixAdvCounter']; } if (isset($vrpPrefixes[$key6])) { $cbgpPeerAcceptedPrefixes = $vrpPrefixes[$key6]['hwBgpPeerPrefixRcvCounter']; - $cbgpPeerAdvertisedPrefixes = $vrpPrefixes[$key6]['hwBgpPeerPrefixAdvCounter']; + $cbgpPeerAdvertisedPrefixes = $vrpPrefixes[$key6]['hwBgpPeerPrefixAdvCounter']; } } // Validate data - $cbgpPeerAcceptedPrefixes = set_numeric($cbgpPeerAcceptedPrefixes); - $cbgpPeerDeniedPrefixes = set_numeric($cbgpPeerDeniedPrefixes); - $cbgpPeerPrefixAdminLimit = set_numeric($cbgpPeerPrefixAdminLimit); - $cbgpPeerPrefixThreshold = set_numeric($cbgpPeerPrefixThreshold); + $cbgpPeerAcceptedPrefixes = set_numeric($cbgpPeerAcceptedPrefixes); + $cbgpPeerDeniedPrefixes = set_numeric($cbgpPeerDeniedPrefixes); + $cbgpPeerPrefixAdminLimit = set_numeric($cbgpPeerPrefixAdminLimit); + $cbgpPeerPrefixThreshold = set_numeric($cbgpPeerPrefixThreshold); $cbgpPeerPrefixClearThreshold = set_numeric($cbgpPeerPrefixClearThreshold); - $cbgpPeerAdvertisedPrefixes = set_numeric($cbgpPeerAdvertisedPrefixes); - $cbgpPeerSuppressedPrefixes = set_numeric($cbgpPeerSuppressedPrefixes); - $cbgpPeerWithdrawnPrefixes = set_numeric($cbgpPeerWithdrawnPrefixes); + $cbgpPeerAdvertisedPrefixes = set_numeric($cbgpPeerAdvertisedPrefixes); + $cbgpPeerSuppressedPrefixes = set_numeric($cbgpPeerSuppressedPrefixes); + $cbgpPeerWithdrawnPrefixes = set_numeric($cbgpPeerWithdrawnPrefixes); $cbgpPeers_cbgp_fields = [ 'AcceptedPrefixes' => $cbgpPeerAcceptedPrefixes, @@ -544,7 +544,7 @@ if (\LibreNMS\Config::get('enable_bgp')) { ]; foreach ($oids as $oid) { - $tmp_prev = set_numeric($peer_afi[$oid]); + $tmp_prev = set_numeric($peer_afi[$oid]); $tmp_delta = $cbgpPeers_cbgp_fields[$oid] - $tmp_prev; if ($peer_afi[$oid . '_delta'] != $tmp_delta) { $peer['c_update'][$oid . '_delta'] = $tmp_delta; @@ -563,7 +563,7 @@ if (\LibreNMS\Config::get('enable_bgp')) { ); } - $cbgp_rrd_name = safename('cbgp-'.$peer['bgpPeerIdentifier'].".$afi.$safi"); + $cbgp_rrd_name = safename('cbgp-' . $peer['bgpPeerIdentifier'] . ".$afi.$safi"); $cbgp_rrd_def = RrdDefinition::make() ->addDataset('AcceptedPrefixes', 'GAUGE', null, 100000000000) ->addDataset('DeniedPrefixes', 'GAUGE', null, 100000000000) @@ -584,7 +584,7 @@ if (\LibreNMS\Config::get('enable_bgp')) { 'afi' => $afi, 'safi' => $safi, 'rrd_name' => $cbgp_rrd_name, - 'rrd_def' => $cbgp_rrd_def + 'rrd_def' => $cbgp_rrd_def, ]; data_update($device, 'cbgp', $tags, $fields); } //end foreach diff --git a/includes/polling/cipsec-tunnels.inc.php b/includes/polling/cipsec-tunnels.inc.php index eec247e8a2..843c61e5b4 100644 --- a/includes/polling/cipsec-tunnels.inc.php +++ b/includes/polling/cipsec-tunnels.inc.php @@ -3,22 +3,22 @@ use LibreNMS\RRD\RrdDefinition; if ($device['os_group'] == 'cisco') { -// FIXME - seems to be broken. IPs appear with leading zeroes. - $ipsec_array = snmpwalk_cache_oid($device, 'cipSecTunnelEntry', array(), 'CISCO-IPSEC-FLOW-MONITOR-MIB'); - if (!empty($ipsec_array)) { - $ike_array = snmpwalk_cache_oid($device, 'cikeTunnelEntry', array(), 'CISCO-IPSEC-FLOW-MONITOR-MIB'); + // FIXME - seems to be broken. IPs appear with leading zeroes. + $ipsec_array = snmpwalk_cache_oid($device, 'cipSecTunnelEntry', [], 'CISCO-IPSEC-FLOW-MONITOR-MIB'); + if (! empty($ipsec_array)) { + $ike_array = snmpwalk_cache_oid($device, 'cikeTunnelEntry', [], 'CISCO-IPSEC-FLOW-MONITOR-MIB'); } - $tunnels_db = dbFetchRows('SELECT * FROM `ipsec_tunnels` WHERE `device_id` = ?', array($device['device_id'])); + $tunnels_db = dbFetchRows('SELECT * FROM `ipsec_tunnels` WHERE `device_id` = ?', [$device['device_id']]); foreach ($tunnels_db as $tunnel) { if (empty($tunnel['peer_addr']) && empty($tunnel['local_addr'])) { - dbDelete('ipsec_tunnels', '`tunnel_id` = ?', array($tunnel['tunnel_id'])); + dbDelete('ipsec_tunnels', '`tunnel_id` = ?', [$tunnel['tunnel_id']]); } $tunnels[$tunnel['peer_addr']] = $tunnel; } - $valid_tunnels = array(); + $valid_tunnels = []; foreach ($ipsec_array as $index => $tunnel) { $tunnel = array_merge($tunnel, $ike_array[$tunnel['cipSecTunIkeTunnelIndex']]); @@ -29,7 +29,7 @@ if ($device['os_group'] == 'cisco') { $address = $tunnel['cikeTunRemoteValue']; - $oids = array( + $oids = [ 'cipSecTunInOctets', 'cipSecTunInDecompOctets', 'cipSecTunInPkts', @@ -47,33 +47,33 @@ if ($device['os_group'] == 'cisco') { 'cipSecTunOutAuthFails', 'cipSecTunOutEncrypts', 'cipSecTunOutEncryptFails', - ); + ]; - $db_oids = array( + $db_oids = [ 'cipSecTunStatus' => 'tunnel_status', 'cikeTunLocalName' => 'tunnel_name', 'cikeTunLocalValue' => 'local_addr', - ); + ]; - if (!is_array($tunnels[$tunnel['cikeTunRemoteValue']]) && !empty($tunnel['cikeTunRemoteValue'])) { - $tunnel_id = dbInsert(array( + if (! is_array($tunnels[$tunnel['cikeTunRemoteValue']]) && ! empty($tunnel['cikeTunRemoteValue'])) { + $tunnel_id = dbInsert([ 'device_id' => $device['device_id'], 'peer_addr' => $tunnel['cikeTunRemoteValue'], 'local_addr' => $tunnel['cikeTunLocalValue'], - 'tunnel_name' => $tunnel['cikeTunLocalName'] - ), 'ipsec_tunnels'); + 'tunnel_name' => $tunnel['cikeTunLocalName'], + ], 'ipsec_tunnels'); $valid_tunnels[] = $tunnel_id; } else { foreach ($db_oids as $db_oid => $db_value) { $db_update[$db_value] = $tunnel[$db_oid]; } - if (!empty($tunnels[$tunnel['cikeTunRemoteValue']]['tunnel_id'])) { + if (! empty($tunnels[$tunnel['cikeTunRemoteValue']]['tunnel_id'])) { $updated = dbUpdate( $db_update, 'ipsec_tunnels', '`tunnel_id` = ?', - array($tunnels[$tunnel['cikeTunRemoteValue']]['tunnel_id']) + [$tunnels[$tunnel['cikeTunRemoteValue']]['tunnel_id']] ); $valid_tunnels[] = $tunnels[$tunnel['cikeTunRemoteValue']]['tunnel_id']; } @@ -92,7 +92,7 @@ if ($device['os_group'] == 'cisco') { $tunnel['cipSecTunOutUncompOctets'] = $tunnel['cipSecTunHcOutUncompOctets']; } - $rrd_name = array('ipsectunnel', $address); + $rrd_name = ['ipsectunnel', $address]; $rrd_def = new RrdDefinition(); $rrd_def->disableNameChecking(); foreach ($oids as $oid) { @@ -100,7 +100,7 @@ if ($device['os_group'] == 'cisco') { $rrd_def->addDataset($oid_ds, 'COUNTER', null, 1000000000); } - $fields = array(); + $fields = []; foreach ($oids as $oid) { if (is_numeric($tunnel[$oid])) { @@ -119,7 +119,7 @@ if ($device['os_group'] == 'cisco') { } }//end foreach - if (!empty($valid_tunnels)) { + if (! empty($valid_tunnels)) { d_echo($valid_tunnels); dbDelete( 'ipsec_tunnels', diff --git a/includes/polling/cisco-ace-loadbalancer.inc.php b/includes/polling/cisco-ace-loadbalancer.inc.php index c0465ac900..6250d2d289 100644 --- a/includes/polling/cisco-ace-loadbalancer.inc.php +++ b/includes/polling/cisco-ace-loadbalancer.inc.php @@ -3,8 +3,8 @@ use LibreNMS\RRD\RrdDefinition; if ($device['os_group'] == 'cisco') { - $rserver_array = snmpwalk_cache_oid($device, 'cesServerFarmRserverTable', array(), 'CISCO-ENHANCED-SLB-MIB'); - $rserver_db = dbFetchRows('SELECT * FROM `loadbalancer_rservers` WHERE `device_id` = ?', array($device['device_id'])); + $rserver_array = snmpwalk_cache_oid($device, 'cesServerFarmRserverTable', [], 'CISCO-ENHANCED-SLB-MIB'); + $rserver_db = dbFetchRows('SELECT * FROM `loadbalancer_rservers` WHERE `device_id` = ?', [$device['device_id']]); foreach ($rserver_db as $serverfarm) { $serverfarms[$serverfarm['farm_id']] = $serverfarm; @@ -13,23 +13,23 @@ if ($device['os_group'] == 'cisco') { foreach ($rserver_array as $index => $serverfarm) { $farm_id = preg_replace('@\d+\."(.*?)"\.\d+@', '\\1', $index); - $oids = array( + $oids = [ 'cesServerFarmRserverTotalConns', 'cesServerFarmRserverCurrentConns', 'cesServerFarmRserverFailedConns', - ); + ]; - $db_oids = array( + $db_oids = [ $farm_id => 'farm_id', 'cesServerFarmRserverStateDescr' => 'StateDescr', - ); + ]; - if (!is_array($serverfarms[$farm_id])) { - $rserver_id = dbInsert(array( + if (! is_array($serverfarms[$farm_id])) { + $rserver_id = dbInsert([ 'device_id' => $device['device_id'], 'farm_id' => $farm_id, - 'StateDescr' => $serverfarm['cesServerFarmRserverStateDescr'] - ), 'loadbalancer_rservers'); + 'StateDescr' => $serverfarm['cesServerFarmRserverStateDescr'], + ], 'loadbalancer_rservers'); } else { foreach ($db_oids as $db_oid => $db_value) { $db_update[$db_value] = $serverfarm[$db_oid]; @@ -38,7 +38,7 @@ if ($device['os_group'] == 'cisco') { $updated = dbUpdate($db_update, 'loadbalancer_rservers', '`rserver_id` = ?', $serverfarm['cesServerFarmRserverFailedConns']['farm_id']); } - $rrd_name = array('rserver', $serverfarms[$farm_id]['rserver_id']); + $rrd_name = ['rserver', $serverfarms[$farm_id]['rserver_id']]; $rrd_def = new RrdDefinition(); foreach ($oids as $oid) { @@ -46,7 +46,7 @@ if ($device['os_group'] == 'cisco') { $rrd_def->addDataset($oid_ds, 'GAUGE', -1, 100000000); } - $fields = array(); + $fields = []; foreach ($oids as $oid) { if (is_numeric($serverfarm[$oid])) { diff --git a/includes/polling/cisco-ace-serverfarms.inc.php b/includes/polling/cisco-ace-serverfarms.inc.php index 096a027b07..38ea5aec0c 100644 --- a/includes/polling/cisco-ace-serverfarms.inc.php +++ b/includes/polling/cisco-ace-serverfarms.inc.php @@ -3,8 +3,8 @@ use LibreNMS\RRD\RrdDefinition; if ($device['os_group'] == 'cisco') { - $serverfarm_array = snmpwalk_cache_oid($device, 'slbVServerInfoTable', array(), 'CISCO-SLB-MIB'); - $serverfarm_db = dbFetchRows('SELECT * FROM `loadbalancer_vservers` WHERE `device_id` = ?', array($device['device_id'])); + $serverfarm_array = snmpwalk_cache_oid($device, 'slbVServerInfoTable', [], 'CISCO-SLB-MIB'); + $serverfarm_db = dbFetchRows('SELECT * FROM `loadbalancer_vservers` WHERE `device_id` = ?', [$device['device_id']]); foreach ($serverfarm_db as $vserver) { $classmaps[$vserver['classmap']] = $vserver; @@ -14,28 +14,28 @@ if ($device['os_group'] == 'cisco') { $classmap = str_replace('class-map-', '', $vserver['slbVServerClassMap']); $classmap_id = str_replace('9.', '', $index); - $oids = array( + $oids = [ 'slbVServerNumberOfConnections', 'slbVServerDroppedConnections', 'slbVServerClientPacketCounts', 'slbVServerClientByteCounts', 'slbVServerPacketCounts', 'slbVServerByteCounts', - ); + ]; - $db_oids = array( + $db_oids = [ $classmap_id => 'classmap_id', $classmap => 'classmap', 'slbVServerState' => 'serverstate', - ); + ]; - if (!is_array($classmaps[$classmap])) { - $classmap_in = dbInsert(array( + if (! is_array($classmaps[$classmap])) { + $classmap_in = dbInsert([ 'device_id' => $device['device_id'], 'classmap_id' => $classmap_id, 'classmap' => $classmap, - 'serverstate' => $vserver['slbVServerState'] - ), 'loadbalancer_vservers'); + 'serverstate' => $vserver['slbVServerState'], + ], 'loadbalancer_vservers'); } else { foreach ($db_oids as $db_oid => $db_value) { $db_update[$db_value] = $vserver[$db_oid]; @@ -44,14 +44,14 @@ if ($device['os_group'] == 'cisco') { $updated = dbUpdate($db_update, 'loadbalancer_vservers', '`classmap_id` = ?', $vserver['slbVServerState']['classmap']); } - $rrd_name = array('vserver', $classmap_id); + $rrd_name = ['vserver', $classmap_id]; $rrd_def = new RrdDefinition(); foreach ($oids as $oid) { $oid_ds = str_replace('slbVServer', '', $oid); $rrd_def->addDataset($oid_ds, 'COUNTER', null, 1000000000); } - $fields = array(); + $fields = []; foreach ($oids as $oid) { if (is_numeric($vserver[$oid])) { $value = $vserver[$oid]; diff --git a/includes/polling/cisco-asa-firewall.inc.php b/includes/polling/cisco-asa-firewall.inc.php index 3debcb8bbe..5b79dab3f4 100644 --- a/includes/polling/cisco-asa-firewall.inc.php +++ b/includes/polling/cisco-asa-firewall.inc.php @@ -14,17 +14,17 @@ use LibreNMS\RRD\RrdDefinition; -if ($device['os_group'] == 'cisco' && ( $device['os'] == 'asa' || $device['os'] == 'ftd' ) && $device['type'] == 'firewall') { - $oid_list = 'cfwConnectionStatValue.protoIp.currentInUse'; - $temp_data = snmpwalk_cache_double_oid($device, $oid_list, array(), 'CISCO-FIREWALL-MIB'); +if ($device['os_group'] == 'cisco' && ($device['os'] == 'asa' || $device['os'] == 'ftd') && $device['type'] == 'firewall') { + $oid_list = 'cfwConnectionStatValue.protoIp.currentInUse'; + $temp_data = snmpwalk_cache_double_oid($device, $oid_list, [], 'CISCO-FIREWALL-MIB'); foreach ($temp_data as $oid => $result) { - $oid = substr(strchr($oid, '.'), 1); + $oid = substr(strchr($oid, '.'), 1); $data[$oid]['data'] = $result['cfwConnectionStatValue']; - $asa_db = dbFetchCell('SELECT `ciscoASA_id` FROM `ciscoASA` WHERE `device_id` = ? AND `oid` = ?', array($device['device_id'], $oid)); - if (!is_numeric($asa_db)) { - $asa_db = dbInsert(array('device_id' => $device['device_id'], 'oid' => $oid, 'data' => $result['cfwConnectionStatValue']), 'ciscoASA'); + $asa_db = dbFetchCell('SELECT `ciscoASA_id` FROM `ciscoASA` WHERE `device_id` = ? AND `oid` = ?', [$device['device_id'], $oid]); + if (! is_numeric($asa_db)) { + $asa_db = dbInsert(['device_id' => $device['device_id'], 'oid' => $oid, 'data' => $result['cfwConnectionStatValue']], 'ciscoASA'); } else { - $asa_db = dbUpdate(array('data' => $result['cfwConnectionStatValue']), 'ciscoASA', 'device_id=?', array($device['device_id'])); + $asa_db = dbUpdate(['data' => $result['cfwConnectionStatValue']], 'ciscoASA', 'device_id=?', [$device['device_id']]); } $data[$oid]['db_id'] = $asa_db; @@ -32,9 +32,9 @@ if ($device['os_group'] == 'cisco' && ( $device['os'] == 'asa' || $device['os'] if ($data['currentInUse']) { $rrd_def = RrdDefinition::make()->addDataset('connections', 'GAUGE', 0); - $fields = array( + $fields = [ 'connections' => $data['currentInUse']['data'], - ); + ]; $tags = compact('rrd_def'); data_update($device, 'asa_conns', $tags, $fields); diff --git a/includes/polling/cisco-cbqos.inc.php b/includes/polling/cisco-cbqos.inc.php index 0c50fe914b..12f3f86051 100644 --- a/includes/polling/cisco-cbqos.inc.php +++ b/includes/polling/cisco-cbqos.inc.php @@ -17,9 +17,9 @@ if ($device['os_group'] == "cisco") { $tmp_module = 'Cisco-CBQOS'; $component = new LibreNMS\Component(); - $options['filter']['type'] = array('=',$tmp_module); - $options['filter']['disabled'] = array('=',0); - $options['filter']['ignore'] = array('=',0); + $options['filter']['type'] = ['=', $tmp_module]; + $options['filter']['disabled'] = ['=', 0]; + $options['filter']['ignore'] = ['=', 0]; $components = $component->getComponents($device['device_id'], $options); // We only care about our device id. @@ -40,7 +40,7 @@ if ($device['os_group'] == "cisco") { $ifIndex = $array['ifindex']; $spid = $array['sp-id']; $spobj = $array['sp-obj']; - $rrd_name = array('port', $ifIndex, 'cbqos', $spid, $spobj); + $rrd_name = ['port', $ifIndex, 'cbqos', $spid, $spobj]; $rrd_def = RrdDefinition::make() ->addDataset('postbits', 'COUNTER', 0) ->addDataset('bufferdrops', 'COUNTER', 0) @@ -50,24 +50,24 @@ if ($device['os_group'] == "cisco") { ->addDataset('droppkts', 'COUNTER', 0); // Let's print some debugging info. - d_echo("\n\nComponent: ".$key."\n"); - d_echo(" Class-Map: ".$array['label']."\n"); - d_echo(" SPID.SPOBJ: ".$array['sp-id'].".".$array['sp-obj']."\n"); - d_echo(" PostBytes: 1.3.6.1.4.1.9.9.166.1.15.1.1.10.".$array['sp-id'].".".$array['sp-obj']." = ".$tblcbQosClassMapStats['1.3.6.1.4.1.9.9.166.1.15.1.1.10'][$array['sp-id']][$array['sp-obj']]."\n"); - d_echo(" BufferDrops: 1.3.6.1.4.1.9.9.166.1.15.1.1.21.".$array['sp-id'].".".$array['sp-obj']." = ".$tblcbQosClassMapStats['1.3.6.1.4.1.9.9.166.1.15.1.1.21'][$array['sp-id']][$array['sp-obj']]."\n"); - d_echo(" QOSDrops: 1.3.6.1.4.1.9.9.166.1.15.1.1.17.".$array['sp-id'].".".$array['sp-obj']." = ".$tblcbQosClassMapStats['1.3.6.1.4.1.9.9.166.1.15.1.1.17'][$array['sp-id']][$array['sp-obj']]."\n"); - d_echo(" PreBytes: 1.3.6.1.4.1.9.9.166.1.15.1.1.6.".$array['sp-id'].".".$array['sp-obj']." = ".$tblcbQosClassMapStats['1.3.6.1.4.1.9.9.166.1.15.1.1.6'][$array['sp-id']][$array['sp-obj']]."\n"); - d_echo(" PrePkts: 1.3.6.1.4.1.9.9.166.1.15.1.1.3.".$array['sp-id'].".".$array['sp-obj']." = ".$tblcbQosClassMapStats['1.3.6.1.4.1.9.9.166.1.15.1.1.3'][$array['sp-id']][$array['sp-obj']]."\n"); - d_echo(" DropPkts: 1.3.6.1.4.1.9.9.166.1.15.1.1.14.".$array['sp-id'].".".$array['sp-obj']." = ".$tblcbQosClassMapStats['1.3.6.1.4.1.9.9.166.1.15.1.1.14'][$array['sp-id']][$array['sp-obj']]."\n"); + d_echo("\n\nComponent: " . $key . "\n"); + d_echo(" Class-Map: " . $array['label'] . "\n"); + d_echo(" SPID.SPOBJ: " . $array['sp-id'] . "." . $array['sp-obj'] . "\n"); + d_echo(" PostBytes: 1.3.6.1.4.1.9.9.166.1.15.1.1.10." . $array['sp-id'] . "." . $array['sp-obj'] . " = " . $tblcbQosClassMapStats['1.3.6.1.4.1.9.9.166.1.15.1.1.10'][$array['sp-id']][$array['sp-obj']] . "\n"); + d_echo(" BufferDrops: 1.3.6.1.4.1.9.9.166.1.15.1.1.21." . $array['sp-id'] . "." . $array['sp-obj'] . " = " . $tblcbQosClassMapStats['1.3.6.1.4.1.9.9.166.1.15.1.1.21'][$array['sp-id']][$array['sp-obj']] . "\n"); + d_echo(" QOSDrops: 1.3.6.1.4.1.9.9.166.1.15.1.1.17." . $array['sp-id'] . "." . $array['sp-obj'] . " = " . $tblcbQosClassMapStats['1.3.6.1.4.1.9.9.166.1.15.1.1.17'][$array['sp-id']][$array['sp-obj']] . "\n"); + d_echo(" PreBytes: 1.3.6.1.4.1.9.9.166.1.15.1.1.6." . $array['sp-id'] . "." . $array['sp-obj'] . " = " . $tblcbQosClassMapStats['1.3.6.1.4.1.9.9.166.1.15.1.1.6'][$array['sp-id']][$array['sp-obj']] . "\n"); + d_echo(" PrePkts: 1.3.6.1.4.1.9.9.166.1.15.1.1.3." . $array['sp-id'] . "." . $array['sp-obj'] . " = " . $tblcbQosClassMapStats['1.3.6.1.4.1.9.9.166.1.15.1.1.3'][$array['sp-id']][$array['sp-obj']] . "\n"); + d_echo(" DropPkts: 1.3.6.1.4.1.9.9.166.1.15.1.1.14." . $array['sp-id'] . "." . $array['sp-obj'] . " = " . $tblcbQosClassMapStats['1.3.6.1.4.1.9.9.166.1.15.1.1.14'][$array['sp-id']][$array['sp-obj']] . "\n"); - $fields = array( + $fields = [ 'postbits' => $tblcbQosClassMapStats['1.3.6.1.4.1.9.9.166.1.15.1.1.10'][$array['sp-id']][$array['sp-obj']], 'bufferdrops' => $tblcbQosClassMapStats['1.3.6.1.4.1.9.9.166.1.15.1.1.21'][$array['sp-id']][$array['sp-obj']], 'qosdrops' => $tblcbQosClassMapStats['1.3.6.1.4.1.9.9.166.1.15.1.1.17'][$array['sp-id']][$array['sp-obj']], 'prebits' => $tblcbQosClassMapStats['1.3.6.1.4.1.9.9.166.1.15.1.1.6'][$array['sp-id']][$array['sp-obj']], 'prepkts' => $tblcbQosClassMapStats['1.3.6.1.4.1.9.9.166.1.15.1.1.3'][$array['sp-id']][$array['sp-obj']], - 'droppkts' => $tblcbQosClassMapStats['1.3.6.1.4.1.9.9.166.1.15.1.1.14'][$array['sp-id']][$array['sp-obj']] - ); + 'droppkts' => $tblcbQosClassMapStats['1.3.6.1.4.1.9.9.166.1.15.1.1.14'][$array['sp-id']][$array['sp-obj']], + ]; $tags = compact('rrd_name', 'rrd_def', 'ifIndex', 'spid', 'spobj'); data_update($device, 'cbqos', $tags, $fields); diff --git a/includes/polling/cisco-cef.inc.php b/includes/polling/cisco-cef.inc.php index 677ec1b3c9..789a7b351b 100644 --- a/includes/polling/cisco-cef.inc.php +++ b/includes/polling/cisco-cef.inc.php @@ -3,22 +3,22 @@ use LibreNMS\RRD\RrdDefinition; if ($device['os_group'] == 'cisco') { - $cefs = array(); - $cefs = snmpwalk_cache_threepart_oid($device, 'CISCO-CEF-MIB::cefSwitchingStatsEntry', $cefs, 'CISCO-CEF-MIB'); + $cefs = []; + $cefs = snmpwalk_cache_threepart_oid($device, 'CISCO-CEF-MIB::cefSwitchingStatsEntry', $cefs, 'CISCO-CEF-MIB'); $polled = time(); - $cefs_query = dbFetchRows('SELECT * FROM `cef_switching` WHERE `device_id` = ?', array($device['device_id'])); + $cefs_query = dbFetchRows('SELECT * FROM `cef_switching` WHERE `device_id` = ?', [$device['device_id']]); foreach ($cefs_query as $ceftmp) { - $cef_id = $device['device_id'].'-'.$ceftmp['entPhysicalIndex'].'-'.$ceftmp['afi'].'-'.$ceftmp['cef_index']; + $cef_id = $device['device_id'] . '-' . $ceftmp['entPhysicalIndex'] . '-' . $ceftmp['afi'] . '-' . $ceftmp['cef_index']; $cefs_db[$cef_id] = $ceftmp['cef_switching_id']; } d_echo($cefs); if (is_array($cefs)) { - if (!is_array($entity_array)) { + if (! is_array($entity_array)) { echo 'Caching OIDs: '; - $entity_array = array(); + $entity_array = []; echo ' entPhysicalDescr'; $entity_array = snmpwalk_cache_multi_oid($device, 'entPhysicalDescr', $entity_array, 'ENTITY-MIB'); echo ' entPhysicalName'; @@ -28,26 +28,26 @@ if ($device['os_group'] == 'cisco') { } foreach ($cefs as $entity => $afis) { - $entity_name = $entity_array[$entity]['entPhysicalName'].' - '.$entity_array[$entity]['entPhysicalModelName']; + $entity_name = $entity_array[$entity]['entPhysicalName'] . ' - ' . $entity_array[$entity]['entPhysicalModelName']; echo "\n$entity $entity_name\n"; foreach ($afis as $afi => $paths) { echo " |- $afi\n"; foreach ($paths as $index => $cef_stat) { - echo ' | |-'.$index.': '.$cef_stat['cefSwitchingPath']; + echo ' | |-' . $index . ': ' . $cef_stat['cefSwitchingPath']; - $cef_id = $device['device_id'].'-'.$entity.'-'.$afi.'-'.$index; + $cef_id = $device['device_id'] . '-' . $entity . '-' . $afi . '-' . $index; // if (dbFetchCell("SELECT COUNT(*) FROM `cef_switching` WHERE `device_id` = ? AND `entPhysicalIndex` = ? AND `afi` = ? AND `cef_index` = ?", array($device['device_id'], $entity, $afi, $path)) != "1") - if (!isset($cefs_db[$cef_id])) { - dbInsert(array('device_id' => $device['device_id'], 'entPhysicalIndex' => $entity, 'afi' => $afi, 'cef_index' => $index, 'cef_path' => $cef_stat['cefSwitchingPath']), 'cef_switching'); + if (! isset($cefs_db[$cef_id])) { + dbInsert(['device_id' => $device['device_id'], 'entPhysicalIndex' => $entity, 'afi' => $afi, 'cef_index' => $index, 'cef_path' => $cef_stat['cefSwitchingPath']], 'cef_switching'); echo '+'; } unset($cefs_db[$cef_id]); - $cef_entry = dbFetchRow('SELECT * FROM `cef_switching` WHERE `device_id` = ? AND `entPhysicalIndex` = ? AND `afi` = ? AND `cef_index` = ?', array($device['device_id'], $entity, $afi, $index)); + $cef_entry = dbFetchRow('SELECT * FROM `cef_switching` WHERE `device_id` = ? AND `entPhysicalIndex` = ? AND `afi` = ? AND `cef_index` = ?', [$device['device_id'], $entity, $afi, $index]); - $rrd_name = array('cefswitching', $entity, $afi, $index); + $rrd_name = ['cefswitching', $entity, $afi, $index]; $rrd_def = RrdDefinition::make() ->addDataset('drop', 'DERIVE', 0, 1000000) ->addDataset('punt', 'DERIVE', 0, 1000000) @@ -67,22 +67,22 @@ if ($device['os_group'] == 'cisco') { } // FIXME -- memcached - $cef_stat['update']['drop'] = $cef_stat['cefSwitchingDrop']; - $cef_stat['update']['punt'] = $cef_stat['cefSwitchingPunt']; - $cef_stat['update']['punt2host'] = $cef_stat['cefSwitchingPunt2Host']; - $cef_stat['update']['drop_prev'] = $cef_entry['drop']; - $cef_stat['update']['punt_prev'] = $cef_entry['punt']; + $cef_stat['update']['drop'] = $cef_stat['cefSwitchingDrop']; + $cef_stat['update']['punt'] = $cef_stat['cefSwitchingPunt']; + $cef_stat['update']['punt2host'] = $cef_stat['cefSwitchingPunt2Host']; + $cef_stat['update']['drop_prev'] = $cef_entry['drop']; + $cef_stat['update']['punt_prev'] = $cef_entry['punt']; $cef_stat['update']['punt2host_prev'] = $cef_entry['punt2host']; - $cef_stat['update']['updated'] = $polled; - $cef_stat['update']['updated_prev'] = $cef_entry['updated']; + $cef_stat['update']['updated'] = $polled; + $cef_stat['update']['updated_prev'] = $cef_entry['updated']; - dbUpdate($cef_stat['update'], 'cef_switching', '`device_id` = ? AND `entPhysicalIndex` = ? AND `afi` = ? AND `cef_index` = ?', array($device['device_id'], $entity, $afi, $index)); + dbUpdate($cef_stat['update'], 'cef_switching', '`device_id` = ? AND `entPhysicalIndex` = ? AND `afi` = ? AND `cef_index` = ?', [$device['device_id'], $entity, $afi, $index]); - $fields = array( + $fields = [ 'drop' => $cef_stat['cefSwitchingDrop'], 'punt' => $cef_stat['cefSwitchingPunt'], 'hostpunt' => $cef_stat['cefSwitchingPunt2Host'], - ); + ]; $tags = compact('entity', 'afi', 'index', 'rrd_name', 'rrd_def'); data_update($device, 'cefswitching', $tags, $fields); @@ -96,8 +96,8 @@ if ($device['os_group'] == 'cisco') { // FIXME - need to delete old ones. FIXME REALLY. print_r($cefs_db); - foreach ((array)$cefs_db as $cef_switching_id) { - dbDelete('cef_switching', '`cef_switching_id` = ?', array($cef_switching_id)); + foreach ((array) $cefs_db as $cef_switching_id) { + dbDelete('cef_switching', '`cef_switching_id` = ?', [$cef_switching_id]); echo '-'; } diff --git a/includes/polling/cisco-ipsec-flow-monitor.inc.php b/includes/polling/cisco-ipsec-flow-monitor.inc.php index 2b5d1c5961..b1012e89e3 100644 --- a/includes/polling/cisco-ipsec-flow-monitor.inc.php +++ b/includes/polling/cisco-ipsec-flow-monitor.inc.php @@ -78,7 +78,7 @@ if ($device['os_group'] == 'cisco') { ->addDataset('NoSaFails', 'COUNTER', 0, 100000000000) ->addDataset('SysCapFails', 'COUNTER', 0, 100000000000); - $fields = array( + $fields = [ 'Tunnels' => $data['cipSecGlobalActiveTunnels'], 'InOctets' => $data['cipSecGlobalInOctets'], 'OutOctets' => $data['cipSecGlobalOutOctets'], @@ -100,7 +100,7 @@ if ($device['os_group'] == 'cisco') { 'ProtocolUseFails' => $data['cipSecGlobalProtocolUseFails'], 'NoSaFails' => $data['cipSecGlobalNoSaFails'], 'SysCapFails' => $data['cipSecGlobalSysCapFails'], - ); + ]; $tags = compact('rrd_def'); data_update($device, 'cipsec_flow', $tags, $fields); diff --git a/includes/polling/cisco-mac-accounting.inc.php b/includes/polling/cisco-mac-accounting.inc.php index 947a2dd23b..83c31bed7f 100644 --- a/includes/polling/cisco-mac-accounting.inc.php +++ b/includes/polling/cisco-mac-accounting.inc.php @@ -3,16 +3,16 @@ use LibreNMS\RRD\RrdDefinition; if ($device['os_group'] == 'cisco') { - $acc_rows = dbFetchRows('SELECT *, A.poll_time AS poll_time FROM `mac_accounting` as A, `ports` AS I where A.port_id = I.port_id AND I.device_id = ?', array($device['device_id'])); + $acc_rows = dbFetchRows('SELECT *, A.poll_time AS poll_time FROM `mac_accounting` as A, `ports` AS I where A.port_id = I.port_id AND I.device_id = ?', [$device['device_id']]); - if (!empty($acc_rows)) { - $cip_oids = array( + if (! empty($acc_rows)) { + $cip_oids = [ 'cipMacHCSwitchedBytes', 'cipMacHCSwitchedPkts', - ); - $cip_array = array(); + ]; + $cip_array = []; - foreach (array_merge($cip_oids, array('cipMacSwitchedBytes', 'cipMacSwitchedPkts')) as $oid) { + foreach (array_merge($cip_oids, ['cipMacSwitchedBytes', 'cipMacSwitchedPkts']) as $oid) { echo "$oid "; $cip_array = snmpwalk_cache_cip($device, $oid, $cip_array, 'CISCO-IP-STAT-MIB'); } @@ -20,19 +20,19 @@ if ($device['os_group'] == 'cisco') { // Normalize cip_array $cip_array = array_map(function ($entries) { return array_map(function ($entry) { - $new_entry = array(); - - foreach (array('Bytes', 'Pkts') as $unit) { - $returned_oid = (array_key_exists('cipMacHCSwitched'.$unit, $entry)) ? 'cipMacHCSwitched' : 'cipMacSwitched'; - $new_value = array(); - - foreach ($entry[$returned_oid.$unit] as $key => $value) { + $new_entry = []; + + foreach (['Bytes', 'Pkts'] as $unit) { + $returned_oid = (array_key_exists('cipMacHCSwitched' . $unit, $entry)) ? 'cipMacHCSwitched' : 'cipMacSwitched'; + $new_value = []; + + foreach ($entry[$returned_oid . $unit] as $key => $value) { $new_value[$key] = intval($value); } - - $new_entry['cipMacHCSwitched'.$unit] = $new_value; + + $new_entry['cipMacHCSwitched' . $unit] = $new_value; } - + return $new_entry; }, $entries); }, $cip_array); @@ -64,7 +64,7 @@ if ($device['os_group'] == 'cisco') { // Update metrics foreach ($cip_oids as $oid) { - foreach (array('input', 'output') as $dir) { + foreach (['input', 'output'] as $dir) { $oid_dir = $oid . '_' . $dir; $acc['update'][$oid_dir] = $this_ma[$oid][$dir]; $acc['update'][$oid_dir . '_prev'] = $acc[$oid_dir]; @@ -81,7 +81,7 @@ if ($device['os_group'] == 'cisco') { d_echo("\n" . $acc['hostname'] . ' ' . $acc['ifDescr'] . " $mac -> $b_in:$b_out:$p_in:$p_out "); - $rrd_name = array('cip', $ifIndex, $mac); + $rrd_name = ['cip', $ifIndex, $mac]; $rrd_def = RrdDefinition::make() ->addDataset('IN', 'COUNTER', 0, 12500000000) ->addDataset('OUT', 'COUNTER', 0, 12500000000) @@ -89,19 +89,19 @@ if ($device['os_group'] == 'cisco') { ->addDataset('POUT', 'COUNTER', 0, 12500000000); // FIXME - use memcached to make sure these values don't go backwards? - $fields = array( + $fields = [ 'IN' => $b_in, 'OUT' => $b_out, 'PIN' => $p_in, 'POUT' => $p_out, - ); + ]; $tags = compact('ifIndex', 'mac', 'rrd_name', 'rrd_def'); data_update($device, 'cip', $tags, $fields); if ($acc['update']) { // Do Updates - dbUpdate($acc['update'], 'mac_accounting', '`ma_id` = ?', array($acc['ma_id'])); + dbUpdate($acc['update'], 'mac_accounting', '`ma_id` = ?', [$acc['ma_id']]); } //end if }//end if }//end foreach diff --git a/includes/polling/cisco-otv.inc.php b/includes/polling/cisco-otv.inc.php index 719d474055..ba99079930 100644 --- a/includes/polling/cisco-otv.inc.php +++ b/includes/polling/cisco-otv.inc.php @@ -15,7 +15,7 @@ use LibreNMS\RRD\RrdDefinition; if ($device['os_group'] == "cisco") { // Define some error messages - $error_vpn = array(); + $error_vpn = []; $error_vpn[0] = "Other"; $error_vpn[1] = "Configuration changed"; $error_vpn[2] = "Control Group information is unavailable"; @@ -37,7 +37,7 @@ if ($device['os_group'] == "cisco") { $error_vpn[18] = "Changing device ID"; $error_vpn[19] = "Cleanup in progress"; - $error_aed = array(); + $error_aed = []; $error_aed[0] = "Other"; $error_aed[1] = "Overlay is Down"; $error_aed[2] = "Site ID is not configured"; @@ -50,7 +50,7 @@ if ($device['os_group'] == "cisco") { $error_aed[9] = "Overlay state down event in progress"; $error_aed[10] = "ISIS control group sync pending"; - $error_overlay = array(); + $error_overlay = []; $error_overlay[1] = "active"; $error_overlay[2] = "notInService"; $error_overlay[3] = "notReady"; @@ -61,8 +61,8 @@ if ($device['os_group'] == "cisco") { $tmp_module = 'Cisco-OTV'; $component = new LibreNMS\Component(); - $options['filter']['type'] = array('=',$tmp_module); - $options['filter']['disabled'] = array('=',0); + $options['filter']['type'] = ['=', $tmp_module]; + $options['filter']['disabled'] = ['=', 0]; $components = $component->getComponents($device['device_id'], $options); // We only care about our device id. @@ -77,12 +77,12 @@ if ($device['os_group'] == "cisco") { $tblVlanEdgeDevIsAed = snmpwalk_array_num($device, '.1.3.6.1.4.1.9.9.810.1.2.2.1.6', 2); // Let's create an array of each remote OTV endpoint and the count of MAC addresses that are reachable via. - $count_mac = array(); + $count_mac = []; foreach ($tblRouteNextHopAddr as $k => $v) { $count_mac[$v]++; } // Let's log some debugging - d_echo("\n\nMAC Addresses: ".print_r($count_mac, true)); + d_echo("\n\nMAC Addresses: " . print_r($count_mac, true)); // Loop through the components and extract the data. foreach ($components as $key => &$array) { @@ -91,15 +91,15 @@ if ($device['os_group'] == "cisco") { $message = false; $vpn_state = $tblOverlayEntry['1.3.6.1.4.1.9.9.810.1.2.1.1.3'][$array['index']]; if ($vpn_state != 2) { - $message .= "VPN Down: ".$error_vpn[$tblOverlayEntry['1.3.6.1.4.1.9.9.810.1.2.1.1.4'][$array['index']]]; + $message .= "VPN Down: " . $error_vpn[$tblOverlayEntry['1.3.6.1.4.1.9.9.810.1.2.1.1.4'][$array['index']]]; } $aed_state = $tblOverlayEntry['1.3.6.1.4.1.9.9.810.1.2.1.1.13'][$array['index']]; if ($aed_state == 2) { - $message .= "AED Down: ".$error_aed[$tblOverlayEntry['1.3.6.1.4.1.9.9.810.1.2.1.1.14'][$array['index']]]; + $message .= "AED Down: " . $error_aed[$tblOverlayEntry['1.3.6.1.4.1.9.9.810.1.2.1.1.14'][$array['index']]]; } $overlay_state = $tblOverlayEntry['1.3.6.1.4.1.9.9.810.1.2.1.1.23'][$array['index']]; if ($overlay_state == 2) { - $message .= "Overlay Down: ".$error_overlay[$tblOverlayEntry['1.3.6.1.4.1.9.9.810.1.2.1.1.24'][$array['index']]]; + $message .= "Overlay Down: " . $error_overlay[$tblOverlayEntry['1.3.6.1.4.1.9.9.810.1.2.1.1.24'][$array['index']]]; } // If we have set a message, we have an error, activate alert. @@ -120,30 +120,30 @@ if ($device['os_group'] == "cisco") { } // Let's log some debugging - d_echo("\n\nOverlay Component: ".$key."\n"); - d_echo(" Label: ".$array['label']."\n"); - d_echo(" Index: ".$array['index']."\n"); - d_echo(" Status: ".$array['status']."\n"); - d_echo(" Message: ".$array['error']."\n"); - d_echo(" VLAN Count: ".$count_vlan."\n"); + d_echo("\n\nOverlay Component: " . $key . "\n"); + d_echo(" Label: " . $array['label'] . "\n"); + d_echo(" Index: " . $array['index'] . "\n"); + d_echo(" Status: " . $array['status'] . "\n"); + d_echo(" Message: " . $array['error'] . "\n"); + d_echo(" VLAN Count: " . $count_vlan . "\n"); $label = $array['label']; - $rrd_name = array('cisco', 'otv', $label, 'vlan'); + $rrd_name = ['cisco', 'otv', $label, 'vlan']; $rrd_def = RrdDefinition::make()->addDataset('count', 'GAUGE', 0); - $fields = array( - 'count' => $count_vlan - ); + $fields = [ + 'count' => $count_vlan, + ]; $tags = compact('label', 'rrd_name', 'rrd_def'); data_update($device, 'cisco-otv-vlan', $tags, $fields); } elseif ($array['otvtype'] == 'adjacency') { - $array['uptime'] = $tblAdjacencyDatabaseEntry['1.3.6.1.4.1.9.9.810.1.3.1.1.6.'.$array['index'].'.1.4.'.$array['endpoint']]; + $array['uptime'] = $tblAdjacencyDatabaseEntry['1.3.6.1.4.1.9.9.810.1.3.1.1.6.' . $array['index'] . '.1.4.' . $array['endpoint']]; $message = false; - if ($tblAdjacencyDatabaseEntry['1.3.6.1.4.1.9.9.810.1.3.1.1.5.'.$array['index'].'.1.4.'.$array['endpoint']] != 1) { + if ($tblAdjacencyDatabaseEntry['1.3.6.1.4.1.9.9.810.1.3.1.1.5.' . $array['index'] . '.1.4.' . $array['endpoint']] != 1) { $message .= "Adjacency is Down\n"; } - if ($tblAdjacencyDatabaseEntry['1.3.6.1.4.1.9.9.810.1.3.1.1.6.'.$array['index'].'.1.4.'.$array['endpoint']] < $array['uptime']) { + if ($tblAdjacencyDatabaseEntry['1.3.6.1.4.1.9.9.810.1.3.1.1.6.' . $array['index'] . '.1.4.' . $array['endpoint']] < $array['uptime']) { $message .= "Adjacency has been reset\n"; } @@ -157,11 +157,11 @@ if ($device['os_group'] == "cisco") { } // Let's log some debugging - d_echo("\n\nAdjacency Component: ".$key."\n"); - d_echo(" Label: ".$array['label']."\n"); - d_echo(" Index: ".$array['index']."\n"); - d_echo(" Status: ".$array['status']."\n"); - d_echo(" Message: ".$array['error']."\n"); + d_echo("\n\nAdjacency Component: " . $key . "\n"); + d_echo(" Label: " . $array['label'] . "\n"); + d_echo(" Index: " . $array['index'] . "\n"); + d_echo(" Status: " . $array['status'] . "\n"); + d_echo(" Message: " . $array['error'] . "\n"); } elseif ($array['otvtype'] == 'endpoint') { $count = 0; $endpoint = $array['endpoint']; @@ -171,15 +171,15 @@ if ($device['os_group'] == "cisco") { } // Let's log some debugging - d_echo("\n\nEndpoint Component: ".$key."\n"); - d_echo(" Label: ".$array['label']."\n"); - d_echo(" MAC Count: ".$count."\n"); + d_echo("\n\nEndpoint Component: " . $key . "\n"); + d_echo(" Label: " . $array['label'] . "\n"); + d_echo(" MAC Count: " . $count . "\n"); - $rrd_name = array('cisco', 'otv', $endpoint, 'mac'); + $rrd_name = ['cisco', 'otv', $endpoint, 'mac']; $rrd_def = RrdDefinition::make()->addDataset('count', 'GAUGE', 0); - $fields = array( - 'count' => $count - ); + $fields = [ + 'count' => $count, + ]; $tags = compact('endpoint', 'rrd_name', 'rrd_def'); data_update($device, 'cisco-otv-mac', $tags, $fields); diff --git a/includes/polling/cisco-qfp.inc.php b/includes/polling/cisco-qfp.inc.php index 0baf63ee79..b10b336a82 100644 --- a/includes/polling/cisco-qfp.inc.php +++ b/includes/polling/cisco-qfp.inc.php @@ -22,13 +22,13 @@ $module = 'cisco-qfp'; /* * Fetch device components and filter ignored or disabled ones */ -$options = array( - 'filter' => array( - 'type' => array('=', $module), - 'disabled' => array('=', 0), - 'ignore' => array('=', 0) - ) -); +$options = [ + 'filter' => [ + 'type' => ['=', $module], + 'disabled' => ['=', 0], + 'ignore' => ['=', 0], + ], +]; $component = new LibreNMS\Component(); $components = $component->getComponents($device['device_id'], $options); @@ -39,17 +39,16 @@ $components = $components[$device['device_id']]; * Use 5min for now but if in future LibreNMS polling interval is set through * config file we can use this to quickly select best time interval */ -$time_interval_array = array( +$time_interval_array = [ '5sec' => 1, '1min' => 2, '5min' => 3, - '1h' => 4 -); + '1h' => 4, +]; $ti = $time_interval_array['5min']; - -if (!empty($components) && is_array($components)) { +if (! empty($components) && is_array($components)) { foreach ($components as $component_id => $tmp_component) { /* * Build OIDs and use snmpget to fetch multiple OIDs at once instead of snmpwalk @@ -60,7 +59,7 @@ if (!empty($components) && is_array($components)) { * ceqfpUtilizationEntry table has `entPhysicalIndex` and `ceqfpUtilTimeInterval` indexes */ $util_oid_suffix = $qfp_index . '.' . $ti; - $util_oids = array( + $util_oids = [ 'InPriorityPps' => '.1.3.6.1.4.1.9.9.715.1.1.6.1.2.' . $util_oid_suffix, 'InPriorityBps' => '.1.3.6.1.4.1.9.9.715.1.1.6.1.3.' . $util_oid_suffix, 'InNonPriorityPps' => '.1.3.6.1.4.1.9.9.715.1.1.6.1.4.' . $util_oid_suffix, @@ -73,22 +72,22 @@ if (!empty($components) && is_array($components)) { 'OutNonPriorityBps' => '.1.3.6.1.4.1.9.9.715.1.1.6.1.11.' . $util_oid_suffix, 'OutTotalPps' => '.1.3.6.1.4.1.9.9.715.1.1.6.1.12.' . $util_oid_suffix, 'OutTotalBps' => '.1.3.6.1.4.1.9.9.715.1.1.6.1.13.' . $util_oid_suffix, - 'ProcessingLoad' => '.1.3.6.1.4.1.9.9.715.1.1.6.1.14.' . $util_oid_suffix - ); + 'ProcessingLoad' => '.1.3.6.1.4.1.9.9.715.1.1.6.1.14.' . $util_oid_suffix, + ]; /* * ceqfpMemoryResourceEntry table has `entPhysicalIndex` and `ceqfpMemoryResType` indexes * ceqfpMemoryResType has the only one valid value (1: dram) */ $mem_oid_suffix = $qfp_index . '.1'; - $memory_oids = array( + $memory_oids = [ 'RisingThreshold' => '.1.3.6.1.4.1.9.9.715.1.1.7.1.6.' . $mem_oid_suffix, 'FallingThreshold' => '.1.3.6.1.4.1.9.9.715.1.1.7.1.7.' . $mem_oid_suffix, 'LowFreeWatermark' => '.1.3.6.1.4.1.9.9.715.1.1.7.1.15.' . $mem_oid_suffix, 'Total' => '.1.3.6.1.4.1.9.9.715.1.1.7.1.9.' . $mem_oid_suffix, 'InUse' => '.1.3.6.1.4.1.9.9.715.1.1.7.1.11.' . $mem_oid_suffix, - 'Free' => '.1.3.6.1.4.1.9.9.715.1.1.7.1.13.' . $mem_oid_suffix - ); + 'Free' => '.1.3.6.1.4.1.9.9.715.1.1.7.1.13.' . $mem_oid_suffix, + ]; /* * Get SNMP data @@ -100,7 +99,7 @@ if (!empty($components) && is_array($components)) { * Check if the oids exist * Possible FP linecard OIR between discovery and polling calls */ - if (!empty($util_data) && !empty($memory_data)) { + if (! empty($util_data) && ! empty($memory_data)) { $total_packets = $util_data[$util_oids['InTotalPps']] + $util_data[$util_oids['OutTotalPps']]; $throughput = $util_data[$util_oids['InTotalBps']] + $util_data[$util_oids['OutTotalBps']]; $average_packet = $throughput / 8 / $total_packets; @@ -108,21 +107,21 @@ if (!empty($components) && is_array($components)) { * Create component data array for `component_prefs` * and update components */ - $component_data = array( + $component_data = [ 'utilization' => $util_data[$util_oids['ProcessingLoad']], 'packets' => $total_packets, 'throughput' => $throughput, 'average_packet' => $average_packet, 'memory_total' => $memory_data[$memory_oids['Total']], 'memory_used' => $memory_data[$memory_oids['InUse']], - 'memory_free' => $memory_data[$memory_oids['Free']] - ); + 'memory_free' => $memory_data[$memory_oids['Free']], + ]; $components[$component_id] = array_merge($components[$component_id], $component_data); /* * Create Utilization RRDs */ - $rrd_name = array($module, 'util', $qfp_index); + $rrd_name = [$module, 'util', $qfp_index]; $rrd_def = RrdDefinition::make(); foreach ($util_oids as $name => $oid) { $rrd_def->addDataset($name, 'GAUGE', 0); @@ -132,11 +131,10 @@ if (!empty($components) && is_array($components)) { data_update($device, $module, $tags, $rrd); unset($filename, $rrd_filename, $rrd_name, $rrd_def, $rrd); - /* * Create Utilization RRDs */ - $rrd_name = array($module, 'memory', $qfp_index); + $rrd_name = [$module, 'memory', $qfp_index]; $rrd_def = RrdDefinition::make(); foreach ($memory_oids as $name => $oid) { $rrd_def->addDataset($name, 'GAUGE', 0); diff --git a/includes/polling/cisco-remote-access-monitor.inc.php b/includes/polling/cisco-remote-access-monitor.inc.php index a7562e86c6..7cad68baed 100644 --- a/includes/polling/cisco-remote-access-monitor.inc.php +++ b/includes/polling/cisco-remote-access-monitor.inc.php @@ -34,12 +34,12 @@ use LibreNMS\RRD\RrdDefinition; // CISCO-REMOTE-ACCESS-MONITOR-MIB::crasWebvpnPeakConcurrentSessions.0 = Gauge32: 9 Sessions if ($device['os_group'] == 'cisco') { $oid_list = ['crasEmailNumSessions.0', 'crasIPSecNumSessions.0', 'crasL2LNumSessions.0', 'crasLBNumSessions.0', 'crasSVCNumSessions.0', 'crasWebvpnNumSessions.0']; - $data = snmp_get_multi($device, $oid_list, '-OUQs', 'CISCO-REMOTE-ACCESS-MONITOR-MIB'); - $data = $data[0]; + $data = snmp_get_multi($device, $oid_list, '-OUQs', 'CISCO-REMOTE-ACCESS-MONITOR-MIB'); + $data = $data[0]; // Some ASAs return 'No Such Object available on this agent at this OID' // for crasEmailNumSessions.0. Clamp this to 0. - if (!is_numeric($data['crasEmailNumSessions'])) { + if (! is_numeric($data['crasEmailNumSessions'])) { $data['crasEmailNumSessions'] = 0; } @@ -52,14 +52,14 @@ if ($device['os_group'] == 'cisco') { ->addDataset('svc', 'GAUGE', 0) ->addDataset('webvpn', 'GAUGE', 0); - $fields = array( + $fields = [ 'email' => $data['crasEmailNumSessions'], 'ipsec' => $data['crasIPSecNumSessions'], 'l2l' => $data['crasL2LNumSessions'], 'lb' => $data['crasLBNumSessions'], 'svc' => $data['crasSVCNumSessions'], 'webvpn' => $data['crasWebvpnNumSessions'], - ); + ]; $tags = compact('rrd_def'); data_update($device, 'cras_sessions', $tags, $fields); diff --git a/includes/polling/cisco-sla.inc.php b/includes/polling/cisco-sla.inc.php index 6c0f71c8c5..2362b205b6 100644 --- a/includes/polling/cisco-sla.inc.php +++ b/includes/polling/cisco-sla.inc.php @@ -3,7 +3,7 @@ use LibreNMS\RRD\RrdDefinition; // Gather our SLA's from the DB. -$slas = dbFetchRows('SELECT * FROM `slas` WHERE `device_id` = ? AND `deleted` = 0', array($device['device_id'])); +$slas = dbFetchRows('SELECT * FROM `slas` WHERE `device_id` = ? AND `deleted` = 0', [$device['device_id']]); if (count($slas) > 0) { // We have SLA's, lets go!!! @@ -12,7 +12,7 @@ if (count($slas) > 0) { $rttMonLatestRttOperTable = snmpwalk_array_num($device, '.1.3.6.1.4.1.9.9.42.1.2.10.1', 1); $rttMonLatestOper = snmpwalk_array_num($device, '.1.3.6.1.4.1.9.9.42.1.5', 1); - $uptime = snmp_get($device, 'sysUpTime.0', '-Otv'); + $uptime = snmp_get($device, 'sysUpTime.0', '-Otv'); $time_offset = (time() - intval($uptime) / 100); foreach ($slas as $sla) { @@ -21,8 +21,8 @@ if (count($slas) > 0) { // Lets process each SLA $unixtime = intval(($rttMonLatestRttOperTable['1.3.6.1.4.1.9.9.42.1.2.10.1.5'][$sla_nr] / 100 + $time_offset)); - $time = strftime('%Y-%m-%d %H:%M:%S', $unixtime); - $update = array(); + $time = strftime('%Y-%m-%d %H:%M:%S', $unixtime); + $update = []; // Use Nagios Status codes. $opstatus = $rttMonLatestRttOperTable['1.3.6.1.4.1.9.9.42.1.2.10.1.2'][$sla_nr]; @@ -38,14 +38,14 @@ if (count($slas) > 0) { } $rtt = $rttMonLatestRttOperTable['1.3.6.1.4.1.9.9.42.1.2.10.1.1'][$sla_nr]; - echo 'SLA '.$sla_nr.': '.$rtt_type.' '.$sla['owner'].' '.$sla['tag'].'... '.$rtt.'ms at '.$time.'\n'; + echo 'SLA ' . $sla_nr . ': ' . $rtt_type . ' ' . $sla['owner'] . ' ' . $sla['tag'] . '... ' . $rtt . 'ms at ' . $time . '\n'; - $fields = array( + $fields = [ 'rtt' => $rtt, - ); + ]; // The base RRD - $rrd_name = array('sla', $sla_nr); + $rrd_name = ['sla', $sla_nr]; $rrd_def = RrdDefinition::make()->addDataset('rtt', 'GAUGE', 0, 300000); $tags = compact('sla_nr', 'rrd_name', 'rrd_def'); data_update($device, 'sla', $tags, $fields); @@ -53,20 +53,20 @@ if (count($slas) > 0) { // Let's gather some per-type fields. switch ($rtt_type) { case 'jitter': - $jitter = array( + $jitter = [ 'PacketLossSD' => $rttMonLatestOper['1.3.6.1.4.1.9.9.42.1.5.2.1.26'][$sla_nr], 'PacketLossDS' => $rttMonLatestOper['1.3.6.1.4.1.9.9.42.1.5.2.1.27'][$sla_nr], 'PacketOutOfSequence' => $rttMonLatestOper['1.3.6.1.4.1.9.9.42.1.5.2.1.28'][$sla_nr], 'PacketMIA' => $rttMonLatestOper['1.3.6.1.4.1.9.9.42.1.5.2.1.29'][$sla_nr], 'PacketLateArrival' => $rttMonLatestOper['1.3.6.1.4.1.9.9.42.1.5.2.1.30'][$sla_nr], - 'MOS' => $rttMonLatestOper['1.3.6.1.4.1.9.9.42.1.5.2.1.42'][$sla_nr]/100, + 'MOS' => $rttMonLatestOper['1.3.6.1.4.1.9.9.42.1.5.2.1.42'][$sla_nr] / 100, 'ICPIF' => $rttMonLatestOper['1.3.6.1.4.1.9.9.42.1.5.2.1.43'][$sla_nr], 'OWAvgSD' => $rttMonLatestOper['1.3.6.1.4.1.9.9.42.1.5.2.1.49'][$sla_nr], 'OWAvgDS' => $rttMonLatestOper['1.3.6.1.4.1.9.9.42.1.5.2.1.50'][$sla_nr], 'AvgSDJ' => $rttMonLatestOper['1.3.6.1.4.1.9.9.42.1.5.2.1.47'][$sla_nr], 'AvgDSJ' => $rttMonLatestOper['1.3.6.1.4.1.9.9.42.1.5.2.1.48'][$sla_nr], - ); - $rrd_name = array('sla', $sla_nr, $rtt_type); + ]; + $rrd_name = ['sla', $sla_nr, $rtt_type]; $rrd_def = RrdDefinition::make() ->addDataset('PacketLossSD', 'GAUGE', 0) ->addDataset('PacketLossDS', 'GAUGE', 0) @@ -84,7 +84,7 @@ if (count($slas) > 0) { $fields = array_merge($fields, $jitter); break; case 'icmpjitter': - $icmpjitter = array( + $icmpjitter = [ 'PacketLoss' => $rttMonLatestOper['1.3.6.1.4.1.9.9.42.1.5.4.1.26'][$sla_nr], 'PacketOosSD' => $rttMonLatestOper['1.3.6.1.4.1.9.9.42.1.5.4.1.28'][$sla_nr], 'PacketOosDS' => $rttMonLatestOper['1.3.6.1.4.1.9.9.42.1.5.4.1.29'][$sla_nr], @@ -95,8 +95,8 @@ if (count($slas) > 0) { 'LatencyOWAvgDS' => $rttMonLatestOper['1.3.6.1.4.1.9.9.42.1.5.4.1.48'][$sla_nr], 'JitterIAJOut' => $rttMonLatestOper['1.3.6.1.4.1.9.9.42.1.5.4.1.49'][$sla_nr], 'JitterIAJIn' => $rttMonLatestOper['1.3.6.1.4.1.9.9.42.1.5.4.1.50'][$sla_nr], - ); - $rrd_name = array('sla', $sla_nr, $rtt_type); + ]; + $rrd_name = ['sla', $sla_nr, $rtt_type]; $rrd_def = RrdDefinition::make() ->addDataset('PacketLoss', 'GAUGE', 0) ->addDataset('PacketOosSD', 'GAUGE', 0) @@ -114,12 +114,12 @@ if (count($slas) > 0) { break; } - d_echo("The following datasources were collected for #".$sla['sla_nr'].":\n"); + d_echo("The following datasources were collected for #" . $sla['sla_nr'] . ":\n"); d_echo($fields); // Update the DB if necessary if (count($update) > 0) { - $updated = dbUpdate($update, 'slas', '`sla_id` = ?', array($sla['sla_id'])); + $updated = dbUpdate($update, 'slas', '`sla_id` = ?', [$sla['sla_id']]); } } } diff --git a/includes/polling/cisco-voice/cisco-iosdsp.inc.php b/includes/polling/cisco-voice/cisco-iosdsp.inc.php index a16c9f0939..91b3b5e8ef 100644 --- a/includes/polling/cisco-voice/cisco-iosdsp.inc.php +++ b/includes/polling/cisco-voice/cisco-iosdsp.inc.php @@ -33,16 +33,16 @@ if ($device['os_group'] == "cisco") { ->addDataset('total', 'GAUGE', 0) ->addDataset('active', 'GAUGE', 0); - $fields = array( + $fields = [ 'total' => $total, 'active' => $active, - ); + ]; $tags = compact('rrd_def'); data_update($device, 'cisco-iosdsp', $tags, $fields); $os->enableGraph('cisco-iosdsp'); - echo(" Cisco IOS DSP "); + echo " Cisco IOS DSP "; } unset($rrd_def, $total, $active, $tags, $fields); } diff --git a/includes/polling/cisco-voice/cisco-iosmtp.inc.php b/includes/polling/cisco-voice/cisco-iosmtp.inc.php index ba05609668..19d072b15a 100644 --- a/includes/polling/cisco-voice/cisco-iosmtp.inc.php +++ b/includes/polling/cisco-voice/cisco-iosmtp.inc.php @@ -30,16 +30,16 @@ if ($device['os_group'] == "cisco") { ->addDataset('total', 'GAUGE', 0) ->addDataset('active', 'GAUGE', 0); - $fields = array( + $fields = [ 'total' => $total, 'active' => $active, - ); + ]; $tags = compact('rrd_def'); data_update($device, 'cisco-iosmtp', $tags, $fields); $os->enableGraph('cisco-iosmtp'); - echo (" Cisco IOS MTP "); + echo " Cisco IOS MTP "; } unset($rrd_def, $total, $active, $available, $fields, $tags); } diff --git a/includes/polling/cisco-voice/cisco-iospri.inc.php b/includes/polling/cisco-voice/cisco-iospri.inc.php index 1984bef5a1..932261165d 100644 --- a/includes/polling/cisco-voice/cisco-iospri.inc.php +++ b/includes/polling/cisco-voice/cisco-iospri.inc.php @@ -40,16 +40,16 @@ if ($device['os_group'] == "cisco") { ->addDataset('total', 'GAUGE', 0) ->addDataset('active', 'GAUGE', 0); - $fields = array( + $fields = [ 'total' => $total, 'active' => $active, - ); + ]; $tags = compact('rrd_def'); data_update($device, 'cisco-iospri', $tags, $fields); $os->enableGraph('cisco-iospri'); - echo(" Cisco IOS PRI "); + echo " Cisco IOS PRI "; } unset($rrd_def, $total, $active, $fields, $tags); } diff --git a/includes/polling/cisco-voice/cisco-iosxcode.inc.php b/includes/polling/cisco-voice/cisco-iosxcode.inc.php index 593a965585..5550420ef3 100644 --- a/includes/polling/cisco-voice/cisco-iosxcode.inc.php +++ b/includes/polling/cisco-voice/cisco-iosxcode.inc.php @@ -30,16 +30,16 @@ if ($device['os_group'] == "cisco") { ->addDataset('total', 'GAUGE', 0) ->addDataset('active', 'GAUGE', 0); - $fields = array( + $fields = [ 'total' => $total, 'active' => $active, - ); + ]; $tags = compact('rrd_def'); data_update($device, 'cisco-iosxcode', $tags, $fields); $os->enableGraph('cisco-iosxcode'); - echo (" Cisco IOS Transcoder "); + echo " Cisco IOS Transcoder "; } unset($rrd_def, $total, $active, $available, $fields, $tags); } diff --git a/includes/polling/cisco-voice/cisco-ip.inc.php b/includes/polling/cisco-voice/cisco-ip.inc.php index 501a406cd0..2f0888c210 100644 --- a/includes/polling/cisco-voice/cisco-ip.inc.php +++ b/includes/polling/cisco-voice/cisco-ip.inc.php @@ -24,19 +24,19 @@ if ($device['os_group'] == "cisco") { ->addDataset('sccp', 'GAUGE', 0) ->addDataset('multicast', 'GAUGE', 0); - $fields = array( + $fields = [ 'h323' => $output['h323']['cvCallVolConnActiveConnection'], 'sip' => $output['sip']['cvCallVolConnActiveConnection'], 'mgcp' => $output['mgcp']['cvCallVolConnActiveConnection'], 'sccp' => $output['sccp']['cvCallVolConnActiveConnection'], 'multicast' => $output['multicast']['cvCallVolConnActiveConnection'], - ); + ]; d_echo($fields); $tags = compact('rrd_def'); data_update($device, 'cisco-voice-ip', $tags, $fields); $os->enableGraph('cisco-voice-ip'); - echo(" Cisco IOS Voice IP "); + echo " Cisco IOS Voice IP "; unset($rrd_def, $active, $fields, $tags); } } diff --git a/includes/polling/cisco-vpdn.inc.php b/includes/polling/cisco-vpdn.inc.php index 4b6c2f32b1..469705586e 100644 --- a/includes/polling/cisco-vpdn.inc.php +++ b/includes/polling/cisco-vpdn.inc.php @@ -12,20 +12,19 @@ use LibreNMS\RRD\RrdDefinition; if ($device['os_group'] == 'cisco') { $data = snmpwalk_cache_oid($device, 'cvpdnSystemEntry', null, 'CISCO-VPDN-MGMT-MIB'); - foreach ((array)$data as $type => $vpdn) { + foreach ((array) $data as $type => $vpdn) { if ($vpdn['cvpdnSystemTunnelTotal'] || $vpdn['cvpdnSystemSessionTotal']) { - $rrd_name = array('vpdn', $type); + $rrd_name = ['vpdn', $type]; $rrd_def = RrdDefinition::make() ->addDataset('tunnels', 'GAUGE', 0) ->addDataset('sessions', 'GAUGE', 0) ->addDataset('denied', 'COUNTER', 0, 100000); - $fields = array( + $fields = [ 'tunnels' => $vpdn['cvpdnSystemTunnelTotal'], 'sessions' => $vpdn['cvpdnSystemSessionTotal'], 'denied' => $vpdn['cvpdnSystemDeniedUsersTotal'], - ); - + ]; $tags = compact('type', 'rrd_name', 'rrd_def'); data_update($device, 'vpdn', $tags, $fields); diff --git a/includes/polling/core.inc.php b/includes/polling/core.inc.php index d5456e1a67..768a51940f 100644 --- a/includes/polling/core.inc.php +++ b/includes/polling/core.inc.php @@ -18,14 +18,14 @@ use LibreNMS\Util\Time; $snmpdata = snmp_get_multi_oid($device, ['sysUpTime.0', 'sysContact.0', 'sysName.0', 'sysObjectID.0', 'sysDescr.0'], '-OQnUt', 'SNMPv2-MIB'); -$poll_device['sysUptime'] = $snmpdata['.1.3.6.1.2.1.1.3.0']; -$poll_device['sysContact'] = str_replace("\n", '', $snmpdata['.1.3.6.1.2.1.1.4.0']); -$poll_device['sysName'] = str_replace("\n", '', strtolower($snmpdata['.1.3.6.1.2.1.1.5.0'])); +$poll_device['sysUptime'] = $snmpdata['.1.3.6.1.2.1.1.3.0']; +$poll_device['sysContact'] = str_replace("\n", '', $snmpdata['.1.3.6.1.2.1.1.4.0']); +$poll_device['sysName'] = str_replace("\n", '', strtolower($snmpdata['.1.3.6.1.2.1.1.5.0'])); $poll_device['sysObjectID'] = $snmpdata['.1.3.6.1.2.1.1.2.0']; -$poll_device['sysDescr'] = str_replace(chr(218), "\n", $snmpdata['.1.3.6.1.2.1.1.1.0']); +$poll_device['sysDescr'] = str_replace(chr(218), "\n", $snmpdata['.1.3.6.1.2.1.1.1.0']); -if (!empty($agent_data['uptime'])) { - list($uptime) = explode(' ', $agent_data['uptime']); +if (! empty($agent_data['uptime'])) { + [$uptime] = explode(' ', $agent_data['uptime']); $uptime = round($uptime); echo "Using UNIX Agent Uptime ($uptime)\n"; } else { @@ -44,9 +44,9 @@ if ($uptime != 0 && Config::get("os.{$device['os']}.bad_uptime") !== true) { log_event('Device rebooted after ' . Time::formatInterval($device['uptime']) . " -> {$uptime}s", $device, 'reboot', 4, $device['uptime']); } - $tags = array( + $tags = [ 'rrd_def' => RrdDefinition::make()->addDataset('uptime', 'GAUGE', 0), - ); + ]; data_update($device, 'uptime', $tags, $uptime); $os->enableGraph('uptime'); @@ -54,7 +54,7 @@ if ($uptime != 0 && Config::get("os.{$device['os']}.bad_uptime") !== true) { echo 'Uptime: ' . Time::formatInterval($uptime) . PHP_EOL; $update_array['uptime'] = $uptime; - $device['uptime'] = $uptime; + $device['uptime'] = $uptime; }//end if $poll_device['sysContact'] = str_replace('"', '', $poll_device['sysContact']); @@ -64,10 +64,10 @@ if ($poll_device['sysContact'] == 'not set') { } // Save results of various polled values to the database -foreach (array('sysContact', 'sysObjectID', 'sysName', 'sysDescr') as $elem) { +foreach (['sysContact', 'sysObjectID', 'sysName', 'sysDescr'] as $elem) { if ($poll_device[$elem] != $device[$elem]) { $update_array[$elem] = $poll_device[$elem]; - $device[$elem] = $poll_device[$elem]; + $device[$elem] = $poll_device[$elem]; log_event("$elem -> " . $poll_device[$elem], $device, 'system', 3); } } diff --git a/includes/polling/customoid.inc.php b/includes/polling/customoid.inc.php index eb41234915..2c899e6d0d 100644 --- a/includes/polling/customoid.inc.php +++ b/includes/polling/customoid.inc.php @@ -2,18 +2,18 @@ use LibreNMS\RRD\RrdDefinition; -foreach (dbFetchRows("SELECT * FROM `customoids` WHERE `customoid_passed` = 1 AND `device_id` = ?", array($device['device_id'])) as $customoid) { +foreach (dbFetchRows("SELECT * FROM `customoids` WHERE `customoid_passed` = 1 AND `device_id` = ?", [$device['device_id']]) as $customoid) { d_echo($customoid); $prev_oid_value = $customoid['customoid_current']; $rawdata = snmp_get($device, $customoid['customoid_oid'], '-Oqv'); - $user_funcs = array( + $user_funcs = [ "celsius_to_fahrenheit", "fahrenheit_to_celsius", - "uw_to_dbm" - ); + "uw_to_dbm", + ]; if (is_numeric($rawdata)) { $os->enableGraph('customoid'); @@ -34,14 +34,14 @@ foreach (dbFetchRows("SELECT * FROM `customoids` WHERE `customoid_passed` = 1 AN $oid_value = $customoid['user_func']($oid_value); } - echo 'Custom OID '.$customoid['customoid_descr'].': '; - echo $oid_value.' '.$customoid['customoid_unit']."\n"; + echo 'Custom OID ' . $customoid['customoid_descr'] . ': '; + echo $oid_value . ' ' . $customoid['customoid_unit'] . "\n"; - $fields = array( + $fields = [ 'oid_value' => $oid_value, - ); + ]; - $rrd_name = array('customoid', $customoid['customoid_descr']); + $rrd_name = ['customoid', $customoid['customoid_descr']]; if ($customoid['customoid_datatype'] == 'COUNTER') { $datatype = $customoid['customoid_datatype']; } else { @@ -53,7 +53,7 @@ foreach (dbFetchRows("SELECT * FROM `customoids` WHERE `customoid_passed` = 1 AN $tags = compact('rrd_name', 'rrd_def'); data_update($device, 'customoid', $tags, $fields); - dbUpdate(array('customoid_current' => $oid_value, 'lastupdate' => array('NOW()'), 'customoid_prev' => $prev_oid_value), 'customoids', '`customoid_id` = ?', array($customoid['customoid_id'])); + dbUpdate(['customoid_current' => $oid_value, 'lastupdate' => ['NOW()'], 'customoid_prev' => $prev_oid_value], 'customoids', '`customoid_id` = ?', [$customoid['customoid_id']]); }//end foreach unset($customoid, $prev_oid_value, $rawdata, $user_funcs, $oid_value, $error, $fields, $rrd_def, $rrd_name, $tags); diff --git a/includes/polling/entity-physical/cimc.inc.php b/includes/polling/entity-physical/cimc.inc.php index 6ed6054a8f..2427accc4b 100644 --- a/includes/polling/entity-physical/cimc.inc.php +++ b/includes/polling/entity-physical/cimc.inc.php @@ -12,7 +12,7 @@ */ $component = new LibreNMS\Component(); -$components = $component->getComponents($device['device_id'], array('type'=>'Cisco-CIMC')); +$components = $component->getComponents($device['device_id'], ['type'=>'Cisco-CIMC']); // We only care about our device id. $components = $components[$device['device_id']]; @@ -25,13 +25,13 @@ if (count($components > 0)) { // Make sure we have an array of data before we try to iterate over it if (is_array($tblUCSObjects)) { // First, let's extract any active faults, we will use them later. - $faults = array(); + $faults = []; foreach ($tblUCSObjects as $oid => $data) { if (strstr($oid, '1.3.6.1.4.1.9.9.719.1.1.1.1.5.')) { $id = substr($oid, 30); - $fobj = $tblUCSObjects['1.3.6.1.4.1.9.9.719.1.1.1.1.5.'.$id]; + $fobj = $tblUCSObjects['1.3.6.1.4.1.9.9.719.1.1.1.1.5.' . $id]; $fobj = preg_replace('/^sys/', '/sys', $fobj); - $faults[$fobj] = $tblUCSObjects['1.3.6.1.4.1.9.9.719.1.1.1.1.11.'.$id]; + $faults[$fobj] = $tblUCSObjects['1.3.6.1.4.1.9.9.719.1.1.1.1.11.' . $id]; } } @@ -46,7 +46,7 @@ if (count($components > 0)) { if ($tblUCSObjects[$array['statusoid']] != 1) { // Yes, report an error $array['status'] = 2; - $array['error'] = "Error Operability Code: ".$tblUCSObjects[$array['statusoid']]."\n"; + $array['error'] = "Error Operability Code: " . $tblUCSObjects[$array['statusoid']] . "\n"; } else { // No, unset any errors that may exist. $array['status'] = 0; @@ -61,16 +61,16 @@ if (count($components > 0)) { if (strstr($key, $array['label'])) { // The fault is on this chassis. $array['status'] = 2; - $array['error'] .= $value."\n"; + $array['error'] .= $value . "\n"; } } } // Print some debugging if ($array['status'] == 0) { - d_echo($array['label']." - Ok\n"); + d_echo($array['label'] . " - Ok\n"); } else { - d_echo($array['label']." - ".$array['error']."\n"); + d_echo($array['label'] . " - " . $array['error'] . "\n"); } } // End foreach components // Write the Components back to the DB. diff --git a/includes/polling/entity-physical/ios.inc.php b/includes/polling/entity-physical/ios.inc.php index 2fb0e90a4f..948ec14d15 100644 --- a/includes/polling/entity-physical/ios.inc.php +++ b/includes/polling/entity-physical/ios.inc.php @@ -4,7 +4,7 @@ use LibreNMS\RRD\RrdDefinition; echo "Cisco Cat6xxx/76xx Crossbar : \n"; -$mod_stats = snmpwalk_cache_oid($device, 'cc6kxbarModuleModeTable', array(), 'CISCO-CAT6K-CROSSBAR-MIB'); +$mod_stats = snmpwalk_cache_oid($device, 'cc6kxbarModuleModeTable', [], 'CISCO-CAT6K-CROSSBAR-MIB'); foreach ($mod_stats as $index => $entry) { $group = 'c6kxbar'; @@ -14,19 +14,19 @@ foreach ($mod_stats as $index => $entry) { } } -$chan_stats = snmpwalk_cache_oid($device, 'cc6kxbarModuleChannelTable', array(), 'CISCO-CAT6K-CROSSBAR-MIB'); -if (!empty($chan_stats)) { +$chan_stats = snmpwalk_cache_oid($device, 'cc6kxbarModuleChannelTable', [], 'CISCO-CAT6K-CROSSBAR-MIB'); +if (! empty($chan_stats)) { $chan_stats = snmpwalk_cache_oid($device, 'cc6kxbarStatisticsTable', $chan_stats, 'CISCO-CAT6K-CROSSBAR-MIB'); } foreach ($chan_stats as $index => $entry) { - list($index,$subindex) = explode('.', $index, 2); - $group = 'c6kxbar'; + [$index,$subindex] = explode('.', $index, 2); + $group = 'c6kxbar'; foreach ($entry as $key => $value) { $entPhysical_state[$index][$subindex][$group][$key] = $value; } - $rrd_name = array('c6kxbar', $index, $subindex); + $rrd_name = ['c6kxbar', $index, $subindex]; $rrd_def = RrdDefinition::make() ->addDataset('inutil', 'GAUGE', 0, 100) ->addDataset('oututil', 'GAUGE', 0, 100) @@ -34,13 +34,13 @@ foreach ($chan_stats as $index => $entry) { ->addDataset('outerrors', 'DERIVE', 0, 125000000000) ->addDataset('inerrors', 'DERIVE', 0, 125000000000); - $fields = array( + $fields = [ 'inutil' => $entry['cc6kxbarStatisticsInUtil'], 'oututil' => $entry['cc6kxbarStatisticsOutUtil'], 'outdropped' => $entry['cc6kxbarStatisticsOutDropped'], 'outerrors' => $entry['cc6kxbarStatisticsOutErrors'], 'inerrors' => $entry['cc6kxbarStatisticsInErrors'], - ); + ]; $tags = compact('index', 'subindex', 'rrd_name', 'rrd_def'); data_update($device, 'c6kxbar', $tags, $fields); diff --git a/includes/polling/entity-physical/state.inc.php b/includes/polling/entity-physical/state.inc.php index 7394d8f75c..7d629f3aa3 100644 --- a/includes/polling/entity-physical/state.inc.php +++ b/includes/polling/entity-physical/state.inc.php @@ -1,33 +1,33 @@ $entPhysical_state[$entity['entPhysicalIndex']][$entity['subindex']][$entity['group']][$entity['key']]), + ['value' => $entPhysical_state[$entity['entPhysicalIndex']][$entity['subindex']][$entity['group']][$entity['key']]], 'entPhysical_state', '`device_id` = ? AND `entPhysicalIndex` = ? AND `subindex` = ? AND `group` = ? AND `key` = ?', - array( - $device['device_id'], - $entity['entPhysicalIndex'], - $entity['subindex'], - $entity['group'], - $entity['key'] - ) + [ + $device['device_id'], + $entity['entPhysicalIndex'], + $entity['subindex'], + $entity['group'], + $entity['key'], + ] ); } @@ -37,11 +37,11 @@ foreach (dbFetch('SELECT * FROM `entPhysical_state` WHERE `device_id` = ?', arra // End Set Entity Attrivs // Delete Entity state -foreach ((array)$entPhysical_state as $epi => $entity) { +foreach ((array) $entPhysical_state as $epi => $entity) { foreach ($entity as $subindex => $si) { foreach ($si as $group => $ti) { foreach ($ti as $key => $value) { - dbInsert(array('device_id' => $device['device_id'], 'entPhysicalIndex' => $epi, 'subindex' => $subindex, 'group' => $group, 'key' => $key, 'value' => $value), 'entPhysical_state'); + dbInsert(['device_id' => $device['device_id'], 'entPhysicalIndex' => $epi, 'subindex' => $subindex, 'group' => $group, 'key' => $key, 'value' => $value], 'entPhysical_state'); } } } diff --git a/includes/polling/entity-state.inc.php b/includes/polling/entity-state.inc.php index 2eacee59a7..3674e2e97b 100644 --- a/includes/polling/entity-state.inc.php +++ b/includes/polling/entity-state.inc.php @@ -22,14 +22,13 @@ * @copyright 2017 Tony Murray * @author Tony Murray */ - $entityStatesIndexes = dbFetchRows( 'SELECT S.entity_state_id, S.entStateLastChanged, P.entPhysicalIndex FROM entityState AS S ' . 'LEFT JOIN entPhysical AS P USING (entPhysical_id) WHERE S.device_id=?', - array($device['device_id']) + [$device['device_id']] ); -if (!empty($entityStatesIndexes)) { +if (! empty($entityStatesIndexes)) { echo "\nEntity States: "; // index by entPhysicalIndex @@ -40,20 +39,20 @@ if (!empty($entityStatesIndexes)) { foreach (current($entLC) as $index => $changed) { if ($changed) { // skip empty entries try { - list($date, $time, $tz) = explode(',', $changed); + [$date, $time, $tz] = explode(',', $changed); $lastChanged = new DateTime("$date $time", new DateTimeZone($tz)); $dbLastChanged = new DateTime($entityStatesIndexes[$index]['entStateLastChanged']); if ($lastChanged != $dbLastChanged) { // data has changed, fetch it $new_states = snmp_get_multi( $device, - array( + [ "entStateAdmin.$index", "entStateOper.$index", "entStateUsage.$index", "entStateAlarm.$index", - "entStateStandby.$index" - ), + "entStateStandby.$index", + ], '-OQUse', 'ENTITY-STATE-MIB' ); @@ -69,16 +68,16 @@ if (!empty($entityStatesIndexes)) { $new_states, dbFetchRow( 'SELECT * FROM entityState WHERE entity_state_id=?', - array($entityStatesIndexes[$index]['entity_state_id']) + [$entityStatesIndexes[$index]['entity_state_id']] ) ); - if (!empty($update)) { + if (! empty($update)) { dbUpdate( $update, 'entityState', 'entity_state_id=?', - array($entityStatesIndexes[$index]['entity_state_id']) + [$entityStatesIndexes[$index]['entity_state_id']] ); d_echo("Updating $index: ", 'U'); d_echo($new_states[$index]); diff --git a/includes/polling/functions.inc.php b/includes/polling/functions.inc.php index 0ac1e7409e..dfa5d4a92a 100644 --- a/includes/polling/functions.inc.php +++ b/includes/polling/functions.inc.php @@ -16,7 +16,7 @@ function bulk_sensor_snmpget($device, $sensors) { $oid_per_pdu = get_device_oid_limit($device); $sensors = array_chunk($sensors, $oid_per_pdu); - $cache = array(); + $cache = []; foreach ($sensors as $chunk) { $oids = array_map(function ($data) { return $data['sensor_oid']; @@ -25,6 +25,7 @@ function bulk_sensor_snmpget($device, $sensors) $multi_response = snmp_get_multi_oid($device, $oids, '-OUQnte'); $cache = array_merge($cache, $multi_response); } + return $cache; } @@ -35,10 +36,11 @@ function bulk_sensor_snmpget($device, $sensors) */ function sensor_precache($device, $type) { - $sensor_cache = array(); - if (file_exists('includes/polling/sensors/pre-cache/'. $device['os'] .'.inc.php')) { - include 'includes/polling/sensors/pre-cache/'. $device['os'] .'.inc.php'; + $sensor_cache = []; + if (file_exists('includes/polling/sensors/pre-cache/' . $device['os'] . '.inc.php')) { + include 'includes/polling/sensors/pre-cache/' . $device['os'] . '.inc.php'; } + return $sensor_cache; } @@ -46,11 +48,11 @@ function poll_sensor($device, $class) { global $agent_sensors; - $sensors = array(); - $misc_sensors = array(); - $all_sensors = array(); + $sensors = []; + $misc_sensors = []; + $all_sensors = []; - foreach (dbFetchRows("SELECT * FROM `sensors` WHERE `sensor_class` = ? AND `device_id` = ?", array($class, $device['device_id'])) as $sensor) { + foreach (dbFetchRows("SELECT * FROM `sensors` WHERE `sensor_class` = ? AND `device_id` = ?", [$class, $device['device_id']]) as $sensor) { if ($sensor['poller_type'] == 'agent') { // Agent sensors are polled in the unix-agent } elseif ($sensor['poller_type'] == 'ipmi') { @@ -65,33 +67,33 @@ function poll_sensor($device, $class) $sensor_cache = sensor_precache($device, $class); foreach ($sensors as $sensor) { - echo 'Checking (' . $sensor['poller_type'] . ") $class " . $sensor['sensor_descr'] . '... '.PHP_EOL; + echo 'Checking (' . $sensor['poller_type'] . ") $class " . $sensor['sensor_descr'] . '... ' . PHP_EOL; if ($sensor['poller_type'] == 'snmp') { $mibdir = null; $sensor_value = trim(str_replace('"', '', $snmp_data[$sensor['sensor_oid']])); - if (file_exists('includes/polling/sensors/'. $class .'/'. $device['os'] .'.inc.php')) { - require 'includes/polling/sensors/'. $class .'/'. $device['os'] .'.inc.php'; - } elseif (file_exists('includes/polling/sensors/'. $class .'/'. $device['os_group'] .'.inc.php')) { - require 'includes/polling/sensors/'. $class .'/'. $device['os_group'] .'.inc.php'; + if (file_exists('includes/polling/sensors/' . $class . '/' . $device['os'] . '.inc.php')) { + require 'includes/polling/sensors/' . $class . '/' . $device['os'] . '.inc.php'; + } elseif (file_exists('includes/polling/sensors/' . $class . '/' . $device['os_group'] . '.inc.php')) { + require 'includes/polling/sensors/' . $class . '/' . $device['os_group'] . '.inc.php'; } if ($class == 'temperature') { preg_match('/[\d\.\-]+/', $sensor_value, $temp_response); - if (!empty($temp_response[0])) { + if (! empty($temp_response[0])) { $sensor_value = $temp_response[0]; } } elseif ($class == 'state') { - if (!is_numeric($sensor_value)) { + if (! is_numeric($sensor_value)) { $state_value = dbFetchCell( 'SELECT `state_value` FROM `state_translations` LEFT JOIN `sensors_to_state_indexes` ON `state_translations`.`state_index_id` = `sensors_to_state_indexes`.`state_index_id` WHERE `sensors_to_state_indexes`.`sensor_id` = ? AND `state_translations`.`state_descr` LIKE ?', - array($sensor['sensor_id'], $sensor_value) + [$sensor['sensor_id'], $sensor_value] ); d_echo('State value of ' . $sensor_value . ' is ' . $state_value . "\n"); if (is_numeric($state_value)) { @@ -134,7 +136,7 @@ function poll_sensor($device, $class) */ function record_sensor_data($device, $all_sensors) { - $supported_sensors = array( + $supported_sensors = [ 'current' => 'A', 'frequency' => 'Hz', 'runtime' => 'Min', @@ -152,12 +154,12 @@ function record_sensor_data($device, $all_sensors) 'snr' => 'SNR', 'pressure' => 'kPa', 'cooling' => 'W', - ); + ]; foreach ($all_sensors as $sensor) { - $class = ucfirst($sensor['sensor_class']); - $unit = $supported_sensors[$class]; - $sensor_value = $sensor['new_value']; + $class = ucfirst($sensor['sensor_class']); + $unit = $supported_sensors[$class]; + $sensor_value = $sensor['new_value']; $prev_sensor_value = $sensor['sensor_current']; if ($sensor_value == -32768 || is_nan($sensor_value)) { @@ -183,26 +185,26 @@ function record_sensor_data($device, $all_sensors) echo "$sensor_value $unit\n"; - $fields = array( + $fields = [ 'sensor' => $sensor_value, - ); + ]; - $tags = array( + $tags = [ 'sensor_class' => $sensor['sensor_class'], 'sensor_type' => $sensor['sensor_type'], 'sensor_descr' => $sensor['sensor_descr'], 'sensor_index' => $sensor['sensor_index'], 'rrd_name' => $rrd_name, - 'rrd_def' => $rrd_def - ); + 'rrd_def' => $rrd_def, + ]; data_update($device, 'sensor', $tags, $fields); // FIXME also warn when crossing WARN level! if ($sensor['sensor_limit_low'] != '' && $prev_sensor_value > $sensor['sensor_limit_low'] && $sensor_value < $sensor['sensor_limit_low'] && $sensor['sensor_alert'] == 1) { - echo 'Alerting for '.$device['hostname'].' '.$sensor['sensor_descr']."\n"; + echo 'Alerting for ' . $device['hostname'] . ' ' . $sensor['sensor_descr'] . "\n"; log_event("$class under threshold: $sensor_value $unit (< {$sensor['sensor_limit_low']} $unit)", $device, $sensor['sensor_class'], 4, $sensor['sensor_id']); } elseif ($sensor['sensor_limit'] != '' && $prev_sensor_value < $sensor['sensor_limit'] && $sensor_value > $sensor['sensor_limit'] && $sensor['sensor_alert'] == 1) { - echo 'Alerting for '.$device['hostname'].' '.$sensor['sensor_descr']."\n"; + echo 'Alerting for ' . $device['hostname'] . ' ' . $sensor['sensor_descr'] . "\n"; log_event("$class above threshold: $sensor_value $unit (> {$sensor['sensor_limit']} $unit)", $device, $sensor['sensor_class'], 4, $sensor['sensor_id']); } if ($sensor['sensor_class'] == 'state' && $prev_sensor_value != $sensor_value) { @@ -218,7 +220,7 @@ function record_sensor_data($device, $all_sensors) log_event("$class sensor {$sensor['sensor_descr']} has changed from {$trans[$prev_sensor_value]} ($prev_sensor_value) to {$trans[$sensor_value]} ($sensor_value)", $device, $class, 3, $sensor['sensor_id']); } if ($sensor_value != $prev_sensor_value) { - dbUpdate(array('sensor_current' => $sensor_value, 'sensor_prev' => $prev_sensor_value, 'lastupdate' => array('NOW()')), 'sensors', "`sensor_class` = ? AND `sensor_id` = ?", array($class, $sensor['sensor_id'])); + dbUpdate(['sensor_current' => $sensor_value, 'sensor_prev' => $prev_sensor_value, 'lastupdate' => ['NOW()']], 'sensors', "`sensor_class` = ? AND `sensor_id` = ?", [$class, $sensor['sensor_id']]); } } } @@ -254,35 +256,35 @@ function poll_device($device, $force_module = false) } $db_ip = null; - if (!empty($ip)) { + if (! empty($ip)) { if (empty($device['overwrite_ip'])) { - echo 'Resolved IP: '.$ip.PHP_EOL; + echo 'Resolved IP: ' . $ip . PHP_EOL; } else { - echo 'Assigned IP: '.$ip.PHP_EOL; + echo 'Assigned IP: ' . $ip . PHP_EOL; } $db_ip = inet_pton($ip); } - if (!empty($db_ip) && inet6_ntop($db_ip) != inet6_ntop($device['ip'])) { + if (! empty($db_ip) && inet6_ntop($db_ip) != inet6_ntop($device['ip'])) { log_event('Device IP changed to ' . $ip, $device, 'system', 3); - dbUpdate(array('ip' => $db_ip), 'devices', 'device_id=?', array($device['device_id'])); + dbUpdate(['ip' => $db_ip], 'devices', 'device_id=?', [$device['device_id']]); } if ($os_group = Config::get("os.{$device['os']}.group")) { $device['os_group'] = $os_group; - echo ' ('.$device['os_group'].')'; + echo ' (' . $device['os_group'] . ')'; } - echo PHP_EOL.PHP_EOL; + echo PHP_EOL . PHP_EOL; unset($poll_update); unset($poll_update_query); unset($poll_separator); - $poll_update_array = array(); - $update_array = array(); + $poll_update_array = []; + $update_array = []; $host_rrd = rrd_name($device['hostname'], '', ''); - if (Config::get('norrd') !== true && !is_dir($host_rrd)) { + if (Config::get('norrd') !== true && ! is_dir($host_rrd)) { mkdir($host_rrd); echo "Created directory : $host_rrd\n"; } @@ -304,9 +306,9 @@ function poll_device($device, $force_module = false) d_echo("OS" . (isset($os_module_status) ? ($os_module_status ? '+ ' : '- ') : ' ')); d_echo("Device" . (isset($attribs['poll_' . $module]) ? ($attribs['poll_' . $module] ? '+ ' : '- ') : ' ')); if ($force_module === true || - $attribs['poll_'.$module] || - ($os_module_status && !isset($attribs['poll_'.$module])) || - ($module_status && !isset($os_module_status) && !isset($attribs['poll_' . $module]))) { + $attribs['poll_' . $module] || + ($os_module_status && ! isset($attribs['poll_' . $module])) || + ($module_status && ! isset($os_module_status) && ! isset($attribs['poll_' . $module]))) { $start_memory = memory_get_usage(); $module_start = microtime(true); echo "\n#### Load poller module $module ####\n"; @@ -315,36 +317,36 @@ function poll_device($device, $force_module = false) include "includes/polling/$module.inc.php"; } catch (Exception $e) { // isolate module exceptions so they don't disrupt the polling process - echo $e->getTraceAsString() .PHP_EOL; + echo $e->getTraceAsString() . PHP_EOL; c_echo("%rError in $module module.%n " . $e->getMessage() . PHP_EOL); logfile("Error in $module module. " . $e->getMessage() . PHP_EOL . $e->getTraceAsString() . PHP_EOL); } $module_time = microtime(true) - $module_start; - $module_mem = (memory_get_usage() - $start_memory); + $module_mem = (memory_get_usage() - $start_memory); printf("\n>> Runtime for poller module '%s': %.4f seconds with %s bytes\n", $module, $module_time, $module_mem); printChangedStats(); echo "#### Unload poller module $module ####\n\n"; // save per-module poller stats - $tags = array( + $tags = [ 'module' => $module, 'rrd_def' => RrdDefinition::make()->addDataset('poller', 'GAUGE', 0), - 'rrd_name' => array('poller-perf', $module), - ); - $fields = array( + 'rrd_name' => ['poller-perf', $module], + ]; + $fields = [ 'poller' => $module_time, - ); + ]; data_update($device, 'poller-perf', $tags, $fields); $os->enableGraph('poller_perf'); // remove old rrd - $oldrrd = rrd_name($device['hostname'], array('poller', $module, 'perf')); + $oldrrd = rrd_name($device['hostname'], ['poller', $module, 'perf']); if (is_file($oldrrd)) { unlink($oldrrd); } unset($tags, $fields, $oldrrd); - } elseif (isset($attribs['poll_'.$module]) && $attribs['poll_'.$module] == '0') { + } elseif (isset($attribs['poll_' . $module]) && $attribs['poll_' . $module] == '0') { echo "Module [ $module ] disabled on host.\n\n"; } elseif (isset($os_module_status) && $os_module_status == '0') { echo "Module [ $module ] disabled on os.\n\n"; @@ -354,40 +356,40 @@ function poll_device($device, $force_module = false) } // Ping response - if (can_ping_device($attribs) === true && !empty($response['ping_time'])) { - $tags = array( + if (can_ping_device($attribs) === true && ! empty($response['ping_time'])) { + $tags = [ 'rrd_def' => RrdDefinition::make()->addDataset('ping', 'GAUGE', 0, 65535), - ); - $fields = array( + ]; + $fields = [ 'ping' => $response['ping_time'], - ); + ]; - $update_array['last_ping'] = array('NOW()'); - $update_array['last_ping_timetaken'] = $response['ping_time']; + $update_array['last_ping'] = ['NOW()']; + $update_array['last_ping_timetaken'] = $response['ping_time']; data_update($device, 'ping-perf', $tags, $fields); $os->enableGraph('ping_perf'); } - $device_time = round(microtime(true) - $device_start, 3); + $device_time = round(microtime(true) - $device_start, 3); // Poller performance - if (!empty($device_time)) { - $tags = array( + if (! empty($device_time)) { + $tags = [ 'rrd_def' => RrdDefinition::make()->addDataset('poller', 'GAUGE', 0), 'module' => 'ALL', - ); - $fields = array( + ]; + $fields = [ 'poller' => $device_time, - ); + ]; data_update($device, 'poller-perf', $tags, $fields); $os->enableGraph('poller_modules_perf'); } - if (!$force_module) { + if (! $force_module) { // don't update last_polled time if we are forcing a specific module to be polled - $update_array['last_polled'] = array('NOW()'); + $update_array['last_polled'] = ['NOW()']; $update_array['last_polled_timetaken'] = $device_time; echo "Enabling graphs: "; @@ -402,7 +404,7 @@ function poll_device($device, $force_module = false) echo PHP_EOL; } - $updated = dbUpdate($update_array, 'devices', '`device_id` = ?', array($device['device_id'])); + $updated = dbUpdate($update_array, 'devices', '`device_id` = ?', [$device['device_id']]); if ($updated) { d_echo('Updating ' . $device['hostname'] . PHP_EOL); } @@ -439,28 +441,29 @@ function poll_device($device, $force_module = false) * @param array $metrics an array of additional metrics to store in the database for alerting * @param string $status This is the current value for alerting */ -function update_application($app, $response, $metrics = array(), $status = '') +function update_application($app, $response, $metrics = [], $status = '') { - if (!is_numeric($app['app_id'])) { + if (! is_numeric($app['app_id'])) { d_echo('$app does not contain app_id, could not update'); + return; } - $data = array( + $data = [ 'app_state' => 'UNKNOWN', 'app_status' => $status, - 'timestamp' => array('NOW()'), - ); + 'timestamp' => ['NOW()'], + ]; if ($response != '' && $response !== false) { - if (Str::contains($response, array( + if (Str::contains($response, [ 'Traceback (most recent call last):', - ))) { + ])) { $data['app_state'] = 'ERROR'; } elseif (in_array($response, ['OK', 'ERROR', 'LEGACY', 'UNSUPPORTED'])) { $data['app_state'] = $response; } else { - # should maybe be 'unknown' as state + // should maybe be 'unknown' as state $data['app_state'] = 'OK'; } } @@ -468,7 +471,7 @@ function update_application($app, $response, $metrics = array(), $status = '') if ($data['app_state'] != $app['app_state']) { $data['app_state_prev'] = $app['app_state']; - $device = dbFetchRow('SELECT * FROM devices LEFT JOIN applications ON devices.device_id=applications.device_id WHERE applications.app_id=?', array($app['app_id'])); + $device = dbFetchRow('SELECT * FROM devices LEFT JOIN applications ON devices.device_id=applications.device_id WHERE applications.app_id=?', [$app['app_id']]); $app_name = \LibreNMS\Util\StringHelpers::nicecase($app['app_type']); @@ -494,13 +497,13 @@ function update_application($app, $response, $metrics = array(), $status = '') $event_msg = "has UNKNOWN state"; break; } - log_event("Application ".$app_name." ".$event_msg, $device, 'application', $severity); + log_event("Application " . $app_name . " " . $event_msg, $device, 'application', $severity); } - dbUpdate($data, 'applications', '`app_id` = ?', array($app['app_id'])); + dbUpdate($data, 'applications', '`app_id` = ?', [$app['app_id']]); // update metrics - if (!empty($metrics)) { - $db_metrics = dbFetchRows('SELECT * FROM `application_metrics` WHERE app_id=?', array($app['app_id'])); + if (! empty($metrics)) { + $db_metrics = dbFetchRows('SELECT * FROM `application_metrics` WHERE app_id=?', [$app['app_id']]); $db_metrics = array_by_column($db_metrics, 'metric'); // allow two level metrics arrays, flatten them and prepend the group name @@ -517,34 +520,35 @@ function update_application($app, $response, $metrics = array(), $status = '') foreach ($metrics[$metric_group] as $metric_name => $value) { $carry[$prefix . $metric_name] = $value; } + return $carry; }, - array() + [] ); } echo ': '; foreach ($metrics as $metric_name => $value) { - if (!isset($db_metrics[$metric_name])) { + if (! isset($db_metrics[$metric_name])) { // insert new metric dbInsert( - array( + [ 'app_id' => $app['app_id'], 'metric' => $metric_name, 'value' => $value, - ), + ], 'application_metrics' ); echo '+'; } elseif ($value != $db_metrics[$metric_name]['value']) { dbUpdate( - array( + [ 'value' => $value, 'value_prev' => $db_metrics[$metric_name]['value'], - ), + ], 'application_metrics', 'app_id=? && metric=?', - array($app['app_id'], $metric_name) + [$app['app_id'], $metric_name] ); echo 'U'; } else { @@ -559,7 +563,7 @@ function update_application($app, $response, $metrics = array(), $status = '') dbDelete( 'application_metrics', 'app_id=? && metric=?', - array($app['app_id'], $db_metric['metric']) + [$app['app_id'], $db_metric['metric']] ); echo '-'; } @@ -571,10 +575,10 @@ function update_application($app, $response, $metrics = array(), $status = '') function convert_to_celsius($value) { $value = ($value - 32) / 1.8; + return sprintf('%.02f', $value); } - /** * This is to make it easier polling apps. Also to help standardize around JSON. * @@ -613,7 +617,7 @@ function convert_to_celsius($value) * * @param array $device * @param string $extend the extend name. For example, if 'zfs' is passed it will be converted to 'nsExtendOutputFull.3.122.102.115'. - * @param integer $min_version the minimum version to accept for the returned JSON. default: 1 + * @param int $min_version the minimum version to accept for the returned JSON. default: 1 * * @return array The json output data parsed into an array * @throws JsonAppBlankJsonException @@ -625,7 +629,7 @@ function convert_to_celsius($value) */ function json_app_get($device, $extend, $min_version = 1) { - $output = snmp_get($device, 'nsExtendOutputFull.'.string_to_oid($extend), '-Oqv', 'NET-SNMP-EXTEND-MIB'); + $output = snmp_get($device, 'nsExtendOutputFull.' . string_to_oid($extend), '-Oqv', 'NET-SNMP-EXTEND-MIB'); // make sure we actually get something back if (empty($output)) { @@ -646,12 +650,12 @@ function json_app_get($device, $extend, $min_version = 1) } // It is a legacy JSON app extend, meaning these are not set - if (!isset($parsed_json['error'], $parsed_json['data'], $parsed_json['errorString'], $parsed_json['version'])) { + if (! isset($parsed_json['error'], $parsed_json['data'], $parsed_json['errorString'], $parsed_json['version'])) { throw new JsonAppMissingKeysException("Legacy script or extend error, missing one or more required keys.", $output, $parsed_json, -5); } if ($parsed_json['version'] < $min_version) { - throw new JsonAppWrongVersionException("Script,'".$parsed_json['version']."', older than required version of '$min_version'", $output, $parsed_json, -6); + throw new JsonAppWrongVersionException("Script,'" . $parsed_json['version'] . "', older than required version of '$min_version'", $output, $parsed_json, -6); } if ($parsed_json['error'] != 0) { @@ -678,16 +682,16 @@ function json_app_get($device, $extend, $min_version = 1) */ function data_flatten($array, $prefix = '', $joiner = '_') { - $return = array(); + $return = []; foreach ($array as $key => $value) { if (is_array($value)) { if (strcmp($prefix, '')) { - $key=$prefix.$joiner.$key; + $key = $prefix . $joiner . $key; } $return = array_merge($return, data_flatten($value, $key, $joiner)); } else { if (strcmp($prefix, '')) { - $key=$prefix.$joiner.$key; + $key = $prefix . $joiner . $key; } $return[$key] = $value; } diff --git a/includes/polling/hr-mib.inc.php b/includes/polling/hr-mib.inc.php index 5c68de9233..fbfc32b257 100644 --- a/includes/polling/hr-mib.inc.php +++ b/includes/polling/hr-mib.inc.php @@ -8,12 +8,12 @@ $oid_list = ['hrSystemProcesses.0', 'hrSystemNumUsers.0']; $hrSystem = snmp_get_multi($device, $oid_list, '-OUQs', 'HOST-RESOURCES-MIB'); if (is_numeric($hrSystem[0]['hrSystemProcesses'])) { - $tags = array( + $tags = [ 'rrd_def' => RrdDefinition::make()->addDataset('procs', 'GAUGE', 0), - ); - $fields = array( + ]; + $fields = [ 'procs' => $hrSystem[0]['hrSystemProcesses'], - ); + ]; data_update($device, 'hr_processes', $tags, $fields); @@ -22,12 +22,12 @@ if (is_numeric($hrSystem[0]['hrSystemProcesses'])) { } if (is_numeric($hrSystem[0]['hrSystemNumUsers'])) { - $tags = array( - 'rrd_def' => RrdDefinition::make()->addDataset('users', 'GAUGE', 0) - ); - $fields = array( + $tags = [ + 'rrd_def' => RrdDefinition::make()->addDataset('users', 'GAUGE', 0), + ]; + $fields = [ 'users' => $hrSystem[0]['hrSystemNumUsers'], - ); + ]; data_update($device, 'hr_users', $tags, $fields); diff --git a/includes/polling/ipSystemStats.inc.php b/includes/polling/ipSystemStats.inc.php index fa7ecc7e34..2e51765d2c 100644 --- a/includes/polling/ipSystemStats.inc.php +++ b/includes/polling/ipSystemStats.inc.php @@ -52,7 +52,7 @@ use LibreNMS\RRD\RrdDefinition; $data = snmpwalk_cache_oid($device, 'ipSystemStats', null, 'IP-MIB'); if ($data) { - $oids = array( + $oids = [ 'ipSystemStatsInReceives', 'ipSystemStatsInHdrErrors', 'ipSystemStatsInAddrErrors', @@ -69,7 +69,7 @@ if ($data) { 'ipSystemStatsOutFragFails', 'ipSystemStatsOutFragCreates', 'ipSystemStatsOutForwDatagrams', - ); + ]; foreach ($data as $af => $stats) { echo "$af "; @@ -95,12 +95,12 @@ if ($data) { $stats['ipSystemStatsOutForwDatagrams'] = $stats['ipSystemStatsHCOutForwDatagrams']; } - $rrd_name = array('ipSystemStats', $af); + $rrd_name = ['ipSystemStats', $af]; $rrd_def = new RrdDefinition(); - $fields = array(); + $fields = []; foreach ($oids as $oid) { - $oid_ds = str_replace('ipSystemStats', '', $oid); + $oid_ds = str_replace('ipSystemStats', '', $oid); $rrd_def->addDataset($oid_ds, 'COUNTER'); if (strstr($stats[$oid], 'No') || strstr($stats[$oid], 'd') || strstr($stats[$oid], 's')) { $stats[$oid] = '0'; diff --git a/includes/polling/ipmi.inc.php b/includes/polling/ipmi.inc.php index c2e9b2144e..f2e1aee372 100644 --- a/includes/polling/ipmi.inc.php +++ b/includes/polling/ipmi.inc.php @@ -3,7 +3,7 @@ use LibreNMS\Config; use LibreNMS\RRD\RrdDefinition; -$ipmi_rows = dbFetchRows("SELECT * FROM sensors WHERE device_id = ? AND poller_type='ipmi'", array($device['device_id'])); +$ipmi_rows = dbFetchRows("SELECT * FROM sensors WHERE device_id = ? AND poller_type='ipmi'", [$device['device_id']]); if (is_array($ipmi_rows)) { d_echo($ipmi_rows); @@ -32,7 +32,7 @@ if (is_array($ipmi_rows)) { } foreach (explode("\n", $results) as $row) { - list($desc, $value, $type, $status) = explode(',', $row); + [$desc, $value, $type, $status] = explode(',', $row); $desc = trim($desc, ' '); $ipmi_unit_type = Config::get("ipmi_unit.$type"); $ipmi_sensor[$desc][$ipmi_unit_type]['value'] = $value; @@ -50,27 +50,27 @@ if (is_array($ipmi_rows)) { $rrd_name = get_sensor_rrd_name($device, $ipmisensors); $rrd_def = RrdDefinition::make()->addDataset('sensor', 'GAUGE', -20000, 20000); - $fields = array( + $fields = [ 'sensor' => $sensor_value, - ); + ]; - $tags = array( + $tags = [ 'sensor_class' => $ipmisensors['sensor_class'], 'sensor_type' => $ipmisensors['sensor_type'], 'sensor_descr' => $ipmisensors['sensor_descr'], 'sensor_index' => $ipmisensors['sensor_index'], 'rrd_name' => $rrd_name, - 'rrd_def' => $rrd_def - ); + 'rrd_def' => $rrd_def, + ]; data_update($device, 'ipmi', $tags, $fields); // FIXME warnings in event & mail not done here yet! dbUpdate( - array('sensor_current' => $sensor_value, - 'lastupdate' => array('NOW()')), + ['sensor_current' => $sensor_value, + 'lastupdate' => ['NOW()'], ], 'sensors', 'poller_type = ? AND sensor_class = ? AND sensor_id = ?', - array('ipmi', $ipmisensors['sensor_class'], $ipmisensors['sensor_id']) + ['ipmi', $ipmisensors['sensor_class'], $ipmisensors['sensor_id']] ); } diff --git a/includes/polling/junose-atm-vp.inc.php b/includes/polling/junose-atm-vp.inc.php index 518fb26570..471f961684 100644 --- a/includes/polling/junose-atm-vp.inc.php +++ b/includes/polling/junose-atm-vp.inc.php @@ -2,10 +2,10 @@ use LibreNMS\RRD\RrdDefinition; -$vp_rows = dbFetchRows('SELECT * FROM `ports` AS P, `juniAtmVp` AS J WHERE P.`device_id` = ? AND J.port_id = P.port_id', array($device['device_id'])); +$vp_rows = dbFetchRows('SELECT * FROM `ports` AS P, `juniAtmVp` AS J WHERE P.`device_id` = ? AND J.port_id = P.port_id', [$device['device_id']]); if (count($vp_rows)) { - $vp_cache = array(); + $vp_cache = []; $vp_cache = snmpwalk_cache_multi_oid($device, 'juniAtmVpStatsInCells', $vp_cache, 'Juniper-UNI-ATM-MIB', 'junose'); $vp_cache = snmpwalk_cache_multi_oid($device, 'juniAtmVpStatsInPackets', $vp_cache, 'Juniper-UNI-ATM-MIB', 'junose'); $vp_cache = snmpwalk_cache_multi_oid($device, 'juniAtmVpStatsInPacketOctets', $vp_cache, 'Juniper-UNI-ATM-MIB', 'junose'); @@ -30,20 +30,20 @@ if (count($vp_rows)) { $ifIndex = $vp['ifIndex']; $vp_id = $vp['vp_id']; - $oid = $ifIndex .'.'. $vp_id; + $oid = $ifIndex . '.' . $vp_id; d_echo("$oid "); $t_vp = $vp_cache[$oid]; - $vp_update = $t_vp['juniAtmVpStatsInCells'].':'.$t_vp['juniAtmVpStatsOutCells']; - $vp_update .= ':'.$t_vp['juniAtmVpStatsInPackets'].':'.$t_vp['juniAtmVpStatsOutPackets']; - $vp_update .= ':'.$t_vp['juniAtmVpStatsInPacketOctets'].':'.$t_vp['juniAtmVpStatsOutPacketOctets']; - $vp_update .= ':'.$t_vp['juniAtmVpStatsInPacketErrors'].':'.$t_vp['juniAtmVpStatsOutPacketErrors']; + $vp_update = $t_vp['juniAtmVpStatsInCells'] . ':' . $t_vp['juniAtmVpStatsOutCells']; + $vp_update .= ':' . $t_vp['juniAtmVpStatsInPackets'] . ':' . $t_vp['juniAtmVpStatsOutPackets']; + $vp_update .= ':' . $t_vp['juniAtmVpStatsInPacketOctets'] . ':' . $t_vp['juniAtmVpStatsOutPacketOctets']; + $vp_update .= ':' . $t_vp['juniAtmVpStatsInPacketErrors'] . ':' . $t_vp['juniAtmVpStatsOutPacketErrors']; - $rrd_name = array('vp', $ifIndex, $vp_id); + $rrd_name = ['vp', $ifIndex, $vp_id]; - $fields = array( + $fields = [ 'incells' => $t_vp['juniAtmVpStatsInCells'], 'outcells' => $t_vp['juniAtmVpStatsOutCells'], 'inpackets' => $t_vp['juniAtmVpStatsInPackets'], @@ -52,7 +52,7 @@ if (count($vp_rows)) { 'outpacketoctets' => $t_vp['juniAtmVpStatsOutPacketOctets'], 'inpacketerrors' => $t_vp['juniAtmVpStatsInPacketErrors'], 'outpacketerrors' => $t_vp['juniAtmVpStatsOutPacketErrors'], - ); + ]; $tags = compact('ifIndex', 'vp_id', 'rrd_name', 'rrd_def'); data_update($device, 'atm-vp', $tags, $fields); diff --git a/includes/polling/loadbalancers/f5-gtm.inc.php b/includes/polling/loadbalancers/f5-gtm.inc.php index 90587af4f5..b6121c24da 100644 --- a/includes/polling/loadbalancers/f5-gtm.inc.php +++ b/includes/polling/loadbalancers/f5-gtm.inc.php @@ -15,7 +15,7 @@ use LibreNMS\RRD\RrdDefinition; // Define some error messages -$error_poolaction = array(); +$error_poolaction = []; $error_poolaction[0] = "Unused"; $error_poolaction[1] = "Reboot"; $error_poolaction[2] = "Restart"; @@ -25,16 +25,16 @@ $error_poolaction[5] = "Go Active"; $error_poolaction[6] = "None"; $component = new LibreNMS\Component(); -$options['filter']['disabled'] = array('=',0); -$options['filter']['ignore'] = array('=',0); +$options['filter']['disabled'] = ['=', 0]; +$options['filter']['ignore'] = ['=', 0]; $components = $component->getComponents($device['device_id'], $options); // We only care about our device id. $components = $components[$device['device_id']]; // We extracted all the components for this device, now lets only get the GTM ones. -$keep = array(); -$types = array('f5-gtm-wide', 'f5-gtm-pool'); +$keep = []; +$types = ['f5-gtm-wide', 'f5-gtm-pool']; foreach ($components as $k => $v) { foreach ($types as $type) { if ($v['type'] == $type) { @@ -63,7 +63,7 @@ if (count($components > 0)) { $UID = $array['UID']; $label = $array['label']; $hash = $array['hash']; - $rrd_name = array($type, $label, $hash); + $rrd_name = [$type, $label, $hash]; if ($type == 'f5-gtm-wide') { $rrd_def = RrdDefinition::make() @@ -71,32 +71,32 @@ if (count($components > 0)) { ->addDataset('resolved', 'COUNTER', 0) ->addDataset('dropped', 'COUNTER', 0); - $fields = array( - 'requests' => $f5_stats['gtmWideIPStatEntryRequests']['1.3.6.1.4.1.3375.2.3.12.2.3.1.2.'.$UID], - 'resolved' => $f5_stats['gtmWideIPStatEntryResolved']['1.3.6.1.4.1.3375.2.3.12.2.3.1.3.'.$UID], - 'dropped' => $f5_stats['gtmWideIPStatEntryDropped']['1.3.6.1.4.1.3375.2.3.12.2.3.1.7.'.$UID], - ); + $fields = [ + 'requests' => $f5_stats['gtmWideIPStatEntryRequests']['1.3.6.1.4.1.3375.2.3.12.2.3.1.2.' . $UID], + 'resolved' => $f5_stats['gtmWideIPStatEntryResolved']['1.3.6.1.4.1.3375.2.3.12.2.3.1.3.' . $UID], + 'dropped' => $f5_stats['gtmWideIPStatEntryDropped']['1.3.6.1.4.1.3375.2.3.12.2.3.1.7.' . $UID], + ]; // Let's print some debugging info. - d_echo("\n\nComponent: ".$key."\n"); - d_echo(" Type: ".$type."\n"); - d_echo(" Label: ".$label."\n"); + d_echo("\n\nComponent: " . $key . "\n"); + d_echo(" Type: " . $type . "\n"); + d_echo(" Label: " . $label . "\n"); } elseif ($type == 'f5-gtm-pool') { $rrd_def = RrdDefinition::make() ->addDataset('resolved', 'COUNTER', 0) ->addDataset('dropped', 'COUNTER', 0); - $fields = array( - 'resolved' => $f5_stats['gtmPoolEntryResolved']['1.3.6.1.4.1.3375.2.3.6.2.3.1.2.'.$UID], - 'dropped' => $f5_stats['gtmPoolEntryDropped']['1.3.6.1.4.1.3375.2.3.6.2.3.1.5.'.$UID], - ); + $fields = [ + 'resolved' => $f5_stats['gtmPoolEntryResolved']['1.3.6.1.4.1.3375.2.3.6.2.3.1.2.' . $UID], + 'dropped' => $f5_stats['gtmPoolEntryDropped']['1.3.6.1.4.1.3375.2.3.6.2.3.1.5.' . $UID], + ]; // Let's print some debugging info. - d_echo("\n\nComponent: ".$key."\n"); - d_echo(" Type: ".$type."\n"); - d_echo(" Label: ".$label."\n"); + d_echo("\n\nComponent: " . $key . "\n"); + d_echo(" Type: " . $type . "\n"); + d_echo(" Label: " . $label . "\n"); } else { - d_echo("Type is unknown: ".$type."\n"); + d_echo("Type is unknown: " . $type . "\n"); continue; } diff --git a/includes/polling/loadbalancers/f5-ltm.inc.php b/includes/polling/loadbalancers/f5-ltm.inc.php index 3c0624b52d..ebe28303c7 100644 --- a/includes/polling/loadbalancers/f5-ltm.inc.php +++ b/includes/polling/loadbalancers/f5-ltm.inc.php @@ -14,7 +14,7 @@ use LibreNMS\RRD\RrdDefinition; // Define some error messages -$error_poolaction = array(); +$error_poolaction = []; $error_poolaction[0] = "Unused"; $error_poolaction[1] = "Reboot"; $error_poolaction[2] = "Restart"; @@ -24,16 +24,16 @@ $error_poolaction[5] = "Go Active"; $error_poolaction[6] = "None"; $component = new LibreNMS\Component(); -$options['filter']['disabled'] = array('=',0); -$options['filter']['ignore'] = array('=',0); +$options['filter']['disabled'] = ['=', 0]; +$options['filter']['ignore'] = ['=', 0]; $components = $component->getComponents($device['device_id'], $options); // We only care about our device id. $components = $components[$device['device_id']]; // We extracted all the components for this device, now lets only get the LTM ones. -$keep = array(); -$types = array('f5-ltm-vs', 'f5-ltm-bwc', 'f5-ltm-pool', 'f5-ltm-poolmember'); +$keep = []; +$types = ['f5-ltm-vs', 'f5-ltm-bwc', 'f5-ltm-pool', 'f5-ltm-poolmember']; foreach ($components as $k => $v) { foreach ($types as $type) { if ($v['type'] == $type) { @@ -82,7 +82,7 @@ if (count($components > 0)) { $UID = $array['UID']; $label = $array['label']; $hash = $array['hash']; - $rrd_name = array($type, $label, $hash); + $rrd_name = [$type, $label, $hash]; if ($type == 'f5-ltm-bwc') { $rrd_def = RrdDefinition::make() @@ -91,17 +91,17 @@ if (count($components > 0)) { ->addDataset('bytesdropped', 'COUNTER', 0) ->addDataset('bytespassed', 'COUNTER', 0); - $fields = array( - 'pktsin' => $f5_stats['ltmBwcEntryPktsin']['1.3.6.1.4.1.3375.2.2.13.1.3.1.7.'.$UID], - 'bytesin' => $f5_stats['ltmBwcEntryBytesin']['1.3.6.1.4.1.3375.2.2.13.1.3.1.4.'.$UID], - 'bytesdropped' => $f5_stats['ltmBwcEntryBytesDropped']['1.3.6.1.4.1.3375.2.2.13.1.3.1.6.'.$UID], - 'bytespassed' => $f5_stats['ltmBwcEntryBytesPassed']['1.3.6.1.4.1.3375.2.2.13.1.3.1.5.'.$UID], - ); + $fields = [ + 'pktsin' => $f5_stats['ltmBwcEntryPktsin']['1.3.6.1.4.1.3375.2.2.13.1.3.1.7.' . $UID], + 'bytesin' => $f5_stats['ltmBwcEntryBytesin']['1.3.6.1.4.1.3375.2.2.13.1.3.1.4.' . $UID], + 'bytesdropped' => $f5_stats['ltmBwcEntryBytesDropped']['1.3.6.1.4.1.3375.2.2.13.1.3.1.6.' . $UID], + 'bytespassed' => $f5_stats['ltmBwcEntryBytesPassed']['1.3.6.1.4.1.3375.2.2.13.1.3.1.5.' . $UID], + ]; // Let's print some debugging info. - d_echo("\n\nComponent: ".$key."\n"); - d_echo(" Type: ".$type."\n"); - d_echo(" Label: ".$label."\n"); + d_echo("\n\nComponent: " . $key . "\n"); + d_echo(" Type: " . $type . "\n"); + d_echo(" Label: " . $label . "\n"); } elseif ($type == 'f5-ltm-vs') { $rrd_def = RrdDefinition::make() ->addDataset('pktsin', 'COUNTER', 0) @@ -110,25 +110,25 @@ if (count($components > 0)) { ->addDataset('bytesout', 'COUNTER', 0) ->addDataset('totconns', 'COUNTER', 0); - $fields = array( - 'pktsin' => $f5_stats['ltmVirtualServStatEntryPktsin']['1.3.6.1.4.1.3375.2.2.10.2.3.1.6.'.$UID], - 'pktsout' => $f5_stats['ltmVirtualServStatEntryPktsout']['1.3.6.1.4.1.3375.2.2.10.2.3.1.8.'.$UID], - 'bytesin' => $f5_stats['ltmVirtualServStatEntryBytesin']['1.3.6.1.4.1.3375.2.2.10.2.3.1.7.'.$UID], - 'bytesout' => $f5_stats['ltmVirtualServStatEntryBytesout']['1.3.6.1.4.1.3375.2.2.10.2.3.1.9.'.$UID], - 'totconns' => $f5_stats['ltmVirtualServStatEntryTotconns']['1.3.6.1.4.1.3375.2.2.10.2.3.1.11.'.$UID], - ); + $fields = [ + 'pktsin' => $f5_stats['ltmVirtualServStatEntryPktsin']['1.3.6.1.4.1.3375.2.2.10.2.3.1.6.' . $UID], + 'pktsout' => $f5_stats['ltmVirtualServStatEntryPktsout']['1.3.6.1.4.1.3375.2.2.10.2.3.1.8.' . $UID], + 'bytesin' => $f5_stats['ltmVirtualServStatEntryBytesin']['1.3.6.1.4.1.3375.2.2.10.2.3.1.7.' . $UID], + 'bytesout' => $f5_stats['ltmVirtualServStatEntryBytesout']['1.3.6.1.4.1.3375.2.2.10.2.3.1.9.' . $UID], + 'totconns' => $f5_stats['ltmVirtualServStatEntryTotconns']['1.3.6.1.4.1.3375.2.2.10.2.3.1.11.' . $UID], + ]; // Let's print some debugging info. - d_echo("\n\nComponent: ".$key."\n"); - d_echo(" Type: ".$type."\n"); - d_echo(" Label: ".$label."\n"); + d_echo("\n\nComponent: " . $key . "\n"); + d_echo(" Type: " . $type . "\n"); + d_echo(" Label: " . $label . "\n"); // Let's check the status. - $array['state'] = $f5_stats['ltmVsStatusEntryState']['1.3.6.1.4.1.3375.2.2.10.13.2.1.2.'.$UID]; + $array['state'] = $f5_stats['ltmVsStatusEntryState']['1.3.6.1.4.1.3375.2.2.10.13.2.1.2.' . $UID]; if (($array['state'] == 2) || ($array['state'] == 3)) { // The Virtual Server is unavailable. $array['status'] = 2; - $array['error'] = $f5_stats['ltmVsStatusEntryMsg']['1.3.6.1.4.1.3375.2.2.10.13.2.1.5.'.$UID]; + $array['error'] = $f5_stats['ltmVsStatusEntryMsg']['1.3.6.1.4.1.3375.2.2.10.13.2.1.5.' . $UID]; } else { // All is good. $array['status'] = 0; @@ -139,26 +139,26 @@ if (count($components > 0)) { ->addDataset('minup', 'GAUGE', 0) ->addDataset('currup', 'GAUGE', 0); - $array['minup'] = $f5_stats['ltmPoolEntryMinup']['1.3.6.1.4.1.3375.2.2.5.1.2.1.4.'.$UID]; - $array['minupstatus'] = $f5_stats['ltmPoolEntryMinupstatus']['1.3.6.1.4.1.3375.2.2.5.1.2.1.5.'.$UID]; - $array['currentup'] = $f5_stats['ltmPoolEntryCurrentup']['1.3.6.1.4.1.3375.2.2.5.1.2.1.8.'.$UID]; - $array['minupaction'] = $f5_stats['ltmPoolEntryMinupaction']['1.3.6.1.4.1.3375.2.2.5.1.2.1.6.'.$UID]; + $array['minup'] = $f5_stats['ltmPoolEntryMinup']['1.3.6.1.4.1.3375.2.2.5.1.2.1.4.' . $UID]; + $array['minupstatus'] = $f5_stats['ltmPoolEntryMinupstatus']['1.3.6.1.4.1.3375.2.2.5.1.2.1.5.' . $UID]; + $array['currentup'] = $f5_stats['ltmPoolEntryCurrentup']['1.3.6.1.4.1.3375.2.2.5.1.2.1.8.' . $UID]; + $array['minupaction'] = $f5_stats['ltmPoolEntryMinupaction']['1.3.6.1.4.1.3375.2.2.5.1.2.1.6.' . $UID]; - $fields = array( + $fields = [ 'minup' => $array['minup'], 'currup' => $array['currentup'], - ); + ]; // Let's print some debugging info. - d_echo("\n\nComponent: ".$key."\n"); - d_echo(" Type: ".$type."\n"); - d_echo(" Label: ".$label."\n"); + d_echo("\n\nComponent: " . $key . "\n"); + d_echo(" Type: " . $type . "\n"); + d_echo(" Label: " . $label . "\n"); // If we have less pool members than the minimum, we should error. if ($array['currentup'] < $array['minup']) { // Danger Will Robinson... We dont have enough Pool Members! $array['status'] = 2; - $array['error'] = "Minimum Pool Members not met. Action taken: ".$error_poolaction[$array['minupaction']]; + $array['error'] = "Minimum Pool Members not met. Action taken: " . $error_poolaction[$array['minupaction']]; } else { // All is good. $array['status'] = 0; @@ -172,35 +172,35 @@ if (count($components > 0)) { ->addDataset('bytesout', 'COUNTER', 0) ->addDataset('totconns', 'COUNTER', 0); - $array['state'] = $f5_stats['ltmPoolMbrStatusEntryState']['1.3.6.1.4.1.3375.2.2.5.6.2.1.5.'.$UID]; - $array['available'] = $f5_stats['ltmPoolMbrStatusEntryAvail']['1.3.6.1.4.1.3375.2.2.5.6.2.1.6.'.$UID]; + $array['state'] = $f5_stats['ltmPoolMbrStatusEntryState']['1.3.6.1.4.1.3375.2.2.5.6.2.1.5.' . $UID]; + $array['available'] = $f5_stats['ltmPoolMbrStatusEntryAvail']['1.3.6.1.4.1.3375.2.2.5.6.2.1.6.' . $UID]; - $fields = array( - 'pktsin' => $f5_stats['ltmPoolMemberStatEntryPktsin']['1.3.6.1.4.1.3375.2.2.5.4.3.1.5.'.$UID], - 'pktsout' => $f5_stats['ltmPoolMemberStatEntryPktsout']['1.3.6.1.4.1.3375.2.2.5.4.3.1.7.'.$UID], - 'bytesin' => $f5_stats['ltmPoolMemberStatEntryBytesin']['1.3.6.1.4.1.3375.2.2.5.4.3.1.6.'.$UID], - 'bytesout' => $f5_stats['ltmPoolMemberStatEntryBytesout']['1.3.6.1.4.1.3375.2.2.5.4.3.1.8.'.$UID], - 'totconns' => $f5_stats['ltmPoolMemberStatEntryTotconns']['1.3.6.1.4.1.3375.2.2.5.4.3.1.10.'.$UID], - ); + $fields = [ + 'pktsin' => $f5_stats['ltmPoolMemberStatEntryPktsin']['1.3.6.1.4.1.3375.2.2.5.4.3.1.5.' . $UID], + 'pktsout' => $f5_stats['ltmPoolMemberStatEntryPktsout']['1.3.6.1.4.1.3375.2.2.5.4.3.1.7.' . $UID], + 'bytesin' => $f5_stats['ltmPoolMemberStatEntryBytesin']['1.3.6.1.4.1.3375.2.2.5.4.3.1.6.' . $UID], + 'bytesout' => $f5_stats['ltmPoolMemberStatEntryBytesout']['1.3.6.1.4.1.3375.2.2.5.4.3.1.8.' . $UID], + 'totconns' => $f5_stats['ltmPoolMemberStatEntryTotconns']['1.3.6.1.4.1.3375.2.2.5.4.3.1.10.' . $UID], + ]; // Let's print some debugging info. - d_echo("\n\nComponent: ".$key."\n"); - d_echo(" Type: ".$type."\n"); - d_echo(" Label: ".$label."\n"); + d_echo("\n\nComponent: " . $key . "\n"); + d_echo(" Type: " . $type . "\n"); + d_echo(" Label: " . $label . "\n"); // If available and bad state // 0 = None, 1 = Green, 2 = Yellow, 3 = Red, 4 = Blue if (($array['available'] == 1) && ($array['state'] == 3)) { // Warning Alarm, the pool member is down. $array['status'] = 1; - $array['error'] = "Pool Member is Down: ".$f5_stats['ltmPoolMbrStatusEntryMsg']['1.3.6.1.4.1.3375.2.2.5.6.2.1.8.'.$UID]; + $array['error'] = "Pool Member is Down: " . $f5_stats['ltmPoolMbrStatusEntryMsg']['1.3.6.1.4.1.3375.2.2.5.6.2.1.8.' . $UID]; } else { // All is good. $array['status'] = 0; $array['error'] = ''; } } else { - d_echo("Type is unknown: ".$type."\n"); + d_echo("Type is unknown: " . $type . "\n"); continue; } diff --git a/includes/polling/mef.inc.php b/includes/polling/mef.inc.php index 9027443980..11b10f6f2c 100644 --- a/includes/polling/mef.inc.php +++ b/includes/polling/mef.inc.php @@ -6,13 +6,13 @@ echo 'MEF Links: '; * Get a list of all the known MEF Links for this host. */ -$db_info_list = dbFetchRows('SELECT id, mefID, mefType, mefIdent, mefMTU, mefAdmState, mefRowState FROM mefinfo WHERE device_id = ?', array($device['device_id'])); +$db_info_list = dbFetchRows('SELECT id, mefID, mefType, mefIdent, mefMTU, mefAdmState, mefRowState FROM mefinfo WHERE device_id = ?', [$device['device_id']]); -if (!empty($db_info_list)) { - $current_mefinfo = snmpwalk_cache_multi_oid($device, 'MefServiceEvcCfgEntry', array(), 'MEF-UNI-EVC-MIB'); +if (! empty($db_info_list)) { + $current_mefinfo = snmpwalk_cache_multi_oid($device, 'MefServiceEvcCfgEntry', [], 'MEF-UNI-EVC-MIB'); foreach ($db_info_list as $db_info) { - $mef_info = array(); + $mef_info = []; $mef_info['mefType'] = $current_mefinfo[$db_info['mefID']]['mefServiceEvcCfgServiceType']; $mef_info['mefIdent'] = $current_mefinfo[$db_info['mefID']]['mefServiceEvcCfgIdentifier']; @@ -37,7 +37,7 @@ if (!empty($db_info_list)) { */ if ($mef_info[$property] != $db_info[$property]) { // FIXME - this should loop building a query and then run the query after the loop (bad geert!) - dbUpdate(array($property => mres($mef_info[$property])), 'mefinfo', '`id` = ?', array($db_info['id'])); + dbUpdate([$property => mres($mef_info[$property])], 'mefinfo', '`id` = ?', [$db_info['id']]); if ($db_info['mefIdent'] != null) { log_event("MEF Link : " . mres($db_info['mefIdent']) . ' (' . preg_replace('/^mef/', '', mres($db_info[$property])) . ') -> ' . $mef_info[$property], $device); } diff --git a/includes/polling/mempools.inc.php b/includes/polling/mempools.inc.php index 82854795e2..b21507eb1c 100644 --- a/includes/polling/mempools.inc.php +++ b/includes/polling/mempools.inc.php @@ -2,8 +2,8 @@ use LibreNMS\RRD\RrdDefinition; -foreach (dbFetchRows('SELECT * FROM mempools WHERE device_id = ?', array($device['device_id'])) as $mempool) { - echo 'Mempool '.$mempool['mempool_descr'].': '; +foreach (dbFetchRows('SELECT * FROM mempools WHERE device_id = ?', [$device['device_id']]) as $mempool) { + echo 'Mempool ' . $mempool['mempool_descr'] . ': '; $mempool_type = $mempool['mempool_type']; $mempool_index = $mempool['mempool_index']; @@ -19,37 +19,37 @@ foreach (dbFetchRows('SELECT * FROM mempools WHERE device_id = ?', array($device $percent = 0; } - echo $percent.'% '; + echo $percent . '% '; - $rrd_name = array('mempool', $mempool_type, $mempool_index); + $rrd_name = ['mempool', $mempool_type, $mempool_index]; $rrd_def = RrdDefinition::make() ->addDataset('used', 'GAUGE', 0) ->addDataset('free', 'GAUGE', 0); - $fields = array( + $fields = [ 'used' => $mempool['used'], 'free' => $mempool['free'], - ); + ]; $tags = compact('mempool_type', 'mempool_index', 'rrd_name', 'rrd_def'); data_update($device, 'mempool', $tags, $fields); - $mempool['state'] = array( - 'mempool_used' => $mempool['used'], - 'mempool_perc' => $percent, - 'mempool_free' => $mempool['free'], - 'mempool_total' => $mempool['total'], - ); + $mempool['state'] = [ + 'mempool_used' => $mempool['used'], + 'mempool_perc' => $percent, + 'mempool_free' => $mempool['free'], + 'mempool_total' => $mempool['total'], + ]; - if (!empty($mempool['largestfree'])) { + if (! empty($mempool['largestfree'])) { $mempool['state']['mempool_largestfree'] = set_numeric($mempool['largestfree']); } - if (!empty($mempool['lowestfree'])) { + if (! empty($mempool['lowestfree'])) { $mempool['state']['mempool_lowestfree'] = set_numeric($mempool['lowestfree']); } - dbUpdate($mempool['state'], 'mempools', '`mempool_id` = ?', array($mempool['mempool_id'])); + dbUpdate($mempool['state'], 'mempools', '`mempool_id` = ?', [$mempool['mempool_id']]); echo "\n"; }//end foreach diff --git a/includes/polling/mempools/3com.inc.php b/includes/polling/mempools/3com.inc.php index fa9adc9ce4..89f28c5aee 100644 --- a/includes/polling/mempools/3com.inc.php +++ b/includes/polling/mempools/3com.inc.php @@ -22,7 +22,6 @@ * @copyright 2017 Neil Lathwood * @author Neil Lathwood */ - if ($device['os'] === '3com') { echo '3COM:'; diff --git a/includes/polling/mempools/acos.inc.php b/includes/polling/mempools/acos.inc.php index 5df3a23fa3..ddd0362dc5 100644 --- a/includes/polling/mempools/acos.inc.php +++ b/includes/polling/mempools/acos.inc.php @@ -22,7 +22,6 @@ * @copyright 2016 Neil Lathwood * @author Neil Lathwood */ - if ($device['os'] === 'acos') { echo 'ACOS: '; $mempool['used'] = snmp_get($device, 'axSysMemoryUsage.0', '-Ovq', 'A10-AX-MIB'); diff --git a/includes/polling/mempools/adtran-aos.inc.php b/includes/polling/mempools/adtran-aos.inc.php index 555e6c9aba..0aa7adbf9e 100644 --- a/includes/polling/mempools/adtran-aos.inc.php +++ b/includes/polling/mempools/adtran-aos.inc.php @@ -12,14 +12,12 @@ * the source code distribution for details. */ - /* / ADTRAN-AOSCPU::adGenAOSMemPool.0 = Gauge32: 67108863 / ADTRAN-AOSCPU::adGenAOSHeapSize.0 = Gauge32: 39853040 / ADTRAN-AOSCPU::adGenAOSHeapFree.0 = Gauge32: 25979888 */ - -$mempool['used'] = snmp_get($device, 'adGenAOSHeapSize.0', '-OvQ', 'ADTRAN-AOSCPU'); +$mempool['used'] = snmp_get($device, 'adGenAOSHeapSize.0', '-OvQ', 'ADTRAN-AOSCPU'); $mempool['total'] = snmp_get($device, 'adGenAOSMemPool.0', '-OvQ', 'ADTRAN-AOSCPU'); -$mempool['free'] = ($mempool['total'] - $mempool['used']); +$mempool['free'] = ($mempool['total'] - $mempool['used']); diff --git a/includes/polling/mempools/alteonos.inc.php b/includes/polling/mempools/alteonos.inc.php index 823c5fe551..a1ecaed72b 100644 --- a/includes/polling/mempools/alteonos.inc.php +++ b/includes/polling/mempools/alteonos.inc.php @@ -20,7 +20,7 @@ $perc = ($total / $free) * 100; $used = ($total - $free); if (is_numeric($used) && is_numeric($free) && is_numeric($perc)) { $mempool['total'] = $total; - $mempool['free'] = $free; - $mempool['used'] = $used; - $mempool['perc'] = $perc; + $mempool['free'] = $free; + $mempool['used'] = $used; + $mempool['perc'] = $perc; } diff --git a/includes/polling/mempools/aos6.inc.php b/includes/polling/mempools/aos6.inc.php index a89840a993..3f32665fda 100755 --- a/includes/polling/mempools/aos6.inc.php +++ b/includes/polling/mempools/aos6.inc.php @@ -3,7 +3,7 @@ $mempool['units'] = '1'; $mempool['total'] = snmp_get($device, 'systemHardwareMemorySize.0', '-OvQ', 'ALCATEL-IND1-SYSTEM-MIB'); -$percent = snmp_get($device, 'healthDeviceMemoryLatest.0', '-OvQ', 'ALCATEL-IND1-HEALTH-MIB'); +$percent = snmp_get($device, 'healthDeviceMemoryLatest.0', '-OvQ', 'ALCATEL-IND1-HEALTH-MIB'); $mempool['used'] = ($mempool['total'] * ($percent / 100)); $mempool['free'] = ($mempool['total'] - $mempool['used']); diff --git a/includes/polling/mempools/aos7.inc.php b/includes/polling/mempools/aos7.inc.php index 9fdd171b02..e0ec7fe78c 100755 --- a/includes/polling/mempools/aos7.inc.php +++ b/includes/polling/mempools/aos7.inc.php @@ -4,7 +4,7 @@ $mempool['units'] = '1'; $mempool['total'] = snmp_get($device, '.1.3.6.1.4.1.6486.801.1.1.1.2.1.1.3.4.0', '-OvQ', 'ALCATEL-IND1-SYSTEM-MIB', 'nokia/aos7'); $mempool['total'] *= 1024; // Memory in MB -$percent = snmp_get($device, '.1.3.6.1.4.1.6486.801.1.2.1.16.1.1.1.1.1.8.0', '-OvQ', 'ALCATEL-IND1-HEALTH-MIB', 'nokia/aos7'); +$percent = snmp_get($device, '.1.3.6.1.4.1.6486.801.1.2.1.16.1.1.1.1.1.8.0', '-OvQ', 'ALCATEL-IND1-HEALTH-MIB', 'nokia/aos7'); $mempool['used'] = ($mempool['total'] * ($percent / 100)); $mempool['free'] = ($mempool['total'] - $mempool['used']); diff --git a/includes/polling/mempools/aruba-instant.inc.php b/includes/polling/mempools/aruba-instant.inc.php index 5ec120b818..0f7c9193e9 100644 --- a/includes/polling/mempools/aruba-instant.inc.php +++ b/includes/polling/mempools/aruba-instant.inc.php @@ -28,19 +28,19 @@ $mempool_data = snmpwalk_group($device, 'aiAPSerialNum', 'AI-AP-MIB'); $mempool_data = snmpwalk_group($device, 'aiAPTotalMemory', 'AI-AP-MIB', 1, $mempool_data); $mempool_data = snmpwalk_group($device, 'aiAPMemoryFree', 'AI-AP-MIB', 1, $mempool_data); -d_echo('$mempool_data:'.PHP_EOL); +d_echo('$mempool_data:' . PHP_EOL); d_echo($mempool_data); foreach ($mempool_data as $index => $entry) { - d_echo($entry['aiAPSerialNum'].' '.$entry['aiAPTotalMemory'].' / '.$entry['aiAPMemoryFree'].PHP_EOL); + d_echo($entry['aiAPSerialNum'] . ' ' . $entry['aiAPTotalMemory'] . ' / ' . $entry['aiAPMemoryFree'] . PHP_EOL); - $total = $entry['aiAPTotalMemory']; - $free = $entry['aiAPMemoryFree']; - $used = $total - $free; - $perc = ($used / $total * 100); + $total = $entry['aiAPTotalMemory']; + $free = $entry['aiAPMemoryFree']; + $used = $total - $free; + $perc = ($used / $total * 100); $mempool['total'] = $total; - $mempool['used'] = $used; - $mempool['free'] = $free; - $mempool['perc'] = $perc; + $mempool['used'] = $used; + $mempool['free'] = $free; + $mempool['perc'] = $perc; } //end foreach diff --git a/includes/polling/mempools/arubaos.inc.php b/includes/polling/mempools/arubaos.inc.php index eb868375fb..79629dab8e 100644 --- a/includes/polling/mempools/arubaos.inc.php +++ b/includes/polling/mempools/arubaos.inc.php @@ -5,6 +5,6 @@ $memory_pool = snmp_get_multi_oid($device, ['sysXMemorySize.1', 'sysXMemoryUsed.1', 'sysXMemoryFree.1'], '-OQUs', 'WLSX-SWITCH-MIB'); $mempool['total'] = $memory_pool['sysXMemorySize.1'] * 1024; - $mempool['used'] = $memory_pool['sysXMemoryUsed.1'] * 1024; - $mempool['free'] = $memory_pool['sysXMemoryFree.1'] * 1024; - $mempool['perc'] = ($mempool['used'] / $mempool['total'] * 100); + $mempool['used'] = $memory_pool['sysXMemoryUsed.1'] * 1024; + $mempool['free'] = $memory_pool['sysXMemoryFree.1'] * 1024; + $mempool['perc'] = ($mempool['used'] / $mempool['total'] * 100); diff --git a/includes/polling/mempools/avaya-ers.inc.php b/includes/polling/mempools/avaya-ers.inc.php index 6d70b88a08..f73c0e4e83 100644 --- a/includes/polling/mempools/avaya-ers.inc.php +++ b/includes/polling/mempools/avaya-ers.inc.php @@ -6,5 +6,5 @@ $total = (snmp_get($device, ".1.3.6.1.4.1.45.1.6.3.8.1.1.12$index", '-Oqv') * 10 $avail = (snmp_get($device, ".1.3.6.1.4.1.45.1.6.3.8.1.1.13$index", '-Oqv') * 1048576); $mempool['total'] = $total; -$mempool['free'] = $avail; -$mempool['used'] = ($total - $avail); +$mempool['free'] = $avail; +$mempool['used'] = ($total - $avail); diff --git a/includes/polling/mempools/avaya-vsp.inc.php b/includes/polling/mempools/avaya-vsp.inc.php index ce139d9418..0da97e8d13 100644 --- a/includes/polling/mempools/avaya-vsp.inc.php +++ b/includes/polling/mempools/avaya-vsp.inc.php @@ -21,7 +21,7 @@ $perc = snmp_get($device, "1.3.6.1.4.1.2272.1.85.10.1.1.8.1", '-OvQ'); $total = ($used + $free); if (is_numeric($used) && is_numeric($free) && is_numeric($perc)) { $mempool['total'] = $total; - $mempool['free'] = $free; - $mempool['used'] = $used; - $mempool['perc'] = $perc; + $mempool['free'] = $free; + $mempool['used'] = $used; + $mempool['perc'] = $perc; } diff --git a/includes/polling/mempools/bdcom.inc.php b/includes/polling/mempools/bdcom.inc.php index 5d31b750a0..4c6875b2f9 100644 --- a/includes/polling/mempools/bdcom.inc.php +++ b/includes/polling/mempools/bdcom.inc.php @@ -20,7 +20,7 @@ echo 'BDCOM Memory Pool'; $memory_pool = snmp_get_multi_oid($device, ['bdcomMemoryPoolUsed.0', 'bdcomMemoryPoolFree.0'], '-OQUs', 'BDCOM-MEMORY-POOL-MIB'); -$mempool['free'] = ['bdcomMemoryPoolFree.0']; -$mempool['used'] = $memory_pool['bdcomMemoryPoolUsed.0']; +$mempool['free'] = ['bdcomMemoryPoolFree.0']; +$mempool['used'] = $memory_pool['bdcomMemoryPoolUsed.0']; $mempool['total'] = $mempool['free'] + $mempool['used']; -$mempool['perc'] = $mempool['used'] / $mempool['total']; +$mempool['perc'] = $mempool['used'] / $mempool['total']; diff --git a/includes/polling/mempools/benuos.inc.php b/includes/polling/mempools/benuos.inc.php index ef111e2f49..16074047a8 100644 --- a/includes/polling/mempools/benuos.inc.php +++ b/includes/polling/mempools/benuos.inc.php @@ -3,6 +3,6 @@ echo 'Benu'; $memdata = snmp_get_multi($device, ['bSysTotalMem.0', 'bSysMemUsed.0'], '-OQUs', 'BENU-HOST-MIB'); $mempool['total'] = $memdata[0]['bSysTotalMem']; -$mempool['used'] = $memdata[0]['bSysMemUsed']; -$mempool['free'] = ($mempool['total'] - $mempool['used']); -$mempool['perc'] = ($mempool['used'] / $mempool['total']) * 100; +$mempool['used'] = $memdata[0]['bSysMemUsed']; +$mempool['free'] = ($mempool['total'] - $mempool['used']); +$mempool['perc'] = ($mempool['used'] / $mempool['total']) * 100; diff --git a/includes/polling/mempools/binos.inc.php b/includes/polling/mempools/binos.inc.php index 37b93692de..84bd56c0a6 100644 --- a/includes/polling/mempools/binos.inc.php +++ b/includes/polling/mempools/binos.inc.php @@ -12,6 +12,6 @@ * the source code distribution for details. */ -$mempool['used'] = snmp_get($device, '.1.3.6.1.4.1.738.1.111.2.1.1.5.0', '-OvQ'); // PRVT-SYS-INFO-MIB::numBytesAlloc.0 = INTEGER: 48993320 -$mempool['free'] = snmp_get($device, '.1.3.6.1.4.1.738.1.111.2.1.1.1.0', '-OvQ'); // PRVT-SYS-INFO-MIB::numBytesFree.0 = INTEGER: 183136616 -$mempool['total'] = ($mempool['free'] + $mempool['used']); +$mempool['used'] = snmp_get($device, '.1.3.6.1.4.1.738.1.111.2.1.1.5.0', '-OvQ'); // PRVT-SYS-INFO-MIB::numBytesAlloc.0 = INTEGER: 48993320 +$mempool['free'] = snmp_get($device, '.1.3.6.1.4.1.738.1.111.2.1.1.1.0', '-OvQ'); // PRVT-SYS-INFO-MIB::numBytesFree.0 = INTEGER: 183136616 +$mempool['total'] = ($mempool['free'] + $mempool['used']); diff --git a/includes/polling/mempools/binox.inc.php b/includes/polling/mempools/binox.inc.php index 72997e2bb2..0cdc13c8e3 100644 --- a/includes/polling/mempools/binox.inc.php +++ b/includes/polling/mempools/binox.inc.php @@ -12,14 +12,13 @@ * the source code distribution for details. */ - // Somewhat of an ugly hack since Telco Systems device // don't support fetching total memory of the device over SNMP. Only used percentage. // Given OID returns usage in percent so we set total to 100 in order to get a proper graph -$mempool['total'] = "100"; -$usage = snmp_get($device, ".1.3.6.1.4.1.738.10.111.3.1.3.0", "-Ovq"); -$usage = str_replace('%', '', $usage); -$usage = str_replace('"', '', $usage); -$mempool['used'] = $usage; -$mempool['free'] = ($mempool['total'] - $mempool['used']); +$mempool['total'] = "100"; +$usage = snmp_get($device, ".1.3.6.1.4.1.738.10.111.3.1.3.0", "-Ovq"); +$usage = str_replace('%', '', $usage); +$usage = str_replace('"', '', $usage); +$mempool['used'] = $usage; +$mempool['free'] = ($mempool['total'] - $mempool['used']); diff --git a/includes/polling/mempools/cemp.inc.php b/includes/polling/mempools/cemp.inc.php index 6a753cf20b..f8586b84dc 100644 --- a/includes/polling/mempools/cemp.inc.php +++ b/includes/polling/mempools/cemp.inc.php @@ -2,19 +2,19 @@ $oid = $mempool['mempool_index']; -$HCoids = array( +$HCoids = [ "cempMemPoolHCUsed.$oid", "cempMemPoolHCFree.$oid", "cempMemPoolHCLargestFree.$oid", -); -$oids = array( +]; +$oids = [ "cempMemPoolUsed.$oid", "cempMemPoolFree.$oid", "cempMemPoolLargestFree.$oid", -); +]; $data = snmp_get_multi_oid($device, $HCoids, '-OUQ', 'CISCO-ENHANCED-MEMPOOL-MIB'); if (count($data) < 2) { $data = snmp_get_multi_oid($device, $oids, '-OUQ', 'CISCO-ENHANCED-MEMPOOL-MIB'); } -list($mempool['used'], $mempool['free'], $mempool['largestfree']) = array_values($data); +[$mempool['used'], $mempool['free'], $mempool['largestfree']] = array_values($data); $mempool['total'] = ($mempool['used'] + $mempool['free']); diff --git a/includes/polling/mempools/ciscowlc.inc.php b/includes/polling/mempools/ciscowlc.inc.php index 2bafc900a4..525a8f47ad 100644 --- a/includes/polling/mempools/ciscowlc.inc.php +++ b/includes/polling/mempools/ciscowlc.inc.php @@ -6,5 +6,5 @@ $total = str_replace('"', "", snmp_get($device, "1.3.6.1.4.1.14179.1.1.5.2.0", ' $avail = str_replace('"', "", snmp_get($device, "1.3.6.1.4.1.14179.1.1.5.3.0", '-OvQ')); $mempool['total'] = ($total * 1024); -$mempool['free'] = ($avail * 1024); -$mempool['used'] = (($total - $avail) * 1024); +$mempool['free'] = ($avail * 1024); +$mempool['used'] = (($total - $avail) * 1024); diff --git a/includes/polling/mempools/cmp.inc.php b/includes/polling/mempools/cmp.inc.php index c3a6cbb1ff..f5bdda1abe 100644 --- a/includes/polling/mempools/cmp.inc.php +++ b/includes/polling/mempools/cmp.inc.php @@ -2,12 +2,12 @@ $oid = $mempool['mempool_index']; -$oids = array( +$oids = [ "ciscoMemoryPoolUsed.$oid", "ciscoMemoryPoolFree.$oid", "ciscoMemoryPoolLargestFree.$oid", -); +]; $data = snmp_get_multi_oid($device, $oids, '-OUQ', 'CISCO-MEMORY-POOL-MIB'); -list($mempool['used'], $mempool['free'], $mempool['largestfree']) = array_values($data); +[$mempool['used'], $mempool['free'], $mempool['largestfree']] = array_values($data); $mempool['total'] = ($mempool['used'] + $mempool['free']); diff --git a/includes/polling/mempools/comware.inc.php b/includes/polling/mempools/comware.inc.php index 3f2aa1e961..4d7f377723 100644 --- a/includes/polling/mempools/comware.inc.php +++ b/includes/polling/mempools/comware.inc.php @@ -22,7 +22,6 @@ * @copyright 2017 Neil Lathwood * @author Neil Lathwood */ - $usage = snmp_get($device, "hh3cEntityExtMemUsage.{$mempool['mempool_index']}", '-Ovq', 'HH3C-ENTITY-EXT-MIB'); $mempool['total'] = 100; $mempool['used'] = $usage; diff --git a/includes/polling/mempools/cyberoam-utm.inc.php b/includes/polling/mempools/cyberoam-utm.inc.php index 875f038590..979e64d7c2 100644 --- a/includes/polling/mempools/cyberoam-utm.inc.php +++ b/includes/polling/mempools/cyberoam-utm.inc.php @@ -22,23 +22,22 @@ * @copyright 2017 Neil Lathwood * @author Neil Lathwood */ - if ($mempool['mempool_index'] == 0) { $mem_perc = snmp_get($device, '.1.3.6.1.4.1.21067.2.1.2.4.2.0', '-OvQ'); $mem_capacity = snmp_get($device, '.1.3.6.1.4.1.21067.2.1.2.4.1.0', '-OvQ'); - $mem_capacity = ($mem_capacity*1024*1024); + $mem_capacity = ($mem_capacity * 1024 * 1024); $mempool['total'] = $mem_capacity; - $mempool['used'] = ($mem_capacity / 100) * $mem_perc; - $mempool['free'] = $mempool['total'] - $mempool['used']; + $mempool['used'] = ($mem_capacity / 100) * $mem_perc; + $mempool['free'] = $mempool['total'] - $mempool['used']; } if ($mempool['mempool_index'] == 1) { $swap_perc = snmp_get($device, '.1.3.6.1.4.1.21067.2.1.2.4.4.0', '-OvQ'); $swap_capacity = snmp_get($device, '.1.3.6.1.4.1.21067.2.1.2.4.3.0', '-OvQ'); - $swap_capacity = ($swap_capacity*1024*1024); + $swap_capacity = ($swap_capacity * 1024 * 1024); $mempool['total'] = $swap_capacity; - $mempool['used'] = ($swap_capacity / 100) * $swap_perc; - $mempool['free'] = $mempool['total'] - $mempool['used']; + $mempool['used'] = ($swap_capacity / 100) * $swap_perc; + $mempool['free'] = $mempool['total'] - $mempool['used']; } unset( diff --git a/includes/polling/mempools/dasan-nos.inc.php b/includes/polling/mempools/dasan-nos.inc.php index f7b7aef0c2..f510b4c09d 100644 --- a/includes/polling/mempools/dasan-nos.inc.php +++ b/includes/polling/mempools/dasan-nos.inc.php @@ -22,7 +22,6 @@ * @copyright 2016 Neil Lathwood * @author Neil Lathwood */ - $mempool['total'] = snmp_get($device, 'dsTotalMem.0', '-OvQU', 'DASAN-SWITCH-MIB'); -$mempool['used'] = snmp_get($device, 'dsUsedMem.0', '-OvQU', 'DASAN-SWITCH-MIB'); -$mempool['free'] = snmp_get($device, 'dsFreeMem.0', '-OvQU', 'DASAN-SWITCH-MIB'); +$mempool['used'] = snmp_get($device, 'dsUsedMem.0', '-OvQU', 'DASAN-SWITCH-MIB'); +$mempool['free'] = snmp_get($device, 'dsFreeMem.0', '-OvQU', 'DASAN-SWITCH-MIB'); diff --git a/includes/polling/mempools/dell-net.inc.php b/includes/polling/mempools/dell-net.inc.php index a1038bee48..b256590584 100644 --- a/includes/polling/mempools/dell-net.inc.php +++ b/includes/polling/mempools/dell-net.inc.php @@ -9,13 +9,13 @@ * * option) any later version. Please see LICENSE.txt at the top level of * * the source code distribution for details. * */ - + $total = snmp_get($device, '.1.3.6.1.4.1.6027.3.26.1.4.3.1.6.2.1.1', '-OvQ'); -$usage = snmp_get($device, '.1.3.6.1.4.1.6027.3.26.1.4.4.1.6.2.1.1', '-OvQ'); +$usage = snmp_get($device, '.1.3.6.1.4.1.6027.3.26.1.4.4.1.6.2.1.1', '-OvQ'); $usage_perc = $usage / 100; $used = $total * $usage_perc; $free = $total - $used; - + $mempool['total'] = $total * 1024 * 1024; -$mempool['free'] = $free * 1024 * 1024; -$mempool['used'] = $used * 1024 * 1024; +$mempool['free'] = $free * 1024 * 1024; +$mempool['used'] = $used * 1024 * 1024; diff --git a/includes/polling/mempools/dlink.inc.php b/includes/polling/mempools/dlink.inc.php index 5b30284b26..c7c0eae28d 100644 --- a/includes/polling/mempools/dlink.inc.php +++ b/includes/polling/mempools/dlink.inc.php @@ -18,9 +18,9 @@ d_echo('Dlink'); $memory_oid = '.1.3.6.1.4.1.171.12.1.1.9.1.4.1'; $perc = snmp_get($device, $memory_oid, '-OvQ'); if (is_numeric($perc)) { - $mempool['used'] = $perc; + $mempool['used'] = $perc; $mempool['total'] = 100; - $mempool['free'] = 100 - $perc; + $mempool['free'] = 100 - $perc; } else { $dlink_mempools = snmp_get_multi_oid($device, "dEntityExtMemUtilTotal.$mempool_index dEntityExtMemUtilUsed.$mempool_index dEntityExtMemUtilFree.$mempool_index", '-OUQs', 'DLINKSW-ENTITY-EXT-MIB'); $mempool['total'] = $dlink_mempools["dEntityExtMemUtilTotal.$mempool_index"]; diff --git a/includes/polling/mempools/dlinkap.inc.php b/includes/polling/mempools/dlinkap.inc.php index 056502c848..f14c0d5d22 100644 --- a/includes/polling/mempools/dlinkap.inc.php +++ b/includes/polling/mempools/dlinkap.inc.php @@ -15,11 +15,11 @@ */ d_echo('Dlink AP'); -$memory_oid = $device['sysObjectID'].'.5.1.4.0'; +$memory_oid = $device['sysObjectID'] . '.5.1.4.0'; $perc = snmp_get($device, $memory_oid, '-OvQ'); if (is_numeric($perc)) { - $mempool['perc'] = $perc; - $mempool['used'] = $perc; + $mempool['perc'] = $perc; + $mempool['used'] = $perc; $mempool['total'] = 100; - $mempool['free'] = 100 - $perc; + $mempool['free'] = 100 - $perc; } diff --git a/includes/polling/mempools/dnos.inc.php b/includes/polling/mempools/dnos.inc.php index 8f3bd8b3cc..c825739dcd 100644 --- a/includes/polling/mempools/dnos.inc.php +++ b/includes/polling/mempools/dnos.inc.php @@ -4,18 +4,18 @@ if (preg_match('/.6027.1.3.[0-9]+$/', $device['sysObjectID'])) { $mempool['total'] = snmp_get($device, 'chSysProcessorMemSize.1', '-OvQU', 'F10-S-SERIES-CHASSIS-MIB'); - $mempool['used'] = $mempool['total'] * (snmp_get($device, 'chStackUnitMemUsageUtil.1', '-OvQU', 'F10-S-SERIES-CHASSIS-MIB')/ 100); - $mempool['free'] = ($mempool['total'] - $mempool['used']); + $mempool['used'] = $mempool['total'] * (snmp_get($device, 'chStackUnitMemUsageUtil.1', '-OvQU', 'F10-S-SERIES-CHASSIS-MIB') / 100); + $mempool['free'] = ($mempool['total'] - $mempool['used']); } elseif (preg_match('/.6027.1.2.[0-9]+$/', $device['sysObjectID'])) { $mempool['total'] = snmp_get($device, 'chSysProcessorMemSize.1', '-OvQU', 'F10-C-SERIES-CHASSIS-MIB'); - $mempool['used'] = $mempool['total'] * (snmp_get($device, 'chStackUnitMemUsageUtil.1', '-OvQU', 'F10-C-SERIES-CHASSIS-MIB')/ 100); - $mempool['free'] = ($mempool['total'] - $mempool['used']); + $mempool['used'] = $mempool['total'] * (snmp_get($device, 'chStackUnitMemUsageUtil.1', '-OvQU', 'F10-C-SERIES-CHASSIS-MIB') / 100); + $mempool['free'] = ($mempool['total'] - $mempool['used']); } elseif (preg_match('/.6027.1.4.[0-9]+$/', $device['sysObjectID'])) { $mempool['total'] = snmp_get($device, 'dellNetProcessorMemSize.stack.1.1', '-OvQU', 'DELL-NETWORKING-CHASSIS-MIB'); - $mempool['used'] = $mempool['total'] * (snmp_get($device, 'dellNetCpuUtilMemUsage.stack.1.1', '-OvQU', 'DELL-NETWORKING-CHASSIS-MIB')/ 100); - $mempool['free'] = ($mempool['total'] - $mempool['used']); + $mempool['used'] = $mempool['total'] * (snmp_get($device, 'dellNetCpuUtilMemUsage.stack.1.1', '-OvQU', 'DELL-NETWORKING-CHASSIS-MIB') / 100); + $mempool['free'] = ($mempool['total'] - $mempool['used']); } else { $mempool['total'] = snmp_get($device, '.1.3.6.1.4.1.674.10895.5000.2.6132.1.1.1.1.4.2.0', '-OvQ'); - $mempool['free'] = snmp_get($device, '.1.3.6.1.4.1.674.10895.5000.2.6132.1.1.1.1.4.1.0', '-OvQ'); - $mempool['used'] = ($mempool['total'] - $mempool['free']); + $mempool['free'] = snmp_get($device, '.1.3.6.1.4.1.674.10895.5000.2.6132.1.1.1.1.4.1.0', '-OvQ'); + $mempool['used'] = ($mempool['total'] - $mempool['free']); } diff --git a/includes/polling/mempools/edgecos.inc.php b/includes/polling/mempools/edgecos.inc.php index cc3072e51e..011dfa8299 100644 --- a/includes/polling/mempools/edgecos.inc.php +++ b/includes/polling/mempools/edgecos.inc.php @@ -28,9 +28,9 @@ if (Str::startsWith($device['sysObjectID'], '.1.3.6.1.4.1.259.10.1.24.')) { //EC $temp_mibs = 'ES3510MA-MIB'; } elseif (Str::startsWith($device['sysObjectID'], '.1.3.6.1.4.1.259.10.1.43.')) { //ECS2100 $temp_mibs = 'ECS2100-MIB'; -}; +} -$temp_data = snmp_get_multi_oid($device, ['memoryTotal.0', 'memoryFreed.0','memoryAllocated.0'], '-OUQs', $temp_mibs); +$temp_data = snmp_get_multi_oid($device, ['memoryTotal.0', 'memoryFreed.0', 'memoryAllocated.0'], '-OUQs', $temp_mibs); $mempool['total'] = $temp_data['memoryTotal.0']; $mempool['free'] = $temp_data['memoryFreed.0']; $mempool['used'] = $temp_data['memoryAllocated.0'] ?? ($mempool['total'] - $mempool['free']); diff --git a/includes/polling/mempools/enterasys.inc.php b/includes/polling/mempools/enterasys.inc.php index 02b6111d3e..9c26748b0f 100644 --- a/includes/polling/mempools/enterasys.inc.php +++ b/includes/polling/mempools/enterasys.inc.php @@ -11,7 +11,7 @@ */ $free = snmp_get($device, "etsysResourceStorageAvailable.{$mempool['mempool_index']}.ram.{$mempool['entPhysicalIndex']}", '-OvQ', 'ENTERASYS-RESOURCE-UTILIZATION-MIB'); -$total = snmp_get($device, "etsysResourceStorageSize.{$mempool['mempool_index']}.ram.{$mempool['entPhysicalIndex']}", '-OvQ', 'ENTERASYS-RESOURCE-UTILIZATION-MIB'); +$total = snmp_get($device, "etsysResourceStorageSize.{$mempool['mempool_index']}.ram.{$mempool['entPhysicalIndex']}", '-OvQ', 'ENTERASYS-RESOURCE-UTILIZATION-MIB'); $mempool['used'] = (($total - $free) * 1024); $mempool['free'] = ($free * 1024); diff --git a/includes/polling/mempools/extreme-mem.inc.php b/includes/polling/mempools/extreme-mem.inc.php index f46d9274ff..a9ae7532d5 100644 --- a/includes/polling/mempools/extreme-mem.inc.php +++ b/includes/polling/mempools/extreme-mem.inc.php @@ -6,5 +6,5 @@ $total = str_replace('"', "", snmp_get($device, "1.3.6.1.4.1.1916.1.32.2.2.1.2.1 $avail = str_replace('"', "", snmp_get($device, "1.3.6.1.4.1.1916.1.32.2.2.1.3.1", '-OvQ')); $mempool['total'] = ($total * 1024); -$mempool['free'] = ($avail * 1024); -$mempool['used'] = (($total - $avail) * 1024); +$mempool['free'] = ($avail * 1024); +$mempool['used'] = (($total - $avail) * 1024); diff --git a/includes/polling/mempools/f5.inc.php b/includes/polling/mempools/f5.inc.php index 78f5719406..41aa931e5b 100644 --- a/includes/polling/mempools/f5.inc.php +++ b/includes/polling/mempools/f5.inc.php @@ -12,14 +12,12 @@ * the source code distribution for details. */ - /* / F5-BIGIP-SYSTEM-MIB::sysStatMemoryTotal.0 = Counter64: 28638707712 / F5-BIGIP-SYSTEM-MIB::sysStatMemoryUsed.0 = Counter64: 1794195576 */ - -$mempool['used'] = snmp_get($device, 'sysGlobalStat.sysStatMemoryUsed.0', '-OvQ', 'F5-BIGIP-SYSTEM-MIB'); +$mempool['used'] = snmp_get($device, 'sysGlobalStat.sysStatMemoryUsed.0', '-OvQ', 'F5-BIGIP-SYSTEM-MIB'); $mempool['total'] = snmp_get($device, 'sysGlobalStat.sysStatMemoryTotal.0', '-OvQ', 'F5-BIGIP-SYSTEM-MIB'); -$mempool['free'] = ($mempool['total'] - $mempool['used']); -$mempool['perc'] = ($mempool['used'] / $mempool['total']) * 100; +$mempool['free'] = ($mempool['total'] - $mempool['used']); +$mempool['perc'] = ($mempool['used'] / $mempool['total']) * 100; diff --git a/includes/polling/mempools/fabos.inc.php b/includes/polling/mempools/fabos.inc.php index b094d8a16c..aa5f196629 100644 --- a/includes/polling/mempools/fabos.inc.php +++ b/includes/polling/mempools/fabos.inc.php @@ -22,7 +22,6 @@ * @copyright 2017 Neil Lathwood * @author Neil Lathwood */ - $perc = snmp_get($device, 'swMemUsage.0', '-Ovq', 'SW-MIB'); if (is_numeric($perc)) { diff --git a/includes/polling/mempools/fiberhome-switch.inc.php b/includes/polling/mempools/fiberhome-switch.inc.php index 72aa126de1..ba9cb257b0 100644 --- a/includes/polling/mempools/fiberhome-switch.inc.php +++ b/includes/polling/mempools/fiberhome-switch.inc.php @@ -15,9 +15,9 @@ */ $oid = $mempool['mempool_index']; - echo "\nFiberHome-MEMORY-POOL Index: ".$mempool['mempool_index']."\n"; + echo "\nFiberHome-MEMORY-POOL Index: " . $mempool['mempool_index'] . "\n"; -if (!is_array($mempool_cache['fiberhome-switch'])) { +if (! is_array($mempool_cache['fiberhome-switch'])) { echo "\ncaching\n"; $mempool_cache['fiberhome-switch'] = snmpwalk_group($device, 'memoryPoolTable', 'WRI-MEMORY-MIB'); d_echo($mempool_cache); @@ -29,9 +29,9 @@ if ($entry['memoryPoolTotalBytes'] < 0) { $entry['memoryPoolTotalBytes'] = ($entry['memoryPoolTotalBytes'] * -1); } -$perc = $entry['memoryPoolCurrUsage']; +$perc = $entry['memoryPoolCurrUsage']; $mempool['total'] = $entry['memoryPoolTotalBytes']; -$mempool['used'] = $entry['memoryPoolAllocBytesNum']; -$mempool['free'] = ($entry['memoryPoolTotalBytes'] - $mempool['used']); +$mempool['used'] = $entry['memoryPoolAllocBytesNum']; +$mempool['free'] = ($entry['memoryPoolTotalBytes'] - $mempool['used']); // End of File diff --git a/includes/polling/mempools/fiberhome.inc.php b/includes/polling/mempools/fiberhome.inc.php index f8d7b128a8..4e2edc8cf2 100644 --- a/includes/polling/mempools/fiberhome.inc.php +++ b/includes/polling/mempools/fiberhome.inc.php @@ -2,9 +2,9 @@ /** * Memory percent */ -$cardIndex = 'mgrCardMemUtil.'.$mempool['mempool_index']; -$usage = snmp_get($device, $cardIndex, '-Ovq', 'GEPON-OLT-COMMON-MIB'); -$perc = round($usage / 100); +$cardIndex = 'mgrCardMemUtil.' . $mempool['mempool_index']; +$usage = snmp_get($device, $cardIndex, '-Ovq', 'GEPON-OLT-COMMON-MIB'); +$perc = round($usage / 100); /* * Manual memory 256Mb on each board */ diff --git a/includes/polling/mempools/fortiauthenticator.inc.php b/includes/polling/mempools/fortiauthenticator.inc.php index ecf68ce96d..ce13ce195e 100644 --- a/includes/polling/mempools/fortiauthenticator.inc.php +++ b/includes/polling/mempools/fortiauthenticator.inc.php @@ -1,4 +1,5 @@ */ - echo 'Fortigate MemPool'; -$mempool['used'] = snmp_get($device, 'fsSysMemUsage.0', '-OvQ', 'FORTINET-FORTISWITCH-MIB'); +$mempool['used'] = snmp_get($device, 'fsSysMemUsage.0', '-OvQ', 'FORTINET-FORTISWITCH-MIB'); $mempool['total'] = snmp_get($device, 'fsSysMemCapacity.0', '-OvQ', 'FORTINET-FORTISWITCH-MIB'); -$mempool['free'] = ($mempool['total'] - $mempool['used']); +$mempool['free'] = ($mempool['total'] - $mempool['used']); $mempool['perc'] = $mempool['total'] / $mempool['used']; -echo '(U: '.$mempool['used'].' T: '.$mempool['total'].' F: '.$mempool['free'].') '; +echo '(U: ' . $mempool['used'] . ' T: ' . $mempool['total'] . ' F: ' . $mempool['free'] . ') '; diff --git a/includes/polling/mempools/fortiweb.inc.php b/includes/polling/mempools/fortiweb.inc.php index 5d1c775bff..2f3ebe7652 100644 --- a/includes/polling/mempools/fortiweb.inc.php +++ b/includes/polling/mempools/fortiweb.inc.php @@ -1,7 +1,8 @@ 0) { - $perc = ($entry['memorySize'] - $entry['memoryIdle']) / $entry['memorySize'] * 100; + $perc = ($entry['memorySize'] - $entry['memoryIdle']) / $entry['memorySize'] * 100; $mempool['total'] = $entry['memorySize']; - $mempool['used'] = ($entry['memorySize'] - $entry['memoryIdle']); - $mempool['free'] = ($entry['memoryIdle']); + $mempool['used'] = ($entry['memorySize'] - $entry['memoryIdle']); + $mempool['free'] = ($entry['memoryIdle']); } diff --git a/includes/polling/mempools/fs-switch.inc.php b/includes/polling/mempools/fs-switch.inc.php index 3da9aa148d..d8c1ebb2ba 100644 --- a/includes/polling/mempools/fs-switch.inc.php +++ b/includes/polling/mempools/fs-switch.inc.php @@ -1,4 +1,5 @@ 0) { - $perc = ($entry['memTotalUsed']) / $entry['memTotalReal'] * 100; + $perc = ($entry['memTotalUsed']) / $entry['memTotalReal'] * 100; $mempool['total'] = ($entry['memTotalReal'] * 1024); - $mempool['used'] = ($entry['memTotalUsed'] * 1024); - $mempool['free'] = ($entry['memTotalFree'] * 1024); + $mempool['used'] = ($entry['memTotalUsed'] * 1024); + $mempool['free'] = ($entry['memTotalFree'] * 1024); } diff --git a/includes/polling/mempools/ftos.inc.php b/includes/polling/mempools/ftos.inc.php index 55e6651823..3a168a68d7 100644 --- a/includes/polling/mempools/ftos.inc.php +++ b/includes/polling/mempools/ftos.inc.php @@ -4,14 +4,14 @@ if (preg_match('/.6027.1.3.[0-9]+$/', $device['sysObjectID'])) { $mempool['total'] = snmp_get($device, 'chSysProcessorMemSize.1', '-OvQU', 'F10-S-SERIES-CHASSIS-MIB'); - $mempool['used'] = $mempool['total'] * (snmp_get($device, 'chStackUnitMemUsageUtil.1', '-OvQU', 'F10-S-SERIES-CHASSIS-MIB')/ 100); - $mempool['free'] = ($mempool['total'] - $mempool['used']); + $mempool['used'] = $mempool['total'] * (snmp_get($device, 'chStackUnitMemUsageUtil.1', '-OvQU', 'F10-S-SERIES-CHASSIS-MIB') / 100); + $mempool['free'] = ($mempool['total'] - $mempool['used']); } elseif (preg_match('/.6027.1.2.[0-9]+$/', $device['sysObjectID'])) { $mempool['total'] = snmp_get($device, 'chSysProcessorMemSize.1', '-OvQU', 'F10-C-SERIES-CHASSIS-MIB'); - $mempool['used'] = $mempool['total'] * (snmp_get($device, 'chStackUnitMemUsageUtil.1', '-OvQU', 'F10-C-SERIES-CHASSIS-MIB')/ 100); - $mempool['free'] = ($mempool['total'] - $mempool['used']); + $mempool['used'] = $mempool['total'] * (snmp_get($device, 'chStackUnitMemUsageUtil.1', '-OvQU', 'F10-C-SERIES-CHASSIS-MIB') / 100); + $mempool['free'] = ($mempool['total'] - $mempool['used']); } else { $mempool['total'] = snmp_get($device, '.1.3.6.1.4.1.674.10895.5000.2.6132.1.1.1.1.4.2.0', '-OvQ'); - $mempool['free'] = snmp_get($device, '.1.3.6.1.4.1.674.10895.5000.2.6132.1.1.1.1.4.1.0', '-OvQ'); - $mempool['used'] = ($mempool['total'] - $mempool['free']); + $mempool['free'] = snmp_get($device, '.1.3.6.1.4.1.674.10895.5000.2.6132.1.1.1.1.4.1.0', '-OvQ'); + $mempool['used'] = ($mempool['total'] - $mempool['free']); } diff --git a/includes/polling/mempools/hirschmann.inc.php b/includes/polling/mempools/hirschmann.inc.php index 3e256e3bd1..032559210d 100644 --- a/includes/polling/mempools/hirschmann.inc.php +++ b/includes/polling/mempools/hirschmann.inc.php @@ -9,4 +9,4 @@ $mempool['total'] = ($mem_allocated + $mem_free); $mempool['used'] = $mem_allocated; $mempool['free'] = $mem_free; -echo '(U: '.$mempool['used'].' T: '.$mempool['total'].' F: '.$mempool['free'].') '; +echo '(U: ' . $mempool['used'] . ' T: ' . $mempool['total'] . ' F: ' . $mempool['free'] . ') '; diff --git a/includes/polling/mempools/hiveos-wireless.inc.php b/includes/polling/mempools/hiveos-wireless.inc.php index fdd77bfeba..fbb349c36a 100644 --- a/includes/polling/mempools/hiveos-wireless.inc.php +++ b/includes/polling/mempools/hiveos-wireless.inc.php @@ -27,7 +27,7 @@ d_echo('Hiveos-Wireless'); $memory_oid = '1.3.6.1.4.1.26928.1.2.4.0'; $perc = snmp_get($device, $memory_oid, '-OvQ'); if (is_numeric($perc)) { - $mempool['used'] = $perc; + $mempool['used'] = $perc; $mempool['total'] = 100; - $mempool['free'] = 100 - $perc; + $mempool['free'] = 100 - $perc; } diff --git a/includes/polling/mempools/hpGlobal.inc.php b/includes/polling/mempools/hpGlobal.inc.php index 4bcea30728..ba7619204e 100644 --- a/includes/polling/mempools/hpGlobal.inc.php +++ b/includes/polling/mempools/hpGlobal.inc.php @@ -7,7 +7,7 @@ // NETSWITCH-MIB::hpGlobalMemTotalBytes.1 = INTEGER: 11337704 // NETSWITCH-MIB::hpGlobalMemFreeBytes.1 = INTEGER: 9669104 // NETSWITCH-MIB::hpGlobalMemAllocBytes.1 = INTEGER: 1668728 -if (!is_array($mempool_cache['hpGlobal'])) { +if (! is_array($mempool_cache['hpGlobal'])) { $mempool_cache['hpGlobal'] = snmpwalk_cache_oid($device, 'hpGlobal', null, 'NETSWITCH-MIB', 'hp'); d_echo($mempool_cache); } else { @@ -17,6 +17,6 @@ if (!is_array($mempool_cache['hpGlobal'])) { $entry = $mempool_cache['hpGlobal'][$mempool['mempool_index']]; $mempool['units'] = '1'; -$mempool['used'] = $entry['hpGlobalMemAllocBytes']; +$mempool['used'] = $entry['hpGlobalMemAllocBytes']; $mempool['total'] = $entry['hpGlobalMemTotalBytes']; -$mempool['free'] = $entry['hpGlobalMemFreeBytes']; +$mempool['free'] = $entry['hpGlobalMemFreeBytes']; diff --git a/includes/polling/mempools/hpLocal.inc.php b/includes/polling/mempools/hpLocal.inc.php index c70b323a0f..ac932894ca 100644 --- a/includes/polling/mempools/hpLocal.inc.php +++ b/includes/polling/mempools/hpLocal.inc.php @@ -7,7 +7,7 @@ // NETSWITCH-MIB::hpLocalMemTotalBytes.1 = INTEGER: 11337704 // NETSWITCH-MIB::hpLocalMemFreeBytes.1 = INTEGER: 9669104 // NETSWITCH-MIB::hpLocalMemAllocBytes.1 = INTEGER: 1668728 -if (!is_array($mempool_cache['hpLocal'])) { +if (! is_array($mempool_cache['hpLocal'])) { $mempool_cache['hpLocal'] = snmpwalk_cache_oid($device, 'hpLocal', null, 'NETSWITCH-MIB', 'hp'); d_echo($mempool_cache); } else { @@ -17,6 +17,6 @@ if (!is_array($mempool_cache['hpLocal'])) { $entry = $mempool_cache['hpLocal'][$mempool['mempool_index']]; $mempool['units'] = '1'; -$mempool['used'] = $entry['hpLocalMemAllocBytes']; +$mempool['used'] = $entry['hpLocalMemAllocBytes']; $mempool['total'] = $entry['hpLocalMemTotalBytes']; -$mempool['free'] = $entry['hpLocalMemFreeBytes']; +$mempool['free'] = $entry['hpLocalMemFreeBytes']; diff --git a/includes/polling/mempools/hpe-ilo.inc.php b/includes/polling/mempools/hpe-ilo.inc.php index de839b67ce..e4a4792951 100644 --- a/includes/polling/mempools/hpe-ilo.inc.php +++ b/includes/polling/mempools/hpe-ilo.inc.php @@ -1,24 +1,24 @@ */ - $oid = '.1.3.6.1.4.1.11863.6.4.1.2.1.1.2.' . $mempool['mempool_index']; $used = snmp_get($device, $oid, '-OvQ'); $mempool['total'] = 100; -$mempool['free'] = ($mempool['total'] - $used); -$mempool['used'] = $used; +$mempool['free'] = ($mempool['total'] - $used); +$mempool['used'] = $used; unset( $oid, diff --git a/includes/polling/mempools/junos.inc.php b/includes/polling/mempools/junos.inc.php index b28f8cc3c9..b1597c23cd 100644 --- a/includes/polling/mempools/junos.inc.php +++ b/includes/polling/mempools/junos.inc.php @@ -4,10 +4,10 @@ $oid = $mempool['mempool_index']; d_echo('JunOS Mempool'); -if (!is_array($mempool_cache['junos'])) { +if (! is_array($mempool_cache['junos'])) { d_echo('caching'); - $mempool_cache['junos'] = array(); + $mempool_cache['junos'] = []; $mempool_cache['junos'] = snmpwalk_cache_multi_oid($device, 'jnxOperatingBuffer', $mempool_cache['junos'], 'JUNIPER-MIB', 'junos'); $mempool_cache['junos'] = snmpwalk_cache_multi_oid($device, 'jnxOperatingDRAMSize', $mempool_cache['junos'], 'JUNIPER-MIB', 'junos'); $mempool_cache['junos'] = snmpwalk_cache_multi_oid($device, 'jnxOperatingMemory', $mempool_cache['junos'], 'JUNIPER-MIB', 'junos'); @@ -25,5 +25,5 @@ if ($entry['jnxOperatingDRAMSize']) { } $mempool['total'] = $memory_available; -$mempool['used'] = ($memory_available / 100 * $perc); -$mempool['free'] = ($memory_available - $mempool['used']); +$mempool['used'] = ($memory_available / 100 * $perc); +$mempool['free'] = ($memory_available - $mempool['used']); diff --git a/includes/polling/mempools/netgear.inc.php b/includes/polling/mempools/netgear.inc.php index 47aea9cc88..efdbb50e03 100644 --- a/includes/polling/mempools/netgear.inc.php +++ b/includes/polling/mempools/netgear.inc.php @@ -18,7 +18,7 @@ echo 'NETGEAR Memory Pool'; $memory_pool = snmp_get_multi_oid($device, ['agentSwitchCpuProcessMemAvailable.0', 'agentSwitchCpuProcessMemFree.0'], '-OQUs', 'NETGEAR-SWITCHING-MIB'); -$mempool['free'] = $memory_pool['agentSwitchCpuProcessMemFree.0']; -$mempool['used'] = $memory_pool['agentSwitchCpuProcessMemAvailable.0'] - $mempool['free']; +$mempool['free'] = $memory_pool['agentSwitchCpuProcessMemFree.0']; +$mempool['used'] = $memory_pool['agentSwitchCpuProcessMemAvailable.0'] - $mempool['free']; $mempool['total'] = $mempool['free'] + $mempool['used']; -$mempool['perc'] = $mempool['used'] / $mempool['total']; +$mempool['perc'] = $mempool['used'] / $mempool['total']; diff --git a/includes/polling/mempools/netonix.inc.php b/includes/polling/mempools/netonix.inc.php index 9853a632a6..63245c59dc 100644 --- a/includes/polling/mempools/netonix.inc.php +++ b/includes/polling/mempools/netonix.inc.php @@ -22,10 +22,9 @@ * @copyright 2016 Tony Murray * @author Tony Murray */ - $total = snmp_get($device, "UCD-SNMP-MIB::memTotalReal.0", "-OvQU") * 1024; $free = snmp_get($device, "UCD-SNMP-MIB::memAvailReal.0", "-OvQU") * 1024; $mempool['total'] = $total; -$mempool['free'] = $free; -$mempool['used'] = $total - $free; +$mempool['free'] = $free; +$mempool['used'] = $total - $free; diff --git a/includes/polling/mempools/netscaler.inc.php b/includes/polling/mempools/netscaler.inc.php index ffa8ec0e2e..0469a7c4c8 100644 --- a/includes/polling/mempools/netscaler.inc.php +++ b/includes/polling/mempools/netscaler.inc.php @@ -7,6 +7,6 @@ // Simple hard-coded poller for Netscaler // Yes, it really can be this simple. $mempool['total'] = (snmp_get($device, '.1.3.6.1.4.1.5951.4.1.1.41.4.0', '-OvQ') * 1047552); -$mempool['perc'] = snmp_get($device, '.1.3.6.1.4.1.5951.4.1.1.41.2.0', '-OvQ'); -$mempool['used'] = ($mempool['total'] / 100 * $mempool['perc']); -$mempool['free'] = ($mempool['total'] - $mempool['used']); +$mempool['perc'] = snmp_get($device, '.1.3.6.1.4.1.5951.4.1.1.41.2.0', '-OvQ'); +$mempool['used'] = ($mempool['total'] / 100 * $mempool['perc']); +$mempool['free'] = ($mempool['total'] - $mempool['used']); diff --git a/includes/polling/mempools/nokia-isam.inc.php b/includes/polling/mempools/nokia-isam.inc.php index 783a5d337a..8d9e4d0025 100644 --- a/includes/polling/mempools/nokia-isam.inc.php +++ b/includes/polling/mempools/nokia-isam.inc.php @@ -13,11 +13,11 @@ echo 'Nokia ISAM Memory: '; $oid = $mempool['mempool_index']; -$oids = array( +$oids = [ "memAbsoluteUsage.$oid", "totalMemSize.$oid", -); +]; $data = snmp_get_multi_oid($device, $oids, '-OUQ', 'ASAM-SYSTEM-MIB'); -list($mempool['used'], $mempool['total']) = array_values($data); +[$mempool['used'], $mempool['total']] = array_values($data); $mempool['free'] = ($mempool['total'] + $mempool['used']); diff --git a/includes/polling/mempools/nos.inc.php b/includes/polling/mempools/nos.inc.php index 44ccf2d241..116fe41c70 100644 --- a/includes/polling/mempools/nos.inc.php +++ b/includes/polling/mempools/nos.inc.php @@ -2,6 +2,6 @@ // Somewhat of an uggly hack since NOS doesn't support fetching total memory of the device over SNMP // Given OID returns usage in percent so we set total to 100 in order to get a proper graph -$mempool['total'] = "100"; -$mempool['used'] = snmp_get($device, "1.3.6.1.4.1.1588.2.1.1.1.26.6.0", "-Ovq"); -$mempool['free'] = ($mempool['total'] - $mempool['used']); +$mempool['total'] = "100"; +$mempool['used'] = snmp_get($device, "1.3.6.1.4.1.1588.2.1.1.1.26.6.0", "-Ovq"); +$mempool['free'] = ($mempool['total'] - $mempool['used']); diff --git a/includes/polling/mempools/opengear.inc.php b/includes/polling/mempools/opengear.inc.php index 8adfffde56..971c7804c3 100644 --- a/includes/polling/mempools/opengear.inc.php +++ b/includes/polling/mempools/opengear.inc.php @@ -13,8 +13,8 @@ * @subpackage polling * @link http://librenms.org */ - + $mempool['total'] = intval(preg_replace('/[^0-9]+/', '', snmp_get($device, 'memTotalReal.0', '-OQUs', 'UCD-SNMP-MIB')), 10); $mempool['free'] = intval(preg_replace('/[^0-9]+/', '', snmp_get($device, 'memTotalFree.0', '-OQUs', 'UCD-SNMP-MIB')), 10); -$mempool['used'] = ($mempool['total'] - $mempool['free']); -$mempool['perc'] = ($mempool['used'] / $mempool['total']) * 100; +$mempool['used'] = ($mempool['total'] - $mempool['free']); +$mempool['perc'] = ($mempool['used'] / $mempool['total']) * 100; diff --git a/includes/polling/mempools/patton-sn.inc.php b/includes/polling/mempools/patton-sn.inc.php index 85b87279f9..7341994926 100644 --- a/includes/polling/mempools/patton-sn.inc.php +++ b/includes/polling/mempools/patton-sn.inc.php @@ -4,7 +4,7 @@ $oid = $mempool['mempool_index']; d_echo('Patton SN Mempool'); -if (!is_array($mempool_cache['patton-sn'])) { +if (! is_array($mempool_cache['patton-sn'])) { d_echo('caching'); $mempool_cache['patton-sn'] = []; @@ -19,9 +19,9 @@ if ($entry['hwEntityMemSize'] < 0) { $entry['hwEntityMemSize'] = ($entry['hwEntityMemSize'] * -1); } -$mempool['total'] = $entry['memAllocatedBytes'] + $entry['memFreeBytes'] ; -$mempool['used'] = $entry['memAllocatedBytes']; -$mempool['free'] = $entry['memFreeBytes']; -$perc = $entry['used']/$entry['total'] * 100; +$mempool['total'] = $entry['memAllocatedBytes'] + $entry['memFreeBytes']; +$mempool['used'] = $entry['memAllocatedBytes']; +$mempool['free'] = $entry['memFreeBytes']; +$perc = $entry['used'] / $entry['total'] * 100; d_echo($mempool); diff --git a/includes/polling/mempools/pbn-mem.inc.php b/includes/polling/mempools/pbn-mem.inc.php index 4d2a56c812..7a2ab0e9f5 100644 --- a/includes/polling/mempools/pbn-mem.inc.php +++ b/includes/polling/mempools/pbn-mem.inc.php @@ -1,6 +1,6 @@ \d+)/', $device['version'], $version); @@ -17,6 +17,6 @@ if ($version['build'] >= 16607) { $mempool['free'] = ($memory_available - $mempool['used']); } - echo "PERC " .$perc."%\n"; - echo "Avail " .$mempool['total']."\n"; + echo "PERC " . $perc . "%\n"; + echo "Avail " . $mempool['total'] . "\n"; } diff --git a/includes/polling/mempools/powerconnect-cpu.inc.php b/includes/polling/mempools/powerconnect-cpu.inc.php index 93da1891be..29b1183d99 100644 --- a/includes/polling/mempools/powerconnect-cpu.inc.php +++ b/includes/polling/mempools/powerconnect-cpu.inc.php @@ -6,5 +6,5 @@ // Yes, it really can be this simple. // Pity there's no matching MIB to be found. $mempool['total'] = snmp_get($device, 'dellLanExtension.6132.1.1.1.1.4.2.0', '-OvQ', 'Dell-Vendor-MIB'); -$mempool['free'] = snmp_get($device, 'dellLanExtension.6132.1.1.1.1.4.1.0', '-OvQ', 'Dell-Vendor-MIB'); -$mempool['used'] = ($mempool['total'] - $mempool['free']); +$mempool['free'] = snmp_get($device, 'dellLanExtension.6132.1.1.1.1.4.1.0', '-OvQ', 'Dell-Vendor-MIB'); +$mempool['used'] = ($mempool['total'] - $mempool['free']); diff --git a/includes/polling/mempools/pulse-mem.inc.php b/includes/polling/mempools/pulse-mem.inc.php index 7934c272aa..507fd81315 100644 --- a/includes/polling/mempools/pulse-mem.inc.php +++ b/includes/polling/mempools/pulse-mem.inc.php @@ -12,9 +12,9 @@ // Simple hard-coded poller for Pulse Secure // Yes, it really can be this simple. -echo 'Pulse Secure MemPool'.'\n'; +echo 'Pulse Secure MemPool' . '\n'; -$perc = str_replace('"', "", snmp_get($device, "PULSESECURE-PSG-MIB::iveMemoryUtil.0", '-OvQ')); +$perc = str_replace('"', "", snmp_get($device, "PULSESECURE-PSG-MIB::iveMemoryUtil.0", '-OvQ')); $memory_available = str_replace('"', "", snmp_get($device, "UCD-SNMP-MIB::memTotalReal.0", '-OvQ')); $mempool['total'] = $memory_available; @@ -23,5 +23,5 @@ if (is_numeric($perc)) { $mempool['free'] = ($memory_available - $mempool['used']); } -echo "PERC " .$perc."%\n"; -echo "Avail " .$mempool['total']."\n"; +echo "PERC " . $perc . "%\n"; +echo "Avail " . $mempool['total'] . "\n"; diff --git a/includes/polling/mempools/raisecom.inc.php b/includes/polling/mempools/raisecom.inc.php index 6335f0c36e..2afe518718 100644 --- a/includes/polling/mempools/raisecom.inc.php +++ b/includes/polling/mempools/raisecom.inc.php @@ -2,8 +2,8 @@ echo 'Raisecom Memory: '; -$avail = snmp_get($device, 'raisecomMemoryAvailable.0', ['-OUvq', '-Pu'], 'RAISECOM-SYSTEM-MIB'); -$total = snmp_get($device, 'raisecomMemoryTotal.0', ['-OUvq', '-Pu'], 'RAISECOM-SYSTEM-MIB'); +$avail = snmp_get($device, 'raisecomMemoryAvailable.0', ['-OUvq', '-Pu'], 'RAISECOM-SYSTEM-MIB'); +$total = snmp_get($device, 'raisecomMemoryTotal.0', ['-OUvq', '-Pu'], 'RAISECOM-SYSTEM-MIB'); if (is_numeric($total) && is_numeric($avail)) { $mempool['total'] = $total; diff --git a/includes/polling/mempools/screenos.inc.php b/includes/polling/mempools/screenos.inc.php index 4f2f433ce0..34fe29029e 100644 --- a/includes/polling/mempools/screenos.inc.php +++ b/includes/polling/mempools/screenos.inc.php @@ -2,6 +2,6 @@ // Simple hard-coded poller for Juniper ScreenOS // Yes, it really can be this simple. -$mempool['used'] = snmp_get($device, '.1.3.6.1.4.1.3224.16.2.1.0', '-OvQ'); +$mempool['used'] = snmp_get($device, '.1.3.6.1.4.1.3224.16.2.1.0', '-OvQ'); $mempool['free'] = snmp_get($device, '.1.3.6.1.4.1.3224.16.2.2.0', '-OvQ'); -$mempool['total'] = ($mempool['free'] + $mempool['used']); +$mempool['total'] = ($mempool['free'] + $mempool['used']); diff --git a/includes/polling/mempools/serveriron.inc.php b/includes/polling/mempools/serveriron.inc.php index ed315eff8f..a980053d34 100644 --- a/includes/polling/mempools/serveriron.inc.php +++ b/includes/polling/mempools/serveriron.inc.php @@ -3,5 +3,5 @@ // Simple hard-coded poller for Brocade Ironware Dynamic Memory (old style) // Yes, it really can be this simple. $mempool['total'] = snmp_get($device, 'snAgGblDynMemTotal.0', '-OvQ', 'FOUNDRY-SN-AGENT-MIB'); -$mempool['free'] = snmp_get($device, 'snAgGblDynMemFree.0', '-OvQ', 'FOUNDRY-SN-AGENT-MIB'); -$mempool['used'] = ($mempool['total'] - $mempool['free']); +$mempool['free'] = snmp_get($device, 'snAgGblDynMemFree.0', '-OvQ', 'FOUNDRY-SN-AGENT-MIB'); +$mempool['used'] = ($mempool['total'] - $mempool['free']); diff --git a/includes/polling/mempools/sgos.inc.php b/includes/polling/mempools/sgos.inc.php index 48248925cf..94e87e3f5d 100644 --- a/includes/polling/mempools/sgos.inc.php +++ b/includes/polling/mempools/sgos.inc.php @@ -2,7 +2,7 @@ // Simple hard-coded poller for ProxySG -echo 'ProxySG MemPool'.'\n'; +echo 'ProxySG MemPool' . '\n'; $used = str_replace('"', "", snmp_get($device, "BLUECOAT-SG-PROXY-MIB::sgProxyMemSysUsage.0", '-OUvQ')); $total = str_replace('"', "", snmp_get($device, "BLUECOAT-SG-PROXY-MIB::sgProxyMemAvailable.0", '-OUvQ')); diff --git a/includes/polling/mempools/smartax.inc.php b/includes/polling/mempools/smartax.inc.php index aec9e14f08..3a022a79c0 100644 --- a/includes/polling/mempools/smartax.inc.php +++ b/includes/polling/mempools/smartax.inc.php @@ -25,8 +25,8 @@ $oid = '.1.3.6.1.4.1.2011.2.6.7.1.1.2.1.6.' . $mempool['mempool_index']; $used = snmp_get($device, $oid, '-OvQ'); $mempool['total'] = 100; -$mempool['free'] = ($mempool['total'] - $used); -$mempool['used'] = $used; +$mempool['free'] = ($mempool['total'] - $used); +$mempool['used'] = $used; unset( $oid, $used diff --git a/includes/polling/mempools/sonicwall-mem.inc.php b/includes/polling/mempools/sonicwall-mem.inc.php index c88c5d62b9..808863cf7d 100644 --- a/includes/polling/mempools/sonicwall-mem.inc.php +++ b/includes/polling/mempools/sonicwall-mem.inc.php @@ -21,7 +21,6 @@ if (Str::startsWith($device['sysObjectID'], '.1.3.6.1.4.1.8741.6')) { $perc = str_replace('"', "", $usage); - if (is_numeric($perc)) { $mempool['perc'] = $perc; $mempool['used'] = $perc; diff --git a/includes/polling/mempools/stoneos.inc.php b/includes/polling/mempools/stoneos.inc.php index e93fbc674e..8ba874612e 100644 --- a/includes/polling/mempools/stoneos.inc.php +++ b/includes/polling/mempools/stoneos.inc.php @@ -1,4 +1,5 @@ */ - $used = snmp_get($device, '.1.3.6.1.4.1.6527.3.1.2.1.1.2.0', '-OvQ'); $free = snmp_get($device, '.1.3.6.1.4.1.6527.3.1.2.1.1.3.0', '-OvQ'); $mempool['total'] = ($free + $used); -$mempool['free'] = $free; -$mempool['used'] = $used; +$mempool['free'] = $free; +$mempool['used'] = $used; diff --git a/includes/polling/mempools/unifi.inc.php b/includes/polling/mempools/unifi.inc.php index 05611285d6..6660c4be99 100644 --- a/includes/polling/mempools/unifi.inc.php +++ b/includes/polling/mempools/unifi.inc.php @@ -11,7 +11,7 @@ */ $total = snmp_get($device, '.1.3.6.1.4.1.10002.1.1.1.1.1.0', '-OvQ'); -$free = snmp_get($device, '.1.3.6.1.4.1.10002.1.1.1.1.2.0', '-OvQ'); +$free = snmp_get($device, '.1.3.6.1.4.1.10002.1.1.1.1.2.0', '-OvQ'); $mempool['total'] = $total * 1024; -$mempool['free'] = $free * 1024; -$mempool['used'] = ($mempool['total'] - $mempool['free']); +$mempool['free'] = $free * 1024; +$mempool['used'] = ($mempool['total'] - $mempool['free']); diff --git a/includes/polling/mempools/vrp.inc.php b/includes/polling/mempools/vrp.inc.php index 53911904fd..dd01fd58d9 100644 --- a/includes/polling/mempools/vrp.inc.php +++ b/includes/polling/mempools/vrp.inc.php @@ -4,10 +4,10 @@ $oid = $mempool['mempool_index']; d_echo('Huawei VRP Mempool'); -if (!is_array($mempool_cache['vrp'])) { +if (! is_array($mempool_cache['vrp'])) { d_echo('caching'); - $mempool_cache['vrp'] = array(); + $mempool_cache['vrp'] = []; $mempool_cache['vrp'] = snmpwalk_cache_multi_oid($device, 'hwEntityMemSize', $mempool_cache['vrp'], 'HUAWEI-ENTITY-EXTENT-MIB', 'huawei'); $mempool_cache['vrp'] = snmpwalk_cache_multi_oid($device, 'hwEntityMemSizeMega', $mempool_cache['vrp'], 'HUAWEI-ENTITY-EXTENT-MIB', 'huawei'); $mempool_cache['vrp'] = snmpwalk_cache_multi_oid($device, 'hwEntityMemUsage', $mempool_cache['vrp'], 'HUAWEI-ENTITY-EXTENT-MIB', 'huawei'); @@ -20,7 +20,7 @@ if ($entry['hwEntityMemSize'] < 0) { $entry['hwEntityMemSize'] = ($entry['hwEntityMemSize'] * -1); } -$perc = $entry['hwEntityMemUsage']; +$perc = $entry['hwEntityMemUsage']; $mempool['total'] = max($entry['hwEntityMemSize'], $entry['hwEntityMemSizeMega'] * 1024 * 1024); -$mempool['used'] = ($mempool['total'] / 100 * $perc); -$mempool['free'] = ($mempool['total'] - $mempool['used']); +$mempool['used'] = ($mempool['total'] / 100 * $perc); +$mempool['free'] = ($mempool['total'] - $mempool['used']); diff --git a/includes/polling/mempools/zyxel.inc.php b/includes/polling/mempools/zyxel.inc.php index 98a2b2dafd..f352487cfa 100644 --- a/includes/polling/mempools/zyxel.inc.php +++ b/includes/polling/mempools/zyxel.inc.php @@ -22,7 +22,6 @@ * @copyright 2017 Neil Lathwood * @author Neil Lathwood */ - d_echo('Zyxel: '); $perc = snmp_get($device, 'sysMgmtMemUsage.0', '-OvQ', 'ZYXEL-ES-COMMON'); if (is_numeric($perc)) { diff --git a/includes/polling/mempools/zyxelnwa.inc.php b/includes/polling/mempools/zyxelnwa.inc.php index 0e9edf2ec7..de5821e8e4 100644 --- a/includes/polling/mempools/zyxelnwa.inc.php +++ b/includes/polling/mempools/zyxelnwa.inc.php @@ -14,7 +14,6 @@ * @author Thomas GAGNIERE */ - d_echo('Zyxel NWA'); $perc = snmp_get($device, ".1.3.6.1.4.1.890.1.6.22.1.2.0", '-OvQ'); if (is_numeric($perc)) { diff --git a/includes/polling/mpls.inc.php b/includes/polling/mpls.inc.php index ca3c8c1ef6..7e0b0e4770 100644 --- a/includes/polling/mpls.inc.php +++ b/includes/polling/mpls.inc.php @@ -25,7 +25,7 @@ use LibreNMS\OS; -if (!$os instanceof OS) { +if (! $os instanceof OS) { $os = OS::make($device); } (new \LibreNMS\Modules\Mpls())->poll($os); diff --git a/includes/polling/nac.inc.php b/includes/polling/nac.inc.php index 372fbb9b74..8ee6a2e876 100644 --- a/includes/polling/nac.inc.php +++ b/includes/polling/nac.inc.php @@ -26,7 +26,7 @@ use LibreNMS\OS; -if (!$os instanceof OS) { +if (! $os instanceof OS) { $os = OS::make($device); } (new \LibreNMS\Modules\Nac())->poll($os); diff --git a/includes/polling/netscaler-vsvr.inc.php b/includes/polling/netscaler-vsvr.inc.php index 10fa83c64f..17c65b5889 100644 --- a/includes/polling/netscaler-vsvr.inc.php +++ b/includes/polling/netscaler-vsvr.inc.php @@ -33,41 +33,41 @@ use LibreNMS\RRD\RrdDefinition; if ($device['os'] == 'netscaler') { - $oids_gauge = array( - 'vsvrCurClntConnections', - 'vsvrCurSrvrConnections', - ); + $oids_gauge = [ + 'vsvrCurClntConnections', + 'vsvrCurSrvrConnections', + ]; - $oids_counter = array( - 'vsvrSurgeCount', - 'vsvrTotalRequests', - 'vsvrTotalRequestBytes', - 'vsvrTotalResponses', - 'vsvrTotalResponseBytes', - 'vsvrTotalPktsRecvd', - 'vsvrTotalPktsSent', - 'vsvrTotalSynsRecvd', - 'vsvrTotMiss', - 'vsvrTotHits', - 'vsvrTotSpillOvers', - 'vsvrTotalClients', - ); + $oids_counter = [ + 'vsvrSurgeCount', + 'vsvrTotalRequests', + 'vsvrTotalRequestBytes', + 'vsvrTotalResponses', + 'vsvrTotalResponseBytes', + 'vsvrTotalPktsRecvd', + 'vsvrTotalPktsSent', + 'vsvrTotalSynsRecvd', + 'vsvrTotMiss', + 'vsvrTotHits', + 'vsvrTotSpillOvers', + 'vsvrTotalClients', + ]; $oids = array_merge($oids_gauge, $oids_counter); $rrd_def = new RrdDefinition(); foreach ($oids_gauge as $oid) { - $oid_ds = str_replace('vsvr', '', $oid); + $oid_ds = str_replace('vsvr', '', $oid); $rrd_def->addDataset($oid_ds, 'GAUGE', null, 100000000000); } foreach ($oids_counter as $oid) { - $oid_ds = str_replace('vsvr', '', $oid); + $oid_ds = str_replace('vsvr', '', $oid); $rrd_def->addDataset($oid_ds, 'COUNTER', null, 100000000000); } - $vsvr_array = snmpwalk_cache_oid($device, 'vserverEntry', array(), 'NS-ROOT-MIB'); + $vsvr_array = snmpwalk_cache_oid($device, 'vserverEntry', [], 'NS-ROOT-MIB'); - $vsvr_db = dbFetchRows('SELECT * FROM `netscaler_vservers` WHERE `device_id` = ?', array($device['device_id'])); + $vsvr_db = dbFetchRows('SELECT * FROM `netscaler_vservers` WHERE `device_id` = ?', [$device['device_id']]); foreach ($vsvr_db as $vsvr) { $vsvrs[$vsvr['vsvr_name']] = $vsvr; print_r($vsvr); @@ -78,9 +78,9 @@ if ($device['os'] == 'netscaler') { foreach ($vsvr_array as $index => $vsvr) { if (isset($vsvr['vsvrFullName'])) { $vsvr_exist[$vsvr['vsvrFullName']] = 1; - $rrd_name = 'netscaler-vsvr-'.$vsvr['vsvrFullName']; + $rrd_name = 'netscaler-vsvr-' . $vsvr['vsvrFullName']; - $fields = array(); + $fields = []; foreach ($oids as $oid) { $oid_ds = str_replace('vsvr', '', $oid); if (is_numeric($vsvr[$oid])) { @@ -90,32 +90,32 @@ if ($device['os'] == 'netscaler') { } } - $tags = array( + $tags = [ 'vsvrFullName' => $vsvr['vsvrFullName'], 'rrd_name' => $rrd_name, - 'rrd_def' => $rrd_def - ); + 'rrd_def' => $rrd_def, + ]; data_update($device, 'netscaler-vsvr', $tags, $fields); - echo str_pad($vsvr['vsvrFullName'], 25).' | '.str_pad($vsvr['vsvrType'], 5).' | '.str_pad($vsvr['vsvrState'], 6).' | '.str_pad($vsvr['vsvrIpAddress'], 16).' | '.str_pad($vsvr['vsvrPort'], 5); - echo ' | '.str_pad($vsvr['vsvrRequestRate'], 8).' | '.str_pad($vsvr['vsvrRxBytesRate'].'B/s', 8).' | '.str_pad($vsvr['vsvrTxBytesRate'].'B/s', 8); + echo str_pad($vsvr['vsvrFullName'], 25) . ' | ' . str_pad($vsvr['vsvrType'], 5) . ' | ' . str_pad($vsvr['vsvrState'], 6) . ' | ' . str_pad($vsvr['vsvrIpAddress'], 16) . ' | ' . str_pad($vsvr['vsvrPort'], 5); + echo ' | ' . str_pad($vsvr['vsvrRequestRate'], 8) . ' | ' . str_pad($vsvr['vsvrRxBytesRate'] . 'B/s', 8) . ' | ' . str_pad($vsvr['vsvrTxBytesRate'] . 'B/s', 8); - $db_update = array( - 'vsvr_ip' => $vsvr['vsvrIpAddress'], - 'vsvr_port' => $vsvr['vsvrPort'], - 'vsvr_state' => $vsvr['vsvrState'], - 'vsvr_type' => $vsvr['vsvrType'], - 'vsvr_req_rate' => $vsvr['RequestRate'], - 'vsvr_bps_in' => $vsvr['vsvrRxBytesRate'], - 'vsvr_bps_out' => $vsvr['vsvrTxBytesRate'], - ); + $db_update = [ + 'vsvr_ip' => $vsvr['vsvrIpAddress'], + 'vsvr_port' => $vsvr['vsvrPort'], + 'vsvr_state' => $vsvr['vsvrState'], + 'vsvr_type' => $vsvr['vsvrType'], + 'vsvr_req_rate' => $vsvr['RequestRate'], + 'vsvr_bps_in' => $vsvr['vsvrRxBytesRate'], + 'vsvr_bps_out' => $vsvr['vsvrTxBytesRate'], + ]; - if (!is_array($vsvrs[$vsvr['vsvrFullName']])) { - $db_insert = array_merge(array('device_id' => $device['device_id'], 'vsvr_name' => $vsvr['vsvrFullName']), $db_update); - $vsvr_id = dbInsert($db_insert, 'netscaler_vservers'); + if (! is_array($vsvrs[$vsvr['vsvrFullName']])) { + $db_insert = array_merge(['device_id' => $device['device_id'], 'vsvr_name' => $vsvr['vsvrFullName']], $db_update); + $vsvr_id = dbInsert($db_insert, 'netscaler_vservers'); echo ' +'; } else { - $updated = dbUpdate($db_update, 'netscaler_vservers', '`vsvr_id` = ?', array($vsvrs[$vsvr['vsvrFullName']]['vsvr_id'])); + $updated = dbUpdate($db_update, 'netscaler_vservers', '`vsvr_id` = ?', [$vsvrs[$vsvr['vsvrFullName']]['vsvr_id']]); echo ' U'; } @@ -126,9 +126,9 @@ if ($device['os'] == 'netscaler') { d_echo($vsvr_exist); foreach ($vsvrs as $db_name => $db_id) { - if (!$vsvr_exist[$db_name]) { - echo '-'.$db_name; - dbDelete('netscaler_vservers', '`vsvr_id` = ?', array($db_id)); + if (! $vsvr_exist[$db_name]) { + echo '-' . $db_name; + dbDelete('netscaler_vservers', '`vsvr_id` = ?', [$db_id]); } } }//end if diff --git a/includes/polling/netstats/netstats-icmp.inc.php b/includes/polling/netstats/netstats-icmp.inc.php index 00f8dfb438..9f50853225 100644 --- a/includes/polling/netstats/netstats-icmp.inc.php +++ b/includes/polling/netstats/netstats-icmp.inc.php @@ -3,11 +3,11 @@ use Illuminate\Support\Str; use LibreNMS\RRD\RrdDefinition; -if (!Str::startsWith($device['os'], array('Snom', 'asa'))) { +if (! Str::startsWith($device['os'], ['Snom', 'asa'])) { echo ' ICMP'; // Below have more oids, and are in trees by themselves, so we can snmpwalk_cache_oid them - $oids = array( + $oids = [ 'icmpInMsgs', 'icmpOutMsgs', 'icmpInErrors', @@ -34,14 +34,14 @@ if (!Str::startsWith($device['os'], array('Snom', 'asa'))) { 'icmpOutTimestampReps', 'icmpOutAddrMasks', 'icmpOutAddrMaskReps', - ); + ]; - $data = snmpwalk_cache_oid($device, 'icmp', array(), 'IP-MIB'); + $data = snmpwalk_cache_oid($device, 'icmp', [], 'IP-MIB'); $data = $data[0]; if (isset($data['icmpInMsgs']) && isset($data['icmpOutMsgs'])) { $rrd_def = new RrdDefinition(); - $fields = array(); + $fields = []; foreach ($oids as $oid) { $rrd_def->addDataset($oid, 'COUNTER', null, 100000000000); $fields[substr($oid, 0, 19)] = isset($data[$oid]) ? $data[$oid] : 'U'; diff --git a/includes/polling/netstats/netstats-ip.inc.php b/includes/polling/netstats/netstats-ip.inc.php index e467fe70c0..d1a91acc57 100644 --- a/includes/polling/netstats/netstats-ip.inc.php +++ b/includes/polling/netstats/netstats-ip.inc.php @@ -3,7 +3,7 @@ use Illuminate\Support\Str; use LibreNMS\RRD\RrdDefinition; -if (!Str::startsWith($device['os'], ['Snom', 'asa'])) { +if (! Str::startsWith($device['os'], ['Snom', 'asa'])) { echo ' IP'; $oids = [ diff --git a/includes/polling/netstats/netstats-ip_forward.inc.php b/includes/polling/netstats/netstats-ip_forward.inc.php index f6db3048bc..f87c26f703 100644 --- a/includes/polling/netstats/netstats-ip_forward.inc.php +++ b/includes/polling/netstats/netstats-ip_forward.inc.php @@ -3,11 +3,11 @@ use Illuminate\Support\Str; use LibreNMS\RRD\RrdDefinition; -if (!Str::startsWith($device['os'], array('Snom', 'asa'))) { +if (! Str::startsWith($device['os'], ['Snom', 'asa'])) { echo ' IP-FORWARD'; $oid = 'ipCidrRouteNumber'; - $fields = array(); + $fields = []; $rrd_def = RrdDefinition::make()->addDataset($oid, 'GAUGE', null, 5000000); $data = snmp_get($device, 'IP-FORWARD-MIB::' . $oid . '.0', '-OQv'); if (is_numeric($data)) { diff --git a/includes/polling/netstats/netstats-snmp.inc.php b/includes/polling/netstats/netstats-snmp.inc.php index 2f1460b94f..d66df6e394 100644 --- a/includes/polling/netstats/netstats-snmp.inc.php +++ b/includes/polling/netstats/netstats-snmp.inc.php @@ -6,7 +6,7 @@ if ($device['os'] != 'Snom') { echo ' SNMP'; // Below have more oids, and are in trees by themselves, so we can snmpwalk_cache_oid them - $oids = array( + $oids = [ 'snmpInPkts', 'snmpOutPkts', 'snmpInBadVersions', @@ -36,13 +36,13 @@ if ($device['os'] != 'Snom') { 'snmpOutTraps', 'snmpSilentDrops', 'snmpProxyDrops', - ); + ]; - $data = snmpwalk_cache_oid($device, 'snmp', array(), 'SNMPv2-MIB'); + $data = snmpwalk_cache_oid($device, 'snmp', [], 'SNMPv2-MIB'); if (isset($data[0]['snmpInPkts'])) { $rrd_def = new RrdDefinition(); - $fields = array(); + $fields = []; foreach ($oids as $oid) { $rrd_def->addDataset($oid, 'COUNTER', null, 100000000000); $fields[substr($oid, 0, 19)] = isset($data[0][$oid]) ? $data[0][$oid] : 'U'; diff --git a/includes/polling/netstats/netstats-tcp.inc.php b/includes/polling/netstats/netstats-tcp.inc.php index f4b7ff5783..f5fe165f0f 100644 --- a/includes/polling/netstats/netstats-tcp.inc.php +++ b/includes/polling/netstats/netstats-tcp.inc.php @@ -3,7 +3,7 @@ use Illuminate\Support\Str; use LibreNMS\RRD\RrdDefinition; -if (!Str::startsWith($device['os'], ['Snom', 'asa'])) { +if (! Str::startsWith($device['os'], ['Snom', 'asa'])) { echo ' TCP'; $oids = [ 'tcpActiveOpens', @@ -35,8 +35,8 @@ if (!Str::startsWith($device['os'], ['Snom', 'asa'])) { } // Replace Segs with HC Segs if we have them. - $fields['tcpInSegs'] = !empty($hc_data['tcpHCInSegs']) ? $hc_data['tcpHCInSegs'] : $fields['tcpInSegs']; - $fields['tcpOutSegs'] = !empty($hc_data['tcpHCOutSegs']) ? $hc_data['tcpHCOutSegs'] : $fields['tcpOutSegs']; + $fields['tcpInSegs'] = ! empty($hc_data['tcpHCInSegs']) ? $hc_data['tcpHCInSegs'] : $fields['tcpInSegs']; + $fields['tcpOutSegs'] = ! empty($hc_data['tcpHCOutSegs']) ? $hc_data['tcpHCOutSegs'] : $fields['tcpOutSegs']; $tags = compact('rrd_def'); data_update($device, 'netstats-tcp', $tags, $fields); diff --git a/includes/polling/netstats/netstats-udp.inc.php b/includes/polling/netstats/netstats-udp.inc.php index 451b69a746..4860ec1bee 100644 --- a/includes/polling/netstats/netstats-udp.inc.php +++ b/includes/polling/netstats/netstats-udp.inc.php @@ -3,7 +3,7 @@ use Illuminate\Support\Str; use LibreNMS\RRD\RrdDefinition; -if (!Str::startsWith($device['os'], ['Snom', 'asa'])) { +if (! Str::startsWith($device['os'], ['Snom', 'asa'])) { echo ' UDP'; $oids = [ diff --git a/includes/polling/ntp/awplus.inc.php b/includes/polling/ntp/awplus.inc.php index a74d0a792d..06792e81c3 100644 --- a/includes/polling/ntp/awplus.inc.php +++ b/includes/polling/ntp/awplus.inc.php @@ -16,10 +16,10 @@ use LibreNMS\RRD\RrdDefinition; $tmp_module = 'ntp'; $component = new LibreNMS\Component(); -$options = array(); -$options['filter']['type'] = array('=',$tmp_module); -$options['filter']['disabled'] = array('=',0); -$options['filter']['ignore'] = array('=',0); +$options = []; +$options['filter']['type'] = ['=', $tmp_module]; +$options['filter']['disabled'] = ['=', 0]; +$options['filter']['ignore'] = ['=', 0]; $components = $component->getComponents($device['device_id'], $options); // We only care about our device id. @@ -35,7 +35,7 @@ if (count($components > 0)) { $peer = $array['peer']; // Let's make sure the rrd is setup for this class. - $rrd_name = array('ntp', $peer); + $rrd_name = ['ntp', $peer]; $rrd_def = RrdDefinition::make() ->addDataset('stratum', 'GAUGE', 0, 16) ->addDataset('offset', 'GAUGE', -1000) @@ -58,20 +58,20 @@ if (count($components > 0)) { $rrd['offset'] = str_replace(' milliseconds', '', $rrd['offset']); $rrd['offset'] = $rrd['offset'] / 1000; // Convert to seconds $rrd['delay'] = $atNtpAssociationEntry[$array['UID']]['atNtpAssociationDelay']; - $rrd['delay'] = str_replace(' milliseconds', '', $rrd['delay']); + $rrd['delay'] = str_replace(' milliseconds', '', $rrd['delay']); $rrd['delay'] = $rrd['delay'] / 1000; // Convert to seconds $rrd['dispersion'] = $atNtpAssociationEntry[$array['UID']]['atNtpAssociationDisp']; $tags = compact('ntp', 'rrd_name', 'rrd_def', 'peer'); data_update($device, 'ntp', $tags, $rrd); // Let's print some debugging info. - d_echo("\n\nComponent: ".$key."\n"); - d_echo(" Index: ".$array['UID']."\n"); - d_echo(" Peer: ".$array['peer'].":".$array['port']."\n"); - d_echo(" Stratum: atNtpAssociationStratum.".$array['UID']." = ".$rrd['stratum']."\n"); - d_echo(" Offset: atNtpAssociationOffset.".$array['UID']." = ".$rrd['offset']."\n"); - d_echo(" Delay: atNtpAssociationDelay.".$array['UID']." = ".$rrd['delay']."\n"); - d_echo(" Dispersion: atNtpAssociationDisp.".$array['UID']." = ".$rrd['dispersion']."\n"); + d_echo("\n\nComponent: " . $key . "\n"); + d_echo(" Index: " . $array['UID'] . "\n"); + d_echo(" Peer: " . $array['peer'] . ":" . $array['port'] . "\n"); + d_echo(" Stratum: atNtpAssociationStratum." . $array['UID'] . " = " . $rrd['stratum'] . "\n"); + d_echo(" Offset: atNtpAssociationOffset." . $array['UID'] . " = " . $rrd['offset'] . "\n"); + d_echo(" Delay: atNtpAssociationDelay." . $array['UID'] . " = " . $rrd['delay'] . "\n"); + d_echo(" Dispersion: atNtpAssociationDisp." . $array['UID'] . " = " . $rrd['dispersion'] . "\n"); // Clean-up after yourself! unset($filename, $rrd_filename, $rrd); diff --git a/includes/polling/ntp/cisco.inc.php b/includes/polling/ntp/cisco.inc.php index 0ecf49b0a0..ab78740243 100644 --- a/includes/polling/ntp/cisco.inc.php +++ b/includes/polling/ntp/cisco.inc.php @@ -16,10 +16,10 @@ use LibreNMS\RRD\RrdDefinition; $tmp_module = 'ntp'; $component = new LibreNMS\Component(); -$options = array(); -$options['filter']['type'] = array('=',$tmp_module); -$options['filter']['disabled'] = array('=',0); -$options['filter']['ignore'] = array('=',0); +$options = []; +$options['filter']['type'] = ['=', $tmp_module]; +$options['filter']['disabled'] = ['=', 0]; +$options['filter']['ignore'] = ['=', 0]; $components = $component->getComponents($device['device_id'], $options); // We only care about our device id. @@ -35,7 +35,7 @@ if (is_array($components) && count($components) > 0) { $peer = $array['peer']; // Let's make sure the rrd is setup for this class. - $rrd_name = array('ntp', $peer); + $rrd_name = ['ntp', $peer]; $rrd_def = RrdDefinition::make() ->addDataset('stratum', 'GAUGE', 0) ->addDataset('offset', 'GAUGE', 0) @@ -61,13 +61,13 @@ if (is_array($components) && count($components) > 0) { data_update($device, 'ntp', $tags, $rrd); // Let's print some debugging info. - d_echo("\n\nComponent: ".$key."\n"); - d_echo(" Index: ".$array['UID']."\n"); - d_echo(" Peer: ".$array['peer'].":".$array['port']."\n"); - d_echo(" Stratum: 1.3.6.1.4.1.9.9.168.1.2.1.1.9.".$array['UID']." = ".$rrd['stratum']."\n"); - d_echo(" Offset: 1.3.6.1.4.1.9.9.168.1.2.1.1.23.".$array['UID']." = ".$rrd['offset']."\n"); - d_echo(" Delay: 1.3.6.1.4.1.9.9.168.1.2.1.1.24.".$array['UID']." = ".$rrd['delay']."\n"); - d_echo(" Dispersion: 1.3.6.1.4.1.9.9.168.1.2.1.1.25.".$array['UID']." = ".$rrd['dispersion']."\n"); + d_echo("\n\nComponent: " . $key . "\n"); + d_echo(" Index: " . $array['UID'] . "\n"); + d_echo(" Peer: " . $array['peer'] . ":" . $array['port'] . "\n"); + d_echo(" Stratum: 1.3.6.1.4.1.9.9.168.1.2.1.1.9." . $array['UID'] . " = " . $rrd['stratum'] . "\n"); + d_echo(" Offset: 1.3.6.1.4.1.9.9.168.1.2.1.1.23." . $array['UID'] . " = " . $rrd['offset'] . "\n"); + d_echo(" Delay: 1.3.6.1.4.1.9.9.168.1.2.1.1.24." . $array['UID'] . " = " . $rrd['delay'] . "\n"); + d_echo(" Dispersion: 1.3.6.1.4.1.9.9.168.1.2.1.1.25." . $array['UID'] . " = " . $rrd['dispersion'] . "\n"); // Clean-up after yourself! unset($filename, $rrd_filename, $rrd); diff --git a/includes/polling/os.inc.php b/includes/polling/os.inc.php index 2fd5115124..8aea723610 100644 --- a/includes/polling/os.inc.php +++ b/includes/polling/os.inc.php @@ -2,7 +2,7 @@ use LibreNMS\OS; -if (!$os instanceof OS) { +if (! $os instanceof OS) { $os = OS::make($device); } (new \LibreNMS\Modules\OS())->poll($os); diff --git a/includes/polling/os/acsw.inc.php b/includes/polling/os/acsw.inc.php index 6d2ba4732b..cff16a5b53 100644 --- a/includes/polling/os/acsw.inc.php +++ b/includes/polling/os/acsw.inc.php @@ -3,13 +3,13 @@ $device['sysDescr'] = str_replace('IOS (tm)', 'IOS (tm),', $device['sysDescr']); $device['sysDescr'] = str_replace(') RELEASE', '), RELEASE', $device['sysDescr']); -echo "\n".$device['sysDescr']."\n"; +echo "\n" . $device['sysDescr'] . "\n"; -list(,$features,$version) = explode(',', $device['sysDescr']); +[,$features,$version] = explode(',', $device['sysDescr']); -$version = str_replace(' Version ', '', $version); -list(,$features) = explode('(', $features); -list(,$features) = explode('-', $features); +$version = str_replace(' Version ', '', $version); +[,$features] = explode('(', $features); +[,$features] = explode('-', $features); $oids = ['entPhysicalModelName.1', 'entPhysicalContainedIn.1', 'entPhysicalName.1', 'entPhysicalSoftwareRev.1', 'entPhysicalModelName.1001', 'entPhysicalContainedIn.1001', 'cardDescr.1', 'cardSlotNumber.1']; @@ -29,7 +29,7 @@ if ($data[1]['entPhysicalContainedIn'] == '0') { } } -list($version) = explode(',', $version); +[$version] = explode(',', $version); // if ($slot_1 == "-1" && strpos($descr_1, "No") === FALSE) { $ciscomodel = $descr_1; } // if (($contained_1 == "0" || $name_1 == "Chassis") && strpos($model_1, "No") === FALSE) { $ciscomodel = $model_1; list($version_1) = explode(",",$ver_1); } @@ -41,9 +41,9 @@ if ($hardware == '') { } if (strpos($device['sysDescr'], 'IOS XR')) { - list(,$version) = explode(',', $device['sysDescr']); - $version = trim($version); - list(,$version) = explode(' ', $version); - list($version) = explode("\n", $version); + [,$version] = explode(',', $device['sysDescr']); + $version = trim($version); + [,$version] = explode(' ', $version); + [$version] = explode("\n", $version); trim($version); } diff --git a/includes/polling/os/arbos.inc.php b/includes/polling/os/arbos.inc.php index f610247e55..7b74fb0a01 100644 --- a/includes/polling/os/arbos.inc.php +++ b/includes/polling/os/arbos.inc.php @@ -9,9 +9,9 @@ $flows = $oids[0]['deviceTotalFlows']; if (is_numeric($flows)) { $rrd_def = RrdDefinition::make()->addDataset('flows', 'GAUGE', 0, 3000000); - $fields = array( + $fields = [ 'flows' => $flows, - ); + ]; $tags = compact('rrd_def'); data_update($device, 'arbos_flows', $tags, $fields); diff --git a/includes/polling/os/areca.inc.php b/includes/polling/os/areca.inc.php index e1442a2dee..e3a0a90a71 100644 --- a/includes/polling/os/areca.inc.php +++ b/includes/polling/os/areca.inc.php @@ -1,17 +1,17 @@ */ - preg_match('/<>/', $device['sysDescr'], $matches); $hardware = $matches[3] . " (Rev: " . $matches[1] . ")"; diff --git a/includes/polling/os/asa.inc.php b/includes/polling/os/asa.inc.php index 280d7ea638..103411bb31 100644 --- a/includes/polling/os/asa.inc.php +++ b/includes/polling/os/asa.inc.php @@ -13,7 +13,7 @@ use Illuminate\Support\Str; -if (!Str::endsWith($device['hardware'], 'sc')) { +if (! Str::endsWith($device['hardware'], 'sc')) { $oids = ['entPhysicalModelName.1', 'entPhysicalSoftwareRev.1', 'entPhysicalSerialNum.1', 'entPhysicalModelName.4', 'entPhysicalSoftwareRev.4']; $data = snmp_get_multi($device, $oids, '-OQUs', 'ENTITY-MIB'); diff --git a/includes/polling/os/asyncos.inc.php b/includes/polling/os/asyncos.inc.php index 5c145b49b1..b83223045a 100644 --- a/includes/polling/os/asyncos.inc.php +++ b/includes/polling/os/asyncos.inc.php @@ -16,7 +16,7 @@ use LibreNMS\RRD\RrdDefinition; -list($hardware,$version,,$serial) = explode(',', $device['sysDescr']); +[$hardware,$version,,$serial] = explode(',', $device['sysDescr']); preg_match('/\w[\d]+\w?/', $hardware, $regexp_results); $hardware = $regexp_results[0]; @@ -27,7 +27,7 @@ $version = $regexp_results[0]; preg_match('/[[\w]+-[\w]+/', $serial, $regexp_results); $serial = $regexp_results[0]; -# Get stats only if device is web proxy +// Get stats only if device is web proxy if (strcmp($device['sysObjectID'], '.1.3.6.1.4.1.15497.1.2') == 0) { $connections = snmp_get($device, 'tcpCurrEstab.0', '-OQv', 'TCP-MIB'); @@ -35,9 +35,9 @@ if (strcmp($device['sysObjectID'], '.1.3.6.1.4.1.15497.1.2') == 0) { $rrd_name = 'asyncos_conns'; $rrd_def = RrdDefinition::make()->addDataset('connections', 'GAUGE', 0, 50000); - $fields = array( + $fields = [ 'connections' => $connections, - ); + ]; $tags = compact('rrd_def'); data_update($device, 'asyncos_conns', $tags, $fields); diff --git a/includes/polling/os/avaya-ipo.inc.php b/includes/polling/os/avaya-ipo.inc.php index 69d2beddae..22857ab3d3 100644 --- a/includes/polling/os/avaya-ipo.inc.php +++ b/includes/polling/os/avaya-ipo.inc.php @@ -1,4 +1,5 @@ */ - $version = trim(snmp_get($device, 'brzaccVLRunningSoftwareVersion.0', '-Oqv', 'ALVARION-DOT11-WLAN-MIB'), '"'); diff --git a/includes/polling/os/cat1900.inc.php b/includes/polling/os/cat1900.inc.php index 5097f86bd0..0b7b7fb72e 100644 --- a/includes/polling/os/cat1900.inc.php +++ b/includes/polling/os/cat1900.inc.php @@ -1,4 +1,4 @@ = '3') { +if (! strstr($ciscomodel, ' ') && strlen($ciscomodel) >= '3') { $hardware = $ciscomodel; } @@ -19,5 +19,5 @@ $device['sysDescr'] = str_replace(', Inc.', '', $device['sysDescr']); // Make the two formats the same $device['sysDescr'] = str_replace("\n", ' ', $device['sysDescr']); -list(,,$hardware,,,,,,,$version,,,$features) = explode(' ', $device['sysDescr']); -list(,$features) = explode('-', $features); +[,,$hardware,,,,,,,$version,,,$features] = explode(' ', $device['sysDescr']); +[,$features] = explode('-', $features); diff --git a/includes/polling/os/chatsworth-pdu.inc.php b/includes/polling/os/chatsworth-pdu.inc.php index dabd339b59..ee1ce495ee 100644 --- a/includes/polling/os/chatsworth-pdu.inc.php +++ b/includes/polling/os/chatsworth-pdu.inc.php @@ -22,6 +22,5 @@ * @copyright 2017 Lorenzo Zafra * @author Lorenzo Zafra */ - $serial = trim(snmp_get($device, '.1.3.6.1.4.1.30932.1.1.1.2.0', '-OQv'), '"'); $version = trim(snmp_get($device, '.1.3.6.1.4.1.30932.1.1.1.1.0', '-OQv'), '"'); diff --git a/includes/polling/os/ciscoepc.inc.php b/includes/polling/os/ciscoepc.inc.php index 4afcca4d3a..7df18cd2c5 100644 --- a/includes/polling/os/ciscoepc.inc.php +++ b/includes/polling/os/ciscoepc.inc.php @@ -22,8 +22,7 @@ * @copyright 2017 Neil Lathwood * @author Neil Lathwood */ - $ciscoepc = snmp_get_multi_oid($device, ['saHwDescrModel.0', 'saHwDescrSerialNumber.0'], '-OUQs', 'SA-HARDWARE-MIB'); $hardware = $ciscoepc['saHwDescrModel.0']; -$serial = $ciscoepc['saHwDescrSerialNumber.0']; +$serial = $ciscoepc['saHwDescrSerialNumber.0']; diff --git a/includes/polling/os/ciscosrp.inc.php b/includes/polling/os/ciscosrp.inc.php index 720c19e407..623bd0fcda 100644 --- a/includes/polling/os/ciscosrp.inc.php +++ b/includes/polling/os/ciscosrp.inc.php @@ -8,31 +8,30 @@ * @subpackage polling * @copyright (C) 2016 Librenms */ - $oids = ['entPhysicalModelName.1', 'entPhysicalContainedIn.1', 'entPhysicalName.1', 'entPhysicalSoftwareRev.1', 'entPhysicalModelName.1001', 'entPhysicalContainedIn.1001', 'cardDescr.1', 'cardSlotNumber.1']; $data = snmp_get_multi($device, $oids, '-OQUs', 'ENTITY-MIB:OLD-CISCO-CHASSIS-MIB'); if ($data[1]['entPhysicalContainedIn'] == '0') { - if (!empty($data[1]['entPhysicalSoftwareRev'])) { + if (! empty($data[1]['entPhysicalSoftwareRev'])) { $version = $data[1]['entPhysicalSoftwareRev']; } - if (!empty($data[1]['entPhysicalName'])) { + if (! empty($data[1]['entPhysicalName'])) { $hardware = $data[1]['entPhysicalName']; } - if (!empty($data[1]['entPhysicalModelName'])) { + if (! empty($data[1]['entPhysicalModelName'])) { $hardware = $data[1]['entPhysicalModelName']; } } -if (!empty($data[1000]['entPhysicalModelName'])) { +if (! empty($data[1000]['entPhysicalModelName'])) { $hardware = $data[1000]['entPhysicalModelName']; -} elseif (!empty($data[1000]['entPhysicalContainedIn'])) { +} elseif (! empty($data[1000]['entPhysicalContainedIn'])) { $hardware = $data[$data[1000]['entPhysicalContainedIn']]['entPhysicalName']; -} elseif (!empty($data[1001]['entPhysicalModelName'])) { +} elseif (! empty($data[1001]['entPhysicalModelName'])) { $hardware = $data[1001]['entPhysicalModelName']; -} elseif (!empty($data[1001]['entPhysicalContainedIn'])) { +} elseif (! empty($data[1001]['entPhysicalContainedIn'])) { $hardware = $data[$data[1001]['entPhysicalContainedIn']]['entPhysicalName']; } diff --git a/includes/polling/os/ciscowap.inc.php b/includes/polling/os/ciscowap.inc.php index 661c86a245..445cd59fec 100644 --- a/includes/polling/os/ciscowap.inc.php +++ b/includes/polling/os/ciscowap.inc.php @@ -5,4 +5,4 @@ preg_match('/(.*), Cisco Small Business (.*) \((.*)\)(.*)/', $device['sysDescr'], $matches); $hardware = $matches['2']; -$version = $matches['3']; +$version = $matches['3']; diff --git a/includes/polling/os/ciscowlc.inc.php b/includes/polling/os/ciscowlc.inc.php index 0c748a6361..dd32ac163b 100644 --- a/includes/polling/os/ciscowlc.inc.php +++ b/includes/polling/os/ciscowlc.inc.php @@ -32,9 +32,9 @@ if (empty($hardware)) { $hardware = snmp_get($device, 'sysObjectID.0', '-Osqv', 'SNMPv2-MIB:CISCO-PRODUCTS-MIB'); } -$stats = snmpwalk_cache_oid($device, "bsnAPEntry", $stats, 'AIRESPACE-WIRELESS-MIB', null, '-OQUsb'); -$radios = snmpwalk_cache_oid($device, "bsnAPIfEntry", $radios, 'AIRESPACE-WIRELESS-MIB', null, '-OQUsb'); -$APstats = snmpwalk_cache_oid($device, 'bsnApIfNoOfUsers', $APstats, 'AIRESPACE-WIRELESS-MIB', null, '-OQUsxb'); +$stats = snmpwalk_cache_oid($device, "bsnAPEntry", $stats, 'AIRESPACE-WIRELESS-MIB', null, '-OQUsb'); +$radios = snmpwalk_cache_oid($device, "bsnAPIfEntry", $radios, 'AIRESPACE-WIRELESS-MIB', null, '-OQUsb'); +$APstats = snmpwalk_cache_oid($device, 'bsnApIfNoOfUsers', $APstats, 'AIRESPACE-WIRELESS-MIB', null, '-OQUsxb'); $loadParams = snmpwalk_cache_oid($device, "bsnAPIfLoadChannelUtilization", $loadParams, 'AIRESPACE-WIRELESS-MIB', null, '-OQUsb'); $interferences = snmpwalk_cache_oid($device, "bsnAPIfInterferencePower", $interferences, 'AIRESPACE-WIRELESS-MIB', null, '-OQUsb'); @@ -49,34 +49,33 @@ $rrd_def = RrdDefinition::make() ->addDataset('NUMAPS', 'GAUGE', 0, 12500000000) ->addDataset('NUMCLIENTS', 'GAUGE', 0, 12500000000); -$fields = array( +$fields = [ 'NUMAPS' => $numAccessPoints, - 'NUMCLIENTS' => $numClients -); + 'NUMCLIENTS' => $numClients, +]; $tags = compact('rrd_def'); data_update($device, 'ciscowlc', $tags, $fields); - -$ap_db = dbFetchRows('SELECT * FROM `access_points` WHERE `device_id` = ?', array($device['device_id'])); +$ap_db = dbFetchRows('SELECT * FROM `access_points` WHERE `device_id` = ?', [$device['device_id']]); foreach ($radios as $key => $value) { $indexName = substr($key, 0, -2); - $channel = str_replace('ch', '', $value['bsnAPIfPhyChannelNumber']); - $mac = str_replace(' ', ':', $stats[$indexName]['bsnAPDot3MacAddress']); - $name = $stats[$indexName]['bsnAPName']; + $channel = str_replace('ch', '', $value['bsnAPIfPhyChannelNumber']); + $mac = str_replace(' ', ':', $stats[$indexName]['bsnAPDot3MacAddress']); + $name = $stats[$indexName]['bsnAPName']; $numasoclients = $value['bsnApIfNoOfUsers']; - $radioArray = explode('.', $key); - $radionum = array_pop($radioArray); - $txpow = $value['bsnAPIfPhyTxPowerLevel']; - $type = $value['bsnAPIfType']; - $interference = 128 + $interferences[$key . '.' . $channel]['bsnAPIfInterferencePower']; - $radioutil = $loadParams[$key]['bsnAPIfLoadChannelUtilization']; + $radioArray = explode('.', $key); + $radionum = array_pop($radioArray); + $txpow = $value['bsnAPIfPhyTxPowerLevel']; + $type = $value['bsnAPIfType']; + $interference = 128 + $interferences[$key . '.' . $channel]['bsnAPIfInterferencePower']; + $radioutil = $loadParams[$key]['bsnAPIfLoadChannelUtilization']; // TODO - $numactbssid = 0; - $nummonbssid = 0; + $numactbssid = 0; + $nummonbssid = 0; $nummonclients = 0; d_echo(" name: $name\n"); @@ -89,11 +88,11 @@ foreach ($radios as $key => $value) { d_echo(" interference: $interference\n"); // if there is a numeric channel, assume the rest of the data is valid, I guess - if (!is_numeric($channel)) { + if (! is_numeric($channel)) { continue; } - $rrd_name = array('arubaap', $name.$radionum); + $rrd_name = ['arubaap', $name . $radionum]; $rrd_def = RrdDefinition::make() ->addDataset('channel', 'GAUGE', 0, 200) ->addDataset('txpow', 'GAUGE', 0, 200) @@ -103,7 +102,7 @@ foreach ($radios as $key => $value) { ->addDataset('numasoclients', 'GAUGE', 0, 500) ->addDataset('interference', 'GAUGE', 0, 2000); - $fields = array( + $fields = [ 'channel' => $channel, 'txpow' => $txpow, 'radioutil' => $radioutil, @@ -111,7 +110,7 @@ foreach ($radios as $key => $value) { 'nummonbssid' => $nummonbssid, 'numasoclients' => $numasoclients, 'interference' => $interference, - ); + ]; $tags = compact('name', 'radionum', 'rrd_name', 'rrd_def'); data_update($device, 'arubaap', $tags, $fields); @@ -120,7 +119,7 @@ foreach ($radios as $key => $value) { for ($z = 0; $z < sizeof($ap_db); $z++) { if ($ap_db[$z]['name'] == $name && $ap_db[$z]['radio_number'] == $radionum) { - $foundid = $ap_db[$z]['accesspoint_id']; + $foundid = $ap_db[$z]['accesspoint_id']; $ap_db[$z]['seen'] = 1; continue; } @@ -128,26 +127,26 @@ foreach ($radios as $key => $value) { if ($foundid == 0) { $ap_id = dbInsert( - array( - 'device_id' => $device['device_id'], - 'name' => $name, - 'radio_number' => $radionum, - 'type' => $type, - 'mac_addr' => $mac, - 'channel' => $channel, - 'txpow' => $txpow, - 'radioutil' => $radioutil, - 'numasoclients' => $numasoclients, - 'nummonclients' => $nummonclients, - 'numactbssid' => $numactbssid, - 'nummonbssid' => $nummonbssid, - 'interference' => $interference - ), + [ + 'device_id' => $device['device_id'], + 'name' => $name, + 'radio_number' => $radionum, + 'type' => $type, + 'mac_addr' => $mac, + 'channel' => $channel, + 'txpow' => $txpow, + 'radioutil' => $radioutil, + 'numasoclients' => $numasoclients, + 'nummonclients' => $nummonclients, + 'numactbssid' => $numactbssid, + 'nummonbssid' => $nummonbssid, + 'interference' => $interference, + ], 'access_points' ); } else { dbUpdate( - array( + [ 'mac_addr' => $mac, 'type' => $type, 'deleted' => 0, @@ -158,17 +157,17 @@ foreach ($radios as $key => $value) { 'nummonclients' => $nummonclients, 'numactbssid' => $numactbssid, 'nummonbssid' => $nummonbssid, - 'interference' => $interference - ), + 'interference' => $interference, + ], 'access_points', '`accesspoint_id` = ?', - array($foundid) + [$foundid] ); } }//end foreach for ($z = 0; $z < sizeof($ap_db); $z++) { - if (!isset($ap_db[$z]['seen']) && $ap_db[$z]['deleted'] == 0) { - dbUpdate(array('deleted' => 1), 'access_points', '`accesspoint_id` = ?', array($ap_db[$z]['accesspoint_id'])); + if (! isset($ap_db[$z]['seen']) && $ap_db[$z]['deleted'] == 0) { + dbUpdate(['deleted' => 1], 'access_points', '`accesspoint_id` = ?', [$ap_db[$z]['accesspoint_id']]); } } diff --git a/includes/polling/os/clearpass.inc.php b/includes/polling/os/clearpass.inc.php index 95f62bebc3..2faf52a06d 100644 --- a/includes/polling/os/clearpass.inc.php +++ b/includes/polling/os/clearpass.inc.php @@ -22,15 +22,14 @@ * @copyright 2017 Neil Lathwood * @author Neil Lathwood */ - -$hardware_oid = '.1.3.6.1.4.1.14823.1.6.1.1.1.1.1.1.0'; -$serial_oid = '.1.3.6.1.4.1.14823.1.6.1.1.1.1.1.2.0'; -$firmware_oid = '.1.3.6.1.4.1.14823.1.6.1.1.1.1.1.3.0'; +$hardware_oid = '.1.3.6.1.4.1.14823.1.6.1.1.1.1.1.1.0'; +$serial_oid = '.1.3.6.1.4.1.14823.1.6.1.1.1.1.1.2.0'; +$firmware_oid = '.1.3.6.1.4.1.14823.1.6.1.1.1.1.1.3.0'; $clearpass_data = snmp_get_multi_oid($device, "$hardware_oid $serial_oid $firmware_oid"); $hardware = trim($clearpass_data[$hardware_oid], '"'); -$serial = trim($clearpass_data[$serial_oid], '"'); -$version = trim($clearpass_data[$firmware_oid], '"'); +$serial = trim($clearpass_data[$serial_oid], '"'); +$version = trim($clearpass_data[$firmware_oid], '"'); unset( $clearpass_data, diff --git a/includes/polling/os/cnpilote.inc.php b/includes/polling/os/cnpilote.inc.php index 9c592c6f2d..969b2e0eba 100644 --- a/includes/polling/os/cnpilote.inc.php +++ b/includes/polling/os/cnpilote.inc.php @@ -9,7 +9,6 @@ * the source code distribution for details. */ - $version = $device['sysDescr']; $cnpilot_data = snmp_get_multi_oid($device, ['cambiumAPSerialNum.0', 'cambiumAPHWType.0'], '-OUQs', 'CAMBIUM-MIB'); diff --git a/includes/polling/os/cnpilotr.inc.php b/includes/polling/os/cnpilotr.inc.php index 8d86ede84c..239912a424 100644 --- a/includes/polling/os/cnpilotr.inc.php +++ b/includes/polling/os/cnpilotr.inc.php @@ -11,6 +11,6 @@ $cnpilot_data = snmp_get_multi_oid($device, ['serialNumber.0', 'productName.0', 'hardwareVersion.0'], '-OUQs', 'CAMBIUM-MIB'); -$version = $cnpilot_data['hardwareVersion.0']; +$version = $cnpilot_data['hardwareVersion.0']; $hardware = $cnpilot_data['productName.0']; -$serial = $cnpilot_data['serialNumber.0']; +$serial = $cnpilot_data['serialNumber.0']; diff --git a/includes/polling/os/ctcu.inc.php b/includes/polling/os/ctcu.inc.php index af3fb61f0e..7b42bae16c 100644 --- a/includes/polling/os/ctcu.inc.php +++ b/includes/polling/os/ctcu.inc.php @@ -22,5 +22,4 @@ * @copyright 2016 Neil Lathwood * @author Neil Lathwood */ - $hardware = str_replace(' GigaBit Ethernet Switch', '', $device['sysDescr']); diff --git a/includes/polling/os/datacom.inc.php b/includes/polling/os/datacom.inc.php index b4dfc043f0..945f2a2400 100644 --- a/includes/polling/os/datacom.inc.php +++ b/includes/polling/os/datacom.inc.php @@ -1,5 +1,6 @@ */ - -list($hardware, $version) = preg_split('/ /', preg_replace('/([\\\"]+)/', '', $device['sysDescr'])); +[$hardware, $version] = preg_split('/ /', preg_replace('/([\\\"]+)/', '', $device['sysDescr'])); diff --git a/includes/polling/os/digipower.inc.php b/includes/polling/os/digipower.inc.php index 152d50d8cc..82b0f8dc31 100644 --- a/includes/polling/os/digipower.inc.php +++ b/includes/polling/os/digipower.inc.php @@ -1,10 +1,10 @@ */ - $tmp_ees = snmp_get_multi($device, ['identControllerFirmwareVersion.0', 'identControllerSerialNumber.0'], '-OQUs', 'EES-POWER-MIB'); $version = $tmp_ees[0]['identControllerFirmwareVersion']; -$serial = $tmp_ees[0]['identControllerSerialNumber']; +$serial = $tmp_ees[0]['identControllerSerialNumber']; unset($tmp_ees); diff --git a/includes/polling/os/elg-ipecs-es.inc.php b/includes/polling/os/elg-ipecs-es.inc.php index afba2a7eec..35775224d5 100644 --- a/includes/polling/os/elg-ipecs-es.inc.php +++ b/includes/polling/os/elg-ipecs-es.inc.php @@ -22,7 +22,6 @@ * @copyright 2017 Neil Lathwood * @author Neil Lathwood */ - -list ($hardware, $dump) = explode(' ', $device['sysDescr'], 2); +[$hardware, $dump] = explode(' ', $device['sysDescr'], 2); unset($dump); diff --git a/includes/polling/os/elg-ipecs-ucp.inc.php b/includes/polling/os/elg-ipecs-ucp.inc.php index 9a451800a7..e23f8d9525 100644 --- a/includes/polling/os/elg-ipecs-ucp.inc.php +++ b/includes/polling/os/elg-ipecs-ucp.inc.php @@ -22,5 +22,4 @@ * @copyright 2017 Neil Lathwood * @author Neil Lathwood */ - -list(,$hardware,) = explode(',', $device['sysDescr'], 3); +[,$hardware,] = explode(',', $device['sysDescr'], 3); diff --git a/includes/polling/os/eltex-olt.inc.php b/includes/polling/os/eltex-olt.inc.php index 0f99fc671c..0df7dc6aa0 100644 --- a/includes/polling/os/eltex-olt.inc.php +++ b/includes/polling/os/eltex-olt.inc.php @@ -22,9 +22,8 @@ * @copyright 2017 Neil Lathwood * @author Neil Lathwood */ - $tmp_eltex = snmp_get($device, 'ltp8xFirmwareRevision.0', '-Ovq', 'ELTEX-LTP8X-STANDALONE'); -list($hardware, $tmp_eltex) = explode(':', $tmp_eltex); +[$hardware, $tmp_eltex] = explode(':', $tmp_eltex); $tmp_eltex = preg_split('/(software version| on)/', $tmp_eltex); $version = $tmp_eltex['1']; diff --git a/includes/polling/os/engenius.inc.php b/includes/polling/os/engenius.inc.php index ae80f3b09e..bfc7c9d7bf 100644 --- a/includes/polling/os/engenius.inc.php +++ b/includes/polling/os/engenius.inc.php @@ -1,8 +1,8 @@ */ - $tmp_enlogic = snmp_get_multi_oid($device, 'pduNamePlateModelNumber pduNamePlateSerialNumber pduNamePlateFirmwareVersion', '-OUQn', 'ENLOGIC-PDU-MIB'); $hardware = $tmp_enlogic['.1.3.6.1.4.1.38446.1.1.2.1.10.1']; -$serial = $tmp_enlogic['.1.3.6.1.4.1.38446.1.1.2.1.11.1']; -$version = $tmp_enlogic['.1.3.6.1.4.1.38446.1.1.2.1.13.1']; +$serial = $tmp_enlogic['.1.3.6.1.4.1.38446.1.1.2.1.11.1']; +$version = $tmp_enlogic['.1.3.6.1.4.1.38446.1.1.2.1.13.1']; unset($tmp_enlogic); diff --git a/includes/polling/os/epmp.inc.php b/includes/polling/os/epmp.inc.php index 65d5e586d3..fd3f9101c5 100644 --- a/includes/polling/os/epmp.inc.php +++ b/includes/polling/os/epmp.inc.php @@ -36,10 +36,10 @@ if (is_numeric($cambiumGPSNumTrackedSat) && is_numeric($cambiumGPSNumVisibleSat) $rrd_def = RrdDefinition::make() ->addDataset('numTracked', 'GAUGE', 0, 100000) ->addDataset('numVisible', 'GAUGE', 0, 100000); - $fields = array( + $fields = [ 'numTracked' => $cambiumGPSNumTrackedSat, - 'numVisible' => $cambiumGPSNumVisibleSat - ); + 'numVisible' => $cambiumGPSNumVisibleSat, + ]; $tags = compact('rrd_def'); data_update($device, 'cambium-epmp-gps', $tags, $fields); $os->enableGraph('cambium_epmp_gps'); @@ -51,10 +51,10 @@ if (is_numeric($cambiumSTAUplinkMCSMode) && is_numeric($cambiumSTADownlinkMCSMod $rrd_def = RrdDefinition::make() ->addDataset('uplinkMCSMode', 'GAUGE', -30, 30) ->addDataset('downlinkMCSMode', 'GAUGE', -30, 30); - $fields = array( + $fields = [ 'uplinkMCSMode' => $cambiumSTAUplinkMCSMode, - 'downlinkMCSMode' => $cambiumSTADownlinkMCSMode - ); + 'downlinkMCSMode' => $cambiumSTADownlinkMCSMode, + ]; $tags = compact('rrd_def'); data_update($device, 'cambium-epmp-modulation', $tags, $fields); $os->enableGraph('cambium_epmp_modulation'); @@ -68,17 +68,16 @@ if (is_numeric($sysNetworkEntryAttempt) && is_numeric($sysNetworkEntrySuccess) & ->addDataset('entryAttempt', 'GAUGE', 0, 100000) ->addDataset('entryAccess', 'GAUGE', 0, 100000) ->addDataset('authFailure', 'GAUGE', 0, 100000); - $fields = array( + $fields = [ 'entryAttempt' => $sysNetworkEntryAttempt, 'entryAccess' => $sysNetworkEntrySuccess, - 'authFailure' => $sysNetworkEntryAuthenticationFailure - ); + 'authFailure' => $sysNetworkEntryAuthenticationFailure, + ]; $tags = compact('rrd_def'); data_update($device, 'cambium-epmp-access', $tags, $fields); $os->enableGraph('cambium_epmp_access'); } - $multi_get_array = snmp_get_multi($device, ['ulWLanTotalAvailableFrameTimePerSecond.0', 'ulWLanTotalUsedFrameTimePerSecond.0', 'dlWLanTotalAvailableFrameTimePerSecond.0', 'dlWLanTotalUsedFrameTimePerSecond.0'], "-OQU", "CAMBIUM-PMP80211-MIB"); $ulWLanTotalAvailableFrameTimePerSecond = $multi_get_array[0]["CAMBIUM-PMP80211-MIB::ulWLanTotalAvailableFrameTimePerSecond"]; @@ -87,17 +86,17 @@ $dlWLanTotalAvailableFrameTimePerSecond = $multi_get_array[0]["CAMBIUM-PMP80211- $dlWLanTotalUsedFrameTimePerSecond = $multi_get_array[0]["CAMBIUM-PMP80211-MIB::dlWLanTotalUsedFrameTimePerSecond"]; if (is_numeric($ulWLanTotalAvailableFrameTimePerSecond) && is_numeric($ulWLanTotalUsedFrameTimePerSecond) && is_numeric($ulWLanTotalAvailableFrameTimePerSecond) && is_numeric($ulWLanTotalUsedFrameTimePerSecond)) { - $ulWlanFrameUtilization = round((($ulWLanTotalUsedFrameTimePerSecond/$ulWLanTotalAvailableFrameTimePerSecond)*100), 2); - $dlWlanFrameUtilization = round((($dlWLanTotalUsedFrameTimePerSecond/$dlWLanTotalAvailableFrameTimePerSecond)*100), 2); + $ulWlanFrameUtilization = round((($ulWLanTotalUsedFrameTimePerSecond / $ulWLanTotalAvailableFrameTimePerSecond) * 100), 2); + $dlWlanFrameUtilization = round((($dlWLanTotalUsedFrameTimePerSecond / $dlWLanTotalAvailableFrameTimePerSecond) * 100), 2); d_echo($dlWlanFrameUtilization); d_echo($ulWlanFrameUtilization); $rrd_def = RrdDefinition::make() ->addDataset('ulwlanfrut', 'GAUGE', 0, 100000) ->addDataset('dlwlanfrut', 'GAUGE', 0, 100000); - $fields = array( - 'ulwlanframeutilization' => $ulWlanFrameUtilization, - 'dlwlanframeutilization' => $dlWlanFrameUtilization - ); + $fields = [ + 'ulwlanframeutilization' => $ulWlanFrameUtilization, + 'dlwlanframeutilization' => $dlWlanFrameUtilization, + ]; $tags = compact('rrd_def'); data_update($device, 'cambium-epmp-frameUtilization', $tags, $fields); $os->enableGraph('cambium-epmp-frameUtilization'); diff --git a/includes/polling/os/etherwan.inc.php b/includes/polling/os/etherwan.inc.php index 71eef924e8..5cea9cd66f 100644 --- a/includes/polling/os/etherwan.inc.php +++ b/includes/polling/os/etherwan.inc.php @@ -22,7 +22,6 @@ * @copyright 2017 Lorenzo Zafra * @author Lorenzo Zafra */ - preg_match('~(?\'hardware\'.*?),\sFirmware\srev:\s(?\'version\'.*) \d\d\/\d\d\/\d\d~', $device['sysDescr'], $matches); if ($matches['hardware']) { diff --git a/includes/polling/os/extendair.inc.php b/includes/polling/os/extendair.inc.php index c78fe35e2c..28d7618cca 100644 --- a/includes/polling/os/extendair.inc.php +++ b/includes/polling/os/extendair.inc.php @@ -22,10 +22,9 @@ * @copyright 2017 Neil Lathwood * @author Neil Lathwood */ - $extendair_data = snmp_get_multi_oid($device, ['serialNumber.0', 'firmwareVersion.0'], '-OQs', 'ExaltComProducts'); -$serial = $extendair_data['serialNumber.0']; +$serial = $extendair_data['serialNumber.0']; $version = $extendair_data['firmwareVersion.0']; unset($extendair_data); diff --git a/includes/polling/os/f5.inc.php b/includes/polling/os/f5.inc.php index b1c47645a7..8013050228 100644 --- a/includes/polling/os/f5.inc.php +++ b/includes/polling/os/f5.inc.php @@ -1,7 +1,8 @@ [ 'dataset' => 'sessions', 'type' => 'GAUGE', - 'name' => 'bigip_apm_sessions' + 'name' => 'bigip_apm_sessions', ], 'sysStatClientTotConns' => [ 'dataset' => 'ClientTotConns', 'type' => 'COUNTER', - 'name' => 'bigip_system_client_connection_rate' + 'name' => 'bigip_system_client_connection_rate', ], 'sysStatServerTotConns' => [ 'dataset' => 'ServerTotConns', 'type' => 'COUNTER', - 'name' => 'bigip_system_server_connection_rate' + 'name' => 'bigip_system_server_connection_rate', ], 'sysStatClientCurConns' => [ 'dataset' => 'ClientCurConns', 'type' => 'GAUGE', - 'name' => 'bigip_system_client_concurrent_connections' + 'name' => 'bigip_system_client_concurrent_connections', ], 'sysStatServerCurConns' => [ 'dataset' => 'ServerCurConns', 'type' => 'GAUGE', - 'name' => 'bigip_system_server_concurrent_connections' + 'name' => 'bigip_system_server_concurrent_connections', ], ]; @@ -67,11 +67,10 @@ foreach ($metadata as $key => $info) { } } - -# SSL TPS +// SSL TPS $oids = [ - 'F5-BIGIP-SYSTEM-MIB::sysClientsslStatTotNativeConns.0', - 'F5-BIGIP-SYSTEM-MIB::sysClientsslStatTotCompatConns.0', + 'F5-BIGIP-SYSTEM-MIB::sysClientsslStatTotNativeConns.0', + 'F5-BIGIP-SYSTEM-MIB::sysClientsslStatTotCompatConns.0', ]; $data = snmp_get_multi($device, $oids, '-OQUs'); @@ -79,14 +78,13 @@ if (is_numeric($data[0]['sysClientsslStatTotNativeConns']) && is_numeric($data[0 $rrd_def = RrdDefinition::make() ->addDataset('TotNativeConns', 'COUNTER', 0) ->addDataset('TotCompatConns', 'COUNTER', 0); - $fields = array( - 'TotNativeConns' => $data[0]['sysClientsslStatTotNativeConns'], - 'TotCompatConns' => $data[0]['sysClientsslStatTotCompatConns'], - ); + $fields = [ + 'TotNativeConns' => $data[0]['sysClientsslStatTotNativeConns'], + 'TotCompatConns' => $data[0]['sysClientsslStatTotCompatConns'], + ]; $tags = compact('rrd_def'); data_update($device, 'bigip_system_tps', $tags, $fields); $os->enableGraph('bigip_system_tps'); } - unset($data, $oids, $metadata); diff --git a/includes/polling/os/foundryos.inc.php b/includes/polling/os/foundryos.inc.php index 443189858f..ee95ae2708 100644 --- a/includes/polling/os/foundryos.inc.php +++ b/includes/polling/os/foundryos.inc.php @@ -9,6 +9,6 @@ * option) any later version. Please see LICENSE.txt at the top level of * the source code distribution for details. */ - + preg_match('/Foundry Networks (.*)/', $device['sysDescr'], $data); $hardware = $data[1]; diff --git a/includes/polling/os/fujitsupyos.inc.php b/includes/polling/os/fujitsupyos.inc.php index c90f64974b..387091ef77 100644 --- a/includes/polling/os/fujitsupyos.inc.php +++ b/includes/polling/os/fujitsupyos.inc.php @@ -10,6 +10,6 @@ * the source code distribution for details. */ -$data = str_replace(array('Fujitsu ', ' Runtime Code '), '', explode(',', $device['sysDescr'])); +$data = str_replace(['Fujitsu ', ' Runtime Code '], '', explode(',', $device['sysDescr'])); $hardware = $data[0]; $version = $data[1]; diff --git a/includes/polling/os/fxm.inc.php b/includes/polling/os/fxm.inc.php index f15dc74eeb..a7dc9db01c 100644 --- a/includes/polling/os/fxm.inc.php +++ b/includes/polling/os/fxm.inc.php @@ -22,8 +22,7 @@ * @copyright 2017 Neil Lathwood * @author Neil Lathwood */ - -$fxm_tmp = snmp_get_multi_oid($device, ['upsIdentProductCode.0', 'upsIdentUPSSoftwareVersion.0'], '-OUQs', 'Argus-Power-System-MIB'); +$fxm_tmp = snmp_get_multi_oid($device, ['upsIdentProductCode.0', 'upsIdentUPSSoftwareVersion.0'], '-OUQs', 'Argus-Power-System-MIB'); $hardware = $fxm_tmp['upsIdentProductCode.0']; -$version = $fxm_tmp['upsIdentUPSSoftwareVersion.0']; +$version = $fxm_tmp['upsIdentUPSSoftwareVersion.0']; unset($fxm_tmp); diff --git a/includes/polling/os/fxos.inc.php b/includes/polling/os/fxos.inc.php index 4fe6152b8b..a953f0d462 100644 --- a/includes/polling/os/fxos.inc.php +++ b/includes/polling/os/fxos.inc.php @@ -9,10 +9,10 @@ * option) any later version. Please see LICENSE.txt at the top level of * the source code distribution for details. */ - + if (preg_match('/Version ([^,]+)/', $device['sysDescr'], $regexp_result)) { $version = $regexp_result[1]; } -$serial = snmp_get($device, "ENTITY-MIB::entPhysicalSerialNum.10", "-Osqnv"); +$serial = snmp_get($device, "ENTITY-MIB::entPhysicalSerialNum.10", "-Osqnv"); $hardware = snmp_get($device, 'sysObjectID.0', '-Osqv', 'SNMPv2-MIB:CISCO-PRODUCTS-MIB'); diff --git a/includes/polling/os/geist-pdu.inc.php b/includes/polling/os/geist-pdu.inc.php index 5923026167..c0829aece9 100644 --- a/includes/polling/os/geist-pdu.inc.php +++ b/includes/polling/os/geist-pdu.inc.php @@ -22,6 +22,5 @@ * @copyright 2017 Neil Lathwood * @author Neil Lathwood */ - -$version = snmp_get($device, 'productVersion.0', '-Oqv', 'GEIST-MIB-V3'); +$version = snmp_get($device, 'productVersion.0', '-Oqv', 'GEIST-MIB-V3'); $hardware = snmp_get($device, 'productHardware.0', '-Oqv', 'GEIST-MIB-V3'); diff --git a/includes/polling/os/geist-watchdog.inc.php b/includes/polling/os/geist-watchdog.inc.php index faafc6f829..405b05b749 100644 --- a/includes/polling/os/geist-watchdog.inc.php +++ b/includes/polling/os/geist-watchdog.inc.php @@ -22,6 +22,5 @@ * @copyright 2017 Neil Lathwood * @author Neil Lathwood */ - -$serial = snmp_get($device, 'climateSerial.1', '-Oqv', 'GEIST-MIB-V3'); +$serial = snmp_get($device, 'climateSerial.1', '-Oqv', 'GEIST-MIB-V3'); $version = snmp_get($device, 'productVersion.0', '-Oqv', 'GEIST-MIB-V3'); diff --git a/includes/polling/os/hpe-ipdu.inc.php b/includes/polling/os/hpe-ipdu.inc.php index d9b0cb5732..063cb1f733 100644 --- a/includes/polling/os/hpe-ipdu.inc.php +++ b/includes/polling/os/hpe-ipdu.inc.php @@ -22,7 +22,6 @@ * @copyright 2017 Neil Lathwood * @author Neil Lathwood */ - $hpe_ipdu_data = snmp_get_multi_oid($device, ['mpduFirmwareVersion.0', 'mpduSerialNumber.0', 'mpduModel.0'], '-OUQs', 'CPQPOWER-MIB'); $serial = trim($hpe_ipdu_data['mpduSerialNumber.1'], '"'); diff --git a/includes/polling/os/hpe-msl.inc.php b/includes/polling/os/hpe-msl.inc.php index 29d4b293df..4ef53a6eea 100644 --- a/includes/polling/os/hpe-msl.inc.php +++ b/includes/polling/os/hpe-msl.inc.php @@ -22,7 +22,6 @@ * @copyright 2016 Neil Lathwood * @author Neil Lathwood */ - $oids = ['hpHttpMgDeviceProductName.1', 'hpHttpMgDeviceSerialNumber.1', 'hpHttpMgDeviceVersion.1']; $data = snmp_get_multi($device, $oids, '-OQUs', 'SEMI-MIB'); diff --git a/includes/polling/os/hpe-rtups.inc.php b/includes/polling/os/hpe-rtups.inc.php index 9afde399af..c5d63b2ac0 100644 --- a/includes/polling/os/hpe-rtups.inc.php +++ b/includes/polling/os/hpe-rtups.inc.php @@ -1,7 +1,8 @@ -*/ - -$oids = array( - 'hardware' => $device['sysObjectID'].'.1.0', - 'version' => $device['sysObjectID'].'.2.1.1.0' -); + */ +$oids = [ + 'hardware' => $device['sysObjectID'] . '.1.0', + 'version' => $device['sysObjectID'] . '.2.1.1.0', +]; $os_data = snmp_get_multi_oid($device, $oids); diff --git a/includes/polling/os/junose.inc.php b/includes/polling/os/junose.inc.php index 73b00defb3..8caad8a873 100644 --- a/includes/polling/os/junose.inc.php +++ b/includes/polling/os/junose.inc.php @@ -2,16 +2,16 @@ if (strpos($device['sysDescr'], 'olive')) { $hardware = 'Olive'; - $serial = ''; + $serial = ''; } else { $junose_hardware = snmp_get($device, 'sysObjectID.0', '-Ovqs', '+Juniper-Products-MIB', 'junose'); - $junose_version = snmp_get($device, 'juniSystemSwVersion.0', '-Ovqs', '+Juniper-System-MIB', 'junose'); - $junose_serial = ''; + $junose_version = snmp_get($device, 'juniSystemSwVersion.0', '-Ovqs', '+Juniper-System-MIB', 'junose'); + $junose_serial = ''; - $hardware = 'Juniper '.rewrite_junose_hardware($junose_hardware); + $hardware = 'Juniper ' . rewrite_junose_hardware($junose_hardware); } -list($version) = explode(' ', $junose_version); -list(,$version) = explode('(', $version); -list($features) = explode(']', $junose_version); -list(,$features) = explode('[', $features); +[$version] = explode(' ', $junose_version); +[,$version] = explode('(', $version); +[$features] = explode(']', $junose_version); +[,$features] = explode('[', $features); diff --git a/includes/polling/os/jwos.inc.php b/includes/polling/os/jwos.inc.php index 689d033354..5d3113f059 100644 --- a/includes/polling/os/jwos.inc.php +++ b/includes/polling/os/jwos.inc.php @@ -8,6 +8,6 @@ $version = snmp_get($device, 'jnxWxSysSwVersion.0', '-Ovq', 'JUNIPER-WX-GLOBAL-R $serial = snmp_get($device, 'jnxWxSysSerialNumber.0', '-Ovq', 'JUNIPER-WX-GLOBAL-REG'); -$hardware = snmp_get($device, 'jnxWxChassisType.0', '-Ovq', 'JUNIPER-WX-GLOBAL-REG'); -$hardware = strtoupper(str_replace('jnx', '', $hardware)); -$hardware .= ' '.snmp_get($device, 'jnxWxSysHwVersion.0', '-Ovq', 'JUNIPER-WX-GLOBAL-REG'); +$hardware = snmp_get($device, 'jnxWxChassisType.0', '-Ovq', 'JUNIPER-WX-GLOBAL-REG'); +$hardware = strtoupper(str_replace('jnx', '', $hardware)); +$hardware .= ' ' . snmp_get($device, 'jnxWxSysHwVersion.0', '-Ovq', 'JUNIPER-WX-GLOBAL-REG'); diff --git a/includes/polling/os/kti.inc.php b/includes/polling/os/kti.inc.php index 36fd1be034..c6b6adad1d 100644 --- a/includes/polling/os/kti.inc.php +++ b/includes/polling/os/kti.inc.php @@ -1,4 +1,4 @@ $device['sysObjectID'].'.1.2.0', - 'version' => $device['sysObjectID'].'.1.4.0', - 'serial' => $device['sysObjectID'].'.1.78.0', -); +$oids = [ + 'hardware' => $device['sysObjectID'] . '.1.2.0', + 'version' => $device['sysObjectID'] . '.1.4.0', + 'serial' => $device['sysObjectID'] . '.1.78.0', +]; $os_data = snmp_get_multi_oid($device, $oids); diff --git a/includes/polling/os/moxa-nport.inc.php b/includes/polling/os/moxa-nport.inc.php index 9f6fb2043d..ec9e2a01c8 100644 --- a/includes/polling/os/moxa-nport.inc.php +++ b/includes/polling/os/moxa-nport.inc.php @@ -14,4 +14,4 @@ // SNMPv2-MIB::sysObjectID.0 = OID: SNMPv2-SMI::enterprises.8691.2.7 // DISMAN-EVENT-MIB::sysUpTimeInstance = Timeticks: (50870289) 5 days, 21:18:22.89 -$hardware = $device['sysDescr']; +$hardware = $device['sysDescr']; diff --git a/includes/polling/os/msl.inc.php b/includes/polling/os/msl.inc.php index 03f581041a..ce4ae992a5 100644 --- a/includes/polling/os/msl.inc.php +++ b/includes/polling/os/msl.inc.php @@ -12,14 +12,14 @@ * the source code distribution for details. */ -$mslhw = $device['sysDescr']; -$version_oid = '.1.3.6.1.4.1.1027.4.1.2.1.1.1.4.10.1.3.6.1.4.1.1027.1.6.1'; -$features_oid = '.1.3.6.1.4.1.1027.4.1.2.1.1.1.5.10.1.3.6.1.4.1.1027.1.6.1'; -$oids = array("mitelAppTblProductVersion.10.1.3.6.1.4.1.1027.1.6.1", "mitelAppTblProductDescr.10.1.3.6.1.4.1.1027.1.6.1"); +$mslhw = $device['sysDescr']; +$version_oid = '.1.3.6.1.4.1.1027.4.1.2.1.1.1.4.10.1.3.6.1.4.1.1027.1.6.1'; +$features_oid = '.1.3.6.1.4.1.1027.4.1.2.1.1.1.5.10.1.3.6.1.4.1.1027.1.6.1'; +$oids = ["mitelAppTblProductVersion.10.1.3.6.1.4.1.1027.1.6.1", "mitelAppTblProductDescr.10.1.3.6.1.4.1.1027.1.6.1"]; $mitelapptbl_data = snmp_get_multi_oid($device, $oids, "-OUQnt", "MITEL-APPCMN-MIB"); $hardware = preg_replace('/;VerSw.*$/', '', (preg_replace('/^.*VerHw:/', '', $mslhw))); -$version = trim($mitelapptbl_data[$version_oid], '"'); +$version = trim($mitelapptbl_data[$version_oid], '"'); $features = trim($mitelapptbl_data[$features_oid], '"'); unset( diff --git a/includes/polling/os/netagent2.inc.php b/includes/polling/os/netagent2.inc.php index ef551db1eb..59196eb93d 100644 --- a/includes/polling/os/netagent2.inc.php +++ b/includes/polling/os/netagent2.inc.php @@ -22,7 +22,6 @@ * @copyright 2018 Mikael Sipilainen * @author Mikael Sipilainen */ - $oid = snmp_get_multi($device, ['.1.3.6.1.2.1.33.1.1.4.0', '.1.3.6.1.2.1.33.1.1.1.0'], '-OQU'); -$version = $oid[0]['.1.3.6.1.2.1.33.1.1.4.0']; +$version = $oid[0]['.1.3.6.1.2.1.33.1.1.4.0']; $hardware = $oid[0]['.1.3.6.1.2.1.33.1.1.1.0']; diff --git a/includes/polling/os/netapp.inc.php b/includes/polling/os/netapp.inc.php index 4273e2e8e4..e39c7529a8 100644 --- a/includes/polling/os/netapp.inc.php +++ b/includes/polling/os/netapp.inc.php @@ -1,6 +1,6 @@ */ - $netguardian_tmp = snmp_get_multi_oid($device, ['dpsRTUModel.0', 'dpsRTUFirmwareVersion.0'], '-OQs', 'DPS-MIB-V38'); -$version = $netguardian_tmp['dpsRTUFirmwareVersion.0']; -$hardware = $netguardian_tmp['dpsRTUModel.0']; +$version = $netguardian_tmp['dpsRTUFirmwareVersion.0']; +$hardware = $netguardian_tmp['dpsRTUModel.0']; unset($netguardian_tmp); diff --git a/includes/polling/os/nimbleos.inc.php b/includes/polling/os/nimbleos.inc.php index a9b53b4b9a..50bcc9e135 100644 --- a/includes/polling/os/nimbleos.inc.php +++ b/includes/polling/os/nimbleos.inc.php @@ -9,6 +9,6 @@ * option) any later version. Please see LICENSE.txt at the top level of * the source code distribution for details. */ - + preg_match('/version (.*)/', $device['sysDescr'], $data); $version = $data[1]; diff --git a/includes/polling/os/nitro.inc.php b/includes/polling/os/nitro.inc.php index 6de435c6b0..6d9757ac2c 100644 --- a/includes/polling/os/nitro.inc.php +++ b/includes/polling/os/nitro.inc.php @@ -14,5 +14,5 @@ if ($device['sysObjectID'] == '.1.3.6.1.4.1.23128.1000.1.1') { // McAfee ACE 9.5.0 if (preg_match('/^McAfee [A-Z]{3} ([^,]+)$/', $device['sysDescr'], $regexp_result)) { - $version = $regexp_result[1]; + $version = $regexp_result[1]; } diff --git a/includes/polling/os/nos.inc.php b/includes/polling/os/nos.inc.php index fc37abf9bd..e8abea0269 100644 --- a/includes/polling/os/nos.inc.php +++ b/includes/polling/os/nos.inc.php @@ -1,5 +1,5 @@ */ - $data = snmp_get_multi_oid($device, ['snsModel.0', 'snsVersion.0', 'snsSerialNumber.0', 'snsSystemName.0'], '-OUQs', 'STORMSHIELD-PROPERTY-MIB'); $hardware = $data['snsModel.0']; diff --git a/includes/polling/os/nxos.inc.php b/includes/polling/os/nxos.inc.php index f4c42cedd6..da1178ad5e 100644 --- a/includes/polling/os/nxos.inc.php +++ b/includes/polling/os/nxos.inc.php @@ -12,19 +12,18 @@ * the source code distribution for details. */ - $oids = ['entPhysicalSoftwareRev.22', 'entPhysicalName.149', 'entPhysicalSerialNum.10']; $data = snmp_get_multi($device, $oids, '-OQUs', 'ENTITY-MIB'); -if (isset($data[22]['entPhysicalSoftwareRev']) && !empty($data[22]['entPhysicalSoftwareRev'])) { +if (isset($data[22]['entPhysicalSoftwareRev']) && ! empty($data[22]['entPhysicalSoftwareRev'])) { $version = $data[22]['entPhysicalSoftwareRev']; } -if (isset($data[149]['entPhysicalName']) && !empty($data[149]['entPhysicalName'])) { +if (isset($data[149]['entPhysicalName']) && ! empty($data[149]['entPhysicalName'])) { $hardware = str_replace(' Chassis', '', $data[149]['entPhysicalName']); } -if (isset($data[10]) && !empty($data[10]['entPhysicalSerialNum'])) { +if (isset($data[10]) && ! empty($data[10]['entPhysicalSerialNum'])) { $serial = $data[10]['entPhysicalSerialNum']; } diff --git a/includes/polling/os/oceanstor.inc.php b/includes/polling/os/oceanstor.inc.php index 47a6ecbfa9..aa363ddf85 100644 --- a/includes/polling/os/oceanstor.inc.php +++ b/includes/polling/os/oceanstor.inc.php @@ -22,5 +22,4 @@ * @copyright 2017 Neil Lathwood * @author Neil Lathwood */ - $version = snmp_get($device, 'version.0', '-OQv', 'ISM-STORAGE-SVC-MIB'); diff --git a/includes/polling/os/onefs.inc.php b/includes/polling/os/onefs.inc.php index 1f34f315ea..6fcebfc1b6 100644 --- a/includes/polling/os/onefs.inc.php +++ b/includes/polling/os/onefs.inc.php @@ -3,5 +3,5 @@ //sysDescr Isilon OneFS HPCDATA-1 v7.0.2.8 Isilon OneFS v7.0.2.8 B_7_0_2_8_269(RELEASE) amd64 preg_match('/Isilon OneFS HPCDATA-1 (.*) Isilon OneFS (.*) (.*)\(RELEASE\) (.*)/', $device['sysDescr'], $matches); -$version = $matches[2]; +$version = $matches[2]; $hardware = $matches[3]; diff --git a/includes/polling/os/pbn-cp.inc.php b/includes/polling/os/pbn-cp.inc.php index 58e134f584..a61cca4ca3 100644 --- a/includes/polling/os/pbn-cp.inc.php +++ b/includes/polling/os/pbn-cp.inc.php @@ -1,8 +1,8 @@ */ - $data = snmp_get_multi_oid($device, ['midSerialNumber.1', 'midFirmwareVersion.1', 'midModelNumber.1', 'midDeviceName.1'], '-OQs', 'PM8ECCMIB'); $serial = trim($data['midSerialNumber.1'], '"'); $version = trim($data['midFirmwareVersion.1'], '"'); diff --git a/includes/polling/os/powerware.inc.php b/includes/polling/os/powerware.inc.php index ac66c9d75f..7f5f5acdd7 100644 --- a/includes/polling/os/powerware.inc.php +++ b/includes/polling/os/powerware.inc.php @@ -1,9 +1,9 @@ */ - $remoteye4_tmp = snmp_get_multi($device, ['upsIdentName.0', 'upsIdentAgentSoftwareVersion.0'], '-OQUs', 'UPS-MIB'); $hardware = $remoteye4_tmp[0]['upsIdentName']; -$version = str_replace('RemotEye4 ', '', $remoteye4_tmp[0]['upsIdentAgentSoftwareVersion']); +$version = str_replace('RemotEye4 ', '', $remoteye4_tmp[0]['upsIdentAgentSoftwareVersion']); diff --git a/includes/polling/os/riverbed.inc.php b/includes/polling/os/riverbed.inc.php index 374cfefcf1..f0e7f46d16 100644 --- a/includes/polling/os/riverbed.inc.php +++ b/includes/polling/os/riverbed.inc.php @@ -14,9 +14,8 @@ use LibreNMS\RRD\RrdDefinition; $hardware = trim(snmp_get($device, '.1.3.6.1.4.1.17163.1.1.1.1.0', '-OQv'), '"'); -$serial = trim(snmp_get($device, '.1.3.6.1.4.1.17163.1.1.1.2.0', '-OQv'), '"'); -$version = trim(snmp_get($device, '.1.3.6.1.4.1.17163.1.1.1.3.0', '-OQv'), '"'); - +$serial = trim(snmp_get($device, '.1.3.6.1.4.1.17163.1.1.1.2.0', '-OQv'), '"'); +$version = trim(snmp_get($device, '.1.3.6.1.4.1.17163.1.1.1.3.0', '-OQv'), '"'); /* optimisation oids * @@ -28,20 +27,20 @@ $version = trim(snmp_get($device, '.1.3.6.1.4.1.17163.1.1.1.3.0', '-OQv'), '"') * */ -$conn_array = array( +$conn_array = [ '.1.3.6.1.4.1.17163.1.1.5.2.3.0', '.1.3.6.1.4.1.17163.1.1.5.2.4.0', '.1.3.6.1.4.1.17163.1.1.5.2.5.0', '.1.3.6.1.4.1.17163.1.1.5.2.6.0', '.1.3.6.1.4.1.17163.1.1.5.2.7.0', -); +]; $connections = snmp_get_multi_oid($device, $conn_array); -$conn_half_open = $connections['.1.3.6.1.4.1.17163.1.1.5.2.3.0']; +$conn_half_open = $connections['.1.3.6.1.4.1.17163.1.1.5.2.3.0']; $conn_half_closed = $connections['.1.3.6.1.4.1.17163.1.1.5.2.4.0']; $conn_established = $connections['.1.3.6.1.4.1.17163.1.1.5.2.5.0']; -$conn_active = $connections['.1.3.6.1.4.1.17163.1.1.5.2.6.0']; -$conn_total = $connections['.1.3.6.1.4.1.17163.1.1.5.2.7.0']; +$conn_active = $connections['.1.3.6.1.4.1.17163.1.1.5.2.6.0']; +$conn_total = $connections['.1.3.6.1.4.1.17163.1.1.5.2.7.0']; if ($conn_half_open >= 0 && $conn_half_closed >= 0 && $conn_established >= 0 && $conn_active >= 0 && $conn_total >= 0) { $rrd_def = RrdDefinition::make() @@ -51,13 +50,13 @@ if ($conn_half_open >= 0 && $conn_half_closed >= 0 && $conn_established >= 0 && ->addDataset('active', 'GAUGE', 0) ->addDataset('total', 'GAUGE', 0); - $fields = array( + $fields = [ 'half_open' => $conn_half_open, 'half_closed' => $conn_half_closed, 'established' => $conn_established, 'active' => $conn_active, 'total' => $conn_total, - ); + ]; $tags = compact('rrd_def'); @@ -71,10 +70,10 @@ if ($conn_half_open >= 0 && $conn_half_closed >= 0 && $conn_established >= 0 && * miss .1.3.6.1.4.1.17163.1.1.5.4.2.0 * */ -$datastore_array = array( +$datastore_array = [ '.1.3.6.1.4.1.17163.1.1.5.4.1.0', '.1.3.6.1.4.1.17163.1.1.5.4.2.0', -); +]; $datastore = snmp_get_multi_oid($device, $datastore_array); $datastore_hits = $datastore['.1.3.6.1.4.1.17163.1.1.5.4.1.0']; @@ -85,10 +84,10 @@ if ($datastore_hits >= 0 && $datastore_miss >= 0) { ->addDataset('datastore_hits', 'GAUGE', 0) ->addDataset('datastore_miss', 'GAUGE', 0); - $fields = array( + $fields = [ 'datastore_hits' => $datastore_hits, 'datastore_miss' => $datastore_miss, - ); + ]; $tags = compact('rrd_def'); @@ -102,14 +101,14 @@ if ($datastore_hits >= 0 && $datastore_miss >= 0) { * passthrough .1.3.6.1.4.1.17163.1.1.5.2.2.0 * */ -$optimization_array = array( +$optimization_array = [ '.1.3.6.1.4.1.17163.1.1.5.2.1.0', '.1.3.6.1.4.1.17163.1.1.5.2.2.0', -); +]; $optimizations = snmp_get_multi_oid($device, $optimization_array); -$conn_optimized = $optimizations['.1.3.6.1.4.1.17163.1.1.5.2.1.0']; +$conn_optimized = $optimizations['.1.3.6.1.4.1.17163.1.1.5.2.1.0']; $conn_passthrough = $optimizations['.1.3.6.1.4.1.17163.1.1.5.2.2.0']; if ($conn_optimized >= 0 && $conn_passthrough >= 0) { @@ -117,10 +116,10 @@ if ($conn_optimized >= 0 && $conn_passthrough >= 0) { ->addDataset('conn_optimized', 'GAUGE', 0) ->addDataset('conn_passthrough', 'GAUGE', 0); - $fields = array( + $fields = [ 'conn_optimized' => $conn_optimized, 'conn_passthrough' => $conn_passthrough, - ); + ]; $tags = compact('rrd_def'); @@ -136,11 +135,11 @@ if ($conn_optimized >= 0 && $conn_passthrough >= 0) { * */ -$bandwidth_array = array( +$bandwidth_array = [ '.1.3.6.1.4.1.17163.1.1.5.3.3.1.0', '.1.3.6.1.4.1.17163.1.1.5.3.3.2.0', '.1.3.6.1.4.1.17163.1.1.5.3.3.3.0', -); +]; $bandwidth = snmp_get_multi_oid($device, $bandwidth_array); @@ -154,11 +153,11 @@ if ($bw_in >= 0 && $bw_out >= 0 && $bw_total >= 0) { ->addDataset('bw_out', 'COUNTER', 0) ->addDataset('bw_total', 'COUNTER', 0); - $fields = array( + $fields = [ 'bw_in' => $bw_in, 'bw_out' => $bw_out, 'bw_total' => $bw_total, - ); + ]; $tags = compact('rrd_def'); diff --git a/includes/polling/os/ros.inc.php b/includes/polling/os/ros.inc.php index bd9712d908..9b5d4ec042 100644 --- a/includes/polling/os/ros.inc.php +++ b/includes/polling/os/ros.inc.php @@ -22,7 +22,6 @@ * @copyright 2017 Lorenzo Zafra * @author Lorenzo Zafra */ - preg_match('~(?\'hardware\'.*?)-(?:.*)~', $device['sysDescr'], $matches); if ($matches['hardware']) { diff --git a/includes/polling/os/ruckuswireless.inc.php b/includes/polling/os/ruckuswireless.inc.php index 41ddca82de..26efcff9a3 100644 --- a/includes/polling/os/ruckuswireless.inc.php +++ b/includes/polling/os/ruckuswireless.inc.php @@ -17,10 +17,10 @@ $ruckus_data = snmp_get_multi_oid($device, ['.1.3.6.1.4.1.25053.1.2.1.1.1.1.18.0', '.1.3.6.1.4.1.25053.1.2.1.1.1.1.15.0', '.1.3.6.1.4.1.25053.1.2.1.1.1.1.12.0', '.1.3.6.1.4.1.25053.1.2.1.1.1.1.9.0', '.1.3.6.1.4.1.25053.1.2.1.1.1.1.20.0', '.1.3.6.1.4.1.25053.1.2.1.1.1.15.15.0']); -$version = $ruckus_data['.1.3.6.1.4.1.25053.1.2.1.1.1.1.18.0']; -$serial = $ruckus_data['.1.3.6.1.4.1.25053.1.2.1.1.1.1.15.0']; -$features = "Licenses: " . $ruckus_data['.1.3.6.1.4.1.25053.1.2.1.1.1.15.15.0'] . "/" . $ruckus_data['.1.3.6.1.4.1.25053.1.2.1.1.1.1.12.0']; -$hardware = $ruckus_data['.1.3.6.1.4.1.25053.1.2.1.1.1.1.9.0']; +$version = $ruckus_data['.1.3.6.1.4.1.25053.1.2.1.1.1.1.18.0']; +$serial = $ruckus_data['.1.3.6.1.4.1.25053.1.2.1.1.1.1.15.0']; +$features = "Licenses: " . $ruckus_data['.1.3.6.1.4.1.25053.1.2.1.1.1.15.15.0'] . "/" . $ruckus_data['.1.3.6.1.4.1.25053.1.2.1.1.1.1.12.0']; +$hardware = $ruckus_data['.1.3.6.1.4.1.25053.1.2.1.1.1.1.9.0']; $ruckuscountry = $ruckus_data['.1.3.6.1.4.1.25053.1.2.1.1.1.1.20.0']; if (isset($ruckuscountry) && $ruckuscountry != '') { diff --git a/includes/polling/os/samsungprinter.inc.php b/includes/polling/os/samsungprinter.inc.php index b995ac244e..a3db209d12 100644 --- a/includes/polling/os/samsungprinter.inc.php +++ b/includes/polling/os/samsungprinter.inc.php @@ -1,4 +1,5 @@ */ - $hardware = trim(snmp_get($device, '1.3.6.1.4.1.367.3.2.1.1.1.1.0', '-OQv', '', ''), '" '); $version = trim(snmp_get($device, '1.3.6.1.4.1.367.3.2.1.1.1.2.0', '-OQv', '', ''), '" '); $serial = trim(snmp_get($device, '1.3.6.1.4.1.367.3.2.1.2.1.4.0', '-OQv', '', ''), '" '); diff --git a/includes/polling/os/serveriron.inc.php b/includes/polling/os/serveriron.inc.php index cad56f98e5..f3db71125c 100644 --- a/includes/polling/os/serveriron.inc.php +++ b/includes/polling/os/serveriron.inc.php @@ -1,5 +1,5 @@ RrdDefinition::make()->addDataset('requests', 'GAUGE', 0), - ); - $fields = array( + ]; + $fields = [ 'requests' => $sgos[0]['sgProxyHttpClientRequestRate'], - ); + ]; data_update($device, 'sgos_average_requests', $tags, $fields); @@ -24,12 +24,12 @@ if (is_numeric($sgos[0]['sgProxyHttpClientRequestRate'])) { } if (is_numeric($sgos[0]['sgProxyHttpClientConnections'])) { - $tags = array( + $tags = [ 'rrd_def' => RrdDefinition::make()->addDataset('client_conn', 'GAUGE', 0), - ); - $fields = array( + ]; + $fields = [ 'client_conn' => $sgos[0]['sgProxyHttpClientConnections'], - ); + ]; data_update($device, 'sgos_client_connections', $tags, $fields); @@ -38,12 +38,12 @@ if (is_numeric($sgos[0]['sgProxyHttpClientConnections'])) { } if (is_numeric($sgos[0]['sgProxyHttpServerConnections'])) { - $tags = array( + $tags = [ 'rrd_def' => RrdDefinition::make()->addDataset('server_conn', 'GAUGE', 0), - ); - $fields = array( + ]; + $fields = [ 'server_conn' => $sgos[0]['sgProxyHttpServerConnections'], - ); + ]; data_update($device, 'sgos_server_connections', $tags, $fields); @@ -52,12 +52,12 @@ if (is_numeric($sgos[0]['sgProxyHttpServerConnections'])) { } if (is_numeric($sgos[0]['sgProxyHttpClientConnectionsActive'])) { - $tags = array( + $tags = [ 'rrd_def' => RrdDefinition::make()->addDataset('client_conn_active', 'GAUGE', 0), - ); - $fields = array( + ]; + $fields = [ 'client_conn_active' => $sgos[0]['sgProxyHttpClientConnectionsActive'], - ); + ]; data_update($device, 'sgos_client_connections_active', $tags, $fields); @@ -66,12 +66,12 @@ if (is_numeric($sgos[0]['sgProxyHttpClientConnectionsActive'])) { } if (is_numeric($sgos[0]['sgProxyHttpServerConnectionsActive'])) { - $tags = array( + $tags = [ 'rrd_def' => RrdDefinition::make()->addDataset('server_conn_active', 'GAUGE', 0), - ); - $fields = array( + ]; + $fields = [ 'server_conn_active' => $sgos[0]['sgProxyHttpServerConnectionsActive'], - ); + ]; data_update($device, 'sgos_server_connections_active', $tags, $fields); @@ -80,12 +80,12 @@ if (is_numeric($sgos[0]['sgProxyHttpServerConnectionsActive'])) { } if (is_numeric($sgos[0]['sgProxyHttpClientConnectionsIdle'])) { - $tags = array( + $tags = [ 'rrd_def' => RrdDefinition::make()->addDataset('client_idle', 'GAUGE', 0), - ); - $fields = array( + ]; + $fields = [ 'client_idle' => $sgos[0]['sgProxyHttpClientConnectionsIdle'], - ); + ]; data_update($device, 'sgos_client_connections_idle', $tags, $fields); @@ -94,12 +94,12 @@ if (is_numeric($sgos[0]['sgProxyHttpClientConnectionsIdle'])) { } if (is_numeric($sgos[0]['sgProxyHttpServerConnectionsIdle'])) { - $tags = array( + $tags = [ 'rrd_def' => RrdDefinition::make()->addDataset('server_idle', 'GAUGE', 0), - ); - $fields = array( + ]; + $fields = [ 'server_idle' => $sgos[0]['sgProxyHttpServerConnectionsIdle'], - ); + ]; data_update($device, 'sgos_server_connections_idle', $tags, $fields); diff --git a/includes/polling/os/sinetica.inc.php b/includes/polling/os/sinetica.inc.php index b6b7e93a66..f2999a4578 100644 --- a/includes/polling/os/sinetica.inc.php +++ b/includes/polling/os/sinetica.inc.php @@ -25,7 +25,7 @@ // Sinetica UPSController. Versions: App. 6.04.03, OS 6.3, Btldr 1.06.09, H/w ZBBNC2 Rev 1.01.06 -list($os_temp, $os_ver, $btldr, $hardware_temp) = explode(', ', $device['sysDescr']); +[$os_temp, $os_ver, $btldr, $hardware_temp] = explode(', ', $device['sysDescr']); -list($ignore, $version) = explode('App. ', $os_temp); +[$ignore, $version] = explode('App. ', $os_temp); $hardware = preg_replace('/H\/w /', '', $hardware_temp); diff --git a/includes/polling/os/smartos.inc.php b/includes/polling/os/smartos.inc.php index 7b09c39c8b..a99d566e96 100644 --- a/includes/polling/os/smartos.inc.php +++ b/includes/polling/os/smartos.inc.php @@ -25,7 +25,7 @@ //SmartOptics, M-Series M-1601-D1000C1 R2A, SmartOS v2.4.14 (Compiled on Thu Jun 2 14:21:33 CEST 2016) -list(, $hardware, $version) = explode(',', $device['sysDescr']); +[, $hardware, $version] = explode(',', $device['sysDescr']); $hardware = str_replace('M-Series ', '', $hardware); -list(,,$version,) = explode(' ', $version); +[,,$version,] = explode(' ', $version); diff --git a/includes/polling/os/snom.inc.php b/includes/polling/os/snom.inc.php index 482c3c9c10..074ada46df 100644 --- a/includes/polling/os/snom.inc.php +++ b/includes/polling/os/snom.inc.php @@ -5,17 +5,17 @@ use LibreNMS\RRD\RrdDefinition; echo "Polling SNOM device...\n"; // Get SNOM specific version string from silly SNOM location. Silly SNOM! -$device['sysDescr'] = snmp_get($device, '1.3.6.1.2.1.7526.2.4', '-Oqv'); -$device['sysDescr'] = str_replace('-', ' ', $device['sysDescr']); -$device['sysDescr'] = str_replace('"', '', $device['sysDescr']); -list($hardware, $features, $version) = explode(' ', $device['sysDescr']); +$device['sysDescr'] = snmp_get($device, '1.3.6.1.2.1.7526.2.4', '-Oqv'); +$device['sysDescr'] = str_replace('-', ' ', $device['sysDescr']); +$device['sysDescr'] = str_replace('"', '', $device['sysDescr']); +[$hardware, $features, $version] = explode(' ', $device['sysDescr']); // Get data for calls and network from SNOM specific SNMP OIDs. -$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'); +$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'); $snmpdatab = snmp_get($device, ['1.3.6.1.2.1.7526.2.5', '1.3.6.1.2.1.7526.2.6'], '-Oqv'); -list($rxbytes, $rxpkts, $txbytes, $txpkts) = explode("\n", $snmpdata); -list($calls, $registrations) = explode("\n", $snmpdatab); +[$rxbytes, $rxpkts, $txbytes, $txpkts] = explode("\n", $snmpdata); +[$calls, $registrations] = explode("\n", $snmpdatab); $txbytes = (0 - $txbytes * 8); $rxbytes = (0 - $rxbytes * 8); echo "$rxbytes, $rxpkts, $txbytes, $txpkts, $calls, $registrations"; @@ -29,14 +29,14 @@ $rrd_def = RrdDefinition::make() ->addDataset('CALLS', 'COUNTER', null, 10000000000) ->addDataset('REGISTRATIONS', 'COUNTER', null, 10000000000); -$fields = array( +$fields = [ 'INOCTETS' => $rxbytes, 'OUTOCTETS' => $txbytes, 'INPKTS' => $rxpkts, 'OUTPKTS' => $rxbytes, 'CALLS' => $calls, 'REGISTRATIONS' => $registrations, -); +]; $tags = compact('rrd_name', 'rrd_def'); data_update($device, 'snom-data', $tags, $fields); diff --git a/includes/polling/os/svos.inc.php b/includes/polling/os/svos.inc.php index 2ff8cff3b9..fe789d249d 100644 --- a/includes/polling/os/svos.inc.php +++ b/includes/polling/os/svos.inc.php @@ -1,6 +1,6 @@ $oid) { diff --git a/includes/polling/os/symbol.inc.php b/includes/polling/os/symbol.inc.php index 6eb2338be2..ed491efdd6 100644 --- a/includes/polling/os/symbol.inc.php +++ b/includes/polling/os/symbol.inc.php @@ -1,8 +1,8 @@ */ - -list($ignore, $version) = explode(' ', trim(snmp_get($device, '.1.3.6.1.4.1.2021.7890.1.101.1', '-Osqnv'), '"')); +[$ignore, $version] = explode(' ', trim(snmp_get($device, '.1.3.6.1.4.1.2021.7890.1.101.1', '-Osqnv'), '"')); unset($ignore); diff --git a/includes/polling/os/tpdin.inc.php b/includes/polling/os/tpdin.inc.php index 3294ae523b..55b962d014 100644 --- a/includes/polling/os/tpdin.inc.php +++ b/includes/polling/os/tpdin.inc.php @@ -22,10 +22,9 @@ * @copyright 2017 Neil Lathwood * @author Neil Lathwood */ - $tycon_data = snmp_get_multi_oid($device, ['name.0', 'version.0'], '-OUQs', 'TPDIN2-MIB'); $hardware = $tycon_data['name.0']; -$version = $tycon_data['version.0']; +$version = $tycon_data['version.0']; unset($tycon_data); diff --git a/includes/polling/os/tranzeo.inc.php b/includes/polling/os/tranzeo.inc.php index 8728fb30f1..d3a8e79fb8 100644 --- a/includes/polling/os/tranzeo.inc.php +++ b/includes/polling/os/tranzeo.inc.php @@ -6,8 +6,8 @@ // Tranzeo TR6Rt, OS 6.8.0(1024), FW TR6-3.6.0Rt, 5.xGHz, 19dBi int. antenna // Tranzeo TR6CPQ, OS 6.3.34(1019), FW TR6-2.0.12CPQ, 2.4GHz, 15dBi int. antenna // Tranzeo TR900Rt, OS 6.8.0(1024), FW TR900-3.3.3Rt, 900MHz, 17dBi ext. antenna -list($hardware, $version, $features, $hardware_antenna) = explode(', ', $device['sysDescr']); +[$hardware, $version, $features, $hardware_antenna] = explode(', ', $device['sysDescr']); -list(,$version) = explode(' ', $version); -list($version) = explode('(', $version); -list(,$features) = explode(' ', $features); +[,$version] = explode(' ', $version); +[$version] = explode('(', $version); +[,$features] = explode(' ', $features); diff --git a/includes/polling/os/unifi.inc.php b/includes/polling/os/unifi.inc.php index 78414a551e..34caa19dc6 100644 --- a/includes/polling/os/unifi.inc.php +++ b/includes/polling/os/unifi.inc.php @@ -1,4 +1,5 @@ \S+\s*){1,4}/', $hardware_snmp, $hard); $hardware = rtrim($hard[0]); } else { - $version = preg_replace('/^VMware /', '', $data[0]['vmwProdName']).' '.$data[0]['vmwProdVersion']; - $features = 'build-'.$data[0]['vmwProdBuild']; + $version = preg_replace('/^VMware /', '', $data[0]['vmwProdName']) . ' ' . $data[0]['vmwProdVersion']; + $features = 'build-' . $data[0]['vmwProdBuild']; $hardware = $hardware_snmp; } -$serial = snmp_get($device, 'entPhysicalSerialNum.1', '-OsvQU', 'ENTITY-MIB'); +$serial = snmp_get($device, 'entPhysicalSerialNum.1', '-OsvQU', 'ENTITY-MIB'); -# Clean up Generic hardware descriptions +// Clean up Generic hardware descriptions $hardware = rewrite_generic_hardware($hardware); /* @@ -45,8 +45,8 @@ echo 'VMware VM: '; * Get a list of all the known Virtual Machines for this host. */ -$db_info_list = dbFetchRows('SELECT id, vmwVmVMID, vmwVmDisplayName, vmwVmGuestOS, vmwVmMemSize, vmwVmCpus, vmwVmState FROM vminfo WHERE device_id = ?', array($device['device_id'])); -$current_vminfo = snmpwalk_cache_multi_oid($device, 'vmwVmTable', array(), '+VMWARE-ROOT-MIB:VMWARE-VMINFO-MIB', 'vmware'); +$db_info_list = dbFetchRows('SELECT id, vmwVmVMID, vmwVmDisplayName, vmwVmGuestOS, vmwVmMemSize, vmwVmCpus, vmwVmState FROM vminfo WHERE device_id = ?', [$device['device_id']]); +$current_vminfo = snmpwalk_cache_multi_oid($device, 'vmwVmTable', [], '+VMWARE-ROOT-MIB:VMWARE-VMINFO-MIB', 'vmware'); foreach ($db_info_list as $db_info) { /* @@ -60,13 +60,13 @@ foreach ($db_info_list as $db_info) { * VMWARE-VMINFO-MIB::vmwVmCpus.224 = INTEGER: 2 */ - $vm_info = array(); + $vm_info = []; $vm_info['vmwVmDisplayName'] = $current_vminfo[$db_info['vmwVmVMID']]['vmwVmDisplayName']; - $vm_info['vmwVmGuestOS'] = $current_vminfo[$db_info['vmwVmVMID']]['vmwVmGuestOS']; - $vm_info['vmwVmMemSize'] = $current_vminfo[$db_info['vmwVmVMID']]['vmwVmMemSize']; - $vm_info['vmwVmState'] = $current_vminfo[$db_info['vmwVmVMID']]['vmwVmState']; - $vm_info['vmwVmCpus'] = $current_vminfo[$db_info['vmwVmVMID']]['vmwVmCpus']; + $vm_info['vmwVmGuestOS'] = $current_vminfo[$db_info['vmwVmVMID']]['vmwVmGuestOS']; + $vm_info['vmwVmMemSize'] = $current_vminfo[$db_info['vmwVmVMID']]['vmwVmMemSize']; + $vm_info['vmwVmState'] = $current_vminfo[$db_info['vmwVmVMID']]['vmwVmState']; + $vm_info['vmwVmCpus'] = $current_vminfo[$db_info['vmwVmVMID']]['vmwVmCpus']; /* * VMware does not return an INTEGER but a STRING of the vmwVmMemSize. This bug @@ -96,7 +96,7 @@ foreach ($db_info_list as $db_info) { if ($vm_info[$property] != $db_info[$property]) { // FIXME - this should loop building a query and then run the query after the loop (bad geert!) - dbUpdate(array($property => $vm_info[$property]), 'vminfo', '`id` = ?', array($db_info['id'])); + dbUpdate([$property => $vm_info[$property]], 'vminfo', '`id` = ?', [$db_info['id']]); if ($db_info['vmwVmDisplayName'] != null) { log_event($db_info['vmwVmDisplayName'] . ' (' . preg_replace('/^vmwVm/', '', $property) . ') -> ' . $vm_info[$property], $device, null, 3); } diff --git a/includes/polling/os/vyatta.inc.php b/includes/polling/os/vyatta.inc.php index 6d6e25efb9..80e7e43b5f 100644 --- a/includes/polling/os/vyatta.inc.php +++ b/includes/polling/os/vyatta.inc.php @@ -1,3 +1,3 @@ addDataset('connections', 'GAUGE', 0); - $fields = array( - 'connections' => $connections - ); + $fields = [ + 'connections' => $connections, + ]; $tags = compact('rrd_def'); data_update($device, 'waas_cwotfostatsactiveoptconn', $tags, $fields); diff --git a/includes/polling/os/webpower.inc.php b/includes/polling/os/webpower.inc.php index b96cd057bf..ddf5278130 100644 --- a/includes/polling/os/webpower.inc.php +++ b/includes/polling/os/webpower.inc.php @@ -13,5 +13,5 @@ $data = str_replace('"', '', snmp_get($device, '1.3.6.1.2.1.33.1.1.4.0', '-Ovq')); preg_match_all('/^WebPower Pro II Card|v[0-9]+.[0-9]+|(SN [0-9]+)/', $data, $matches); $hardware = $matches[0][0]; -$version = $matches[0][1]; -$serial = $matches[0][2]; +$version = $matches[0][1]; +$serial = $matches[0][2]; diff --git a/includes/polling/os/websensor.inc.php b/includes/polling/os/websensor.inc.php index 4d351f52ae..c2b55c1bdd 100644 --- a/includes/polling/os/websensor.inc.php +++ b/includes/polling/os/websensor.inc.php @@ -22,5 +22,4 @@ * @copyright 2017 Neil Lathwood * @author Neil Lathwood */ - $serial = snmp_get($device, 'serialNumber.0', '-OevTQUs', 'T3610-MIB'); diff --git a/includes/polling/os/windows.inc.php b/includes/polling/os/windows.inc.php index bc68c46da1..590376e220 100644 --- a/includes/polling/os/windows.inc.php +++ b/includes/polling/os/windows.inc.php @@ -13,7 +13,7 @@ use Illuminate\Support\Str; if (Str::contains($device['sysDescr'], 'AMD64')) { $hardware = 'AMD x64'; -} elseif (Str::contains($device['sysDescr'], array('EM64', 'Intel64'))) { +} elseif (Str::contains($device['sysDescr'], ['EM64', 'Intel64'])) { $hardware = 'Intel x64'; } elseif (Str::contains($device['sysDescr'], 'x86')) { $hardware = 'Generic x86'; @@ -117,14 +117,14 @@ if (Str::contains($device['sysDescr'], 'Multiprocessor')) { // Detect Dell hardware via OpenManage SNMP $hw = snmp_get($device, '.1.3.6.1.4.1.674.10892.1.300.10.1.9.1', '-Oqv', 'MIB-Dell-10892'); $hw = trim(str_replace('"', '', $hw)); -if (!empty($hw)) { +if (! empty($hw)) { $hardware = 'Dell ' . $hw; $serial = snmp_get($device, '.1.3.6.1.4.1.674.10892.1.300.10.1.11.1', '-Oqv', 'MIB-Dell-10892'); $serial = trim(str_replace('"', '', $serial)); } else { $hw = trim(snmp_get($device, 'cpqSiProductName.0', '-Oqv', 'CPQSINFO-MIB', 'hp'), '"'); - if (!empty($hw)) { + if (! empty($hw)) { $hardware = $hw; } } diff --git a/includes/polling/os/wipipe.inc.php b/includes/polling/os/wipipe.inc.php index 5d320a0d0b..1475ef5663 100644 --- a/includes/polling/os/wipipe.inc.php +++ b/includes/polling/os/wipipe.inc.php @@ -15,4 +15,4 @@ // Rip hardware and firmware version from sysDescr string -- example: Cradlepoint CBA850, Firmware Version 6.2.0.dd92f49 preg_match('/(.*) ([\w\d]+), (.*) ([\w\d\.]+)/', $device['sysDescr'], $wipipe_data); $hardware = $wipipe_data[2]; -$version = $wipipe_data[4]; +$version = $wipipe_data[4]; diff --git a/includes/polling/os/zebra.inc.php b/includes/polling/os/zebra.inc.php index e945e57928..8c7e22ee38 100644 --- a/includes/polling/os/zebra.inc.php +++ b/includes/polling/os/zebra.inc.php @@ -29,11 +29,11 @@ use Illuminate\Support\Str; if (Str::startsWith($device['sysObjectID'], '.1.3.6.1.4.1.683')) { - $oids = array( + $oids = [ 'hardware' => '.1.3.6.1.4.1.683.1.4.0', 'serial' => '.1.3.6.1.4.1.683.1.5.0', 'version' => '.1.3.6.1.4.1.683.1.9.0', - ); + ]; $os_data = snmp_get_multi_oid($device, $oids); foreach ($oids as $var => $oid) { $$var = trim($os_data[$oid], '"'); diff --git a/includes/polling/os/zxdsl.inc.php b/includes/polling/os/zxdsl.inc.php index 01978b9595..e1ce0900a7 100644 --- a/includes/polling/os/zxdsl.inc.php +++ b/includes/polling/os/zxdsl.inc.php @@ -13,10 +13,10 @@ if (strstr($device['sysObjectID'], '.1.3.6.1.4.1.3902.')) { $sysObjectIdSplit = explode('.', $sysObjectId); if (count($sysObjectIdSplit) >= 1) { - $hardware = "ZXDSL ".$sysObjectIdSplit[0]; + $hardware = "ZXDSL " . $sysObjectIdSplit[0]; if (count($sysObjectIdSplit) >= 2) { for ($i = 1; $i < count($sysObjectIdSplit); $i++) { - $hardware .= chr(64+$sysObjectIdSplit[$i]); + $hardware .= chr(64 + $sysObjectIdSplit[$i]); } } } diff --git a/includes/polling/os/zxr10.inc.php b/includes/polling/os/zxr10.inc.php index c9e9718f58..3ce745b775 100644 --- a/includes/polling/os/zxr10.inc.php +++ b/includes/polling/os/zxr10.inc.php @@ -1,6 +1,6 @@ null)); + $vrfs_lite_cisco = [['context_name' => null]]; } foreach ($vrfs_lite_cisco as $vrf_lite) { @@ -22,7 +22,7 @@ foreach ($vrfs_lite_cisco as $vrf_lite) { echo ' Processes: '; // Pull data from device - $ospf_instances_poll = snmpwalk_cache_oid($device, 'OSPF-MIB::ospfGeneralGroup', array(), 'OSPF-MIB'); + $ospf_instances_poll = snmpwalk_cache_oid($device, 'OSPF-MIB::ospfGeneralGroup', [], 'OSPF-MIB'); d_echo($ospf_instances_poll); $ospf_instances = collect(); @@ -52,7 +52,7 @@ foreach ($vrfs_lite_cisco as $vrf_lite) { echo ' Areas: '; // Pull data from device - $ospf_areas_poll = snmpwalk_cache_oid($device, 'OSPF-MIB::ospfAreaEntry', array(), 'OSPF-MIB'); + $ospf_areas_poll = snmpwalk_cache_oid($device, 'OSPF-MIB::ospfAreaEntry', [], 'OSPF-MIB'); d_echo($ospf_areas_poll); $ospf_areas = collect(); @@ -76,17 +76,17 @@ foreach ($vrfs_lite_cisco as $vrf_lite) { echo ' Ports: '; // Pull data from device - $ospf_ports_poll = snmpwalk_cache_oid($device, 'OSPF-MIB::ospfIfEntry', array(), 'OSPF-MIB'); + $ospf_ports_poll = snmpwalk_cache_oid($device, 'OSPF-MIB::ospfIfEntry', [], 'OSPF-MIB'); d_echo($ospf_ports_poll); $ospf_ports = collect(); foreach ($ospf_ports_poll as $ospf_port_id => $ospf_port) { // find port_id if ($ospf_port['ospfAddressLessIf']) { - $ospf_port['port_id'] = (int)$device_model->ports()->where('ifIndex', $ospf_port['ospfAddressLessIf'])->value('port_id'); + $ospf_port['port_id'] = (int) $device_model->ports()->where('ifIndex', $ospf_port['ospfAddressLessIf'])->value('port_id'); } else { // FIXME force same device ? - $ospf_port['port_id'] = (int)Ipv4Address::query() + $ospf_port['port_id'] = (int) Ipv4Address::query() ->where('ipv4_address', $ospf_port['ospfIfIpAddress']) ->where('context_name', $device['context_name']) ->value('port_id'); @@ -111,7 +111,7 @@ foreach ($vrfs_lite_cisco as $vrf_lite) { echo ' Neighbours: '; // Pull data from device - $ospf_nbrs_poll = snmpwalk_cache_oid($device, 'OSPF-MIB::ospfNbrEntry', array(), 'OSPF-MIB'); + $ospf_nbrs_poll = snmpwalk_cache_oid($device, 'OSPF-MIB::ospfNbrEntry', [], 'OSPF-MIB'); d_echo($ospf_nbrs_poll); $ospf_neighbours = collect(); diff --git a/includes/polling/ports.inc.php b/includes/polling/ports.inc.php index 3906eaa1ce..f3a5142149 100644 --- a/includes/polling/ports.inc.php +++ b/includes/polling/ports.inc.php @@ -4,7 +4,7 @@ use LibreNMS\Config; use LibreNMS\RRD\RrdDefinition; -$data_oids = array( +$data_oids = [ 'ifName', 'ifDescr', 'ifAlias', @@ -20,9 +20,9 @@ $data_oids = array( 'ifDuplex', 'ifTrunk', 'ifVlan', -); +]; -$stat_oids = array( +$stat_oids = [ 'ifInErrors', 'ifOutErrors', 'ifInUcastPkts', @@ -44,18 +44,18 @@ $stat_oids = array( 'ifOutBroadcastPkts', 'ifInMulticastPkts', 'ifOutMulticastPkts', -); +]; -$stat_oids_db = array( +$stat_oids_db = [ 'ifInOctets', 'ifOutOctets', 'ifInErrors', 'ifOutErrors', 'ifInUcastPkts', 'ifOutUcastPkts', -); +]; -$stat_oids_db_extended = array( +$stat_oids_db_extended = [ 'ifInNUcastPkts', 'ifOutNUcastPkts', 'ifInDiscards', @@ -65,9 +65,9 @@ $stat_oids_db_extended = array( 'ifOutBroadcastPkts', 'ifInMulticastPkts', 'ifOutMulticastPkts', -); +]; -$cisco_oids = array( +$cisco_oids = [ 'locIfHardType', 'locIfInRunts', 'locIfInGiants', @@ -79,12 +79,12 @@ $cisco_oids = array( 'locIfCollisions', 'locIfInputQueueDrops', 'locIfOutputQueueDrops', -); +]; /* * CISCO-IF-EXTENSION MIB */ -$cisco_if_extension_oids = array( +$cisco_if_extension_oids = [ 'cieIfInRuntsErrs', 'cieIfInGiantsErrs', 'cieIfInFramingErrs', @@ -92,14 +92,14 @@ $cisco_if_extension_oids = array( 'cieIfInIgnored', 'cieIfInAbortErrs', 'cieIfInputQueueDrops', - 'cieIfOutputQueueDrops' -); + 'cieIfOutputQueueDrops', +]; -$pagp_oids = array( +$pagp_oids = [ 'pagpOperationMode', -); +]; -$pagp_extended_oids = array( +$pagp_extended_oids = [ 'pagpPortState', 'pagpPartnerDeviceId', 'pagpPartnerLearnMethod', @@ -109,9 +109,9 @@ $pagp_extended_oids = array( 'pagpEthcOperationMode', 'pagpDeviceId', 'pagpGroupIfIndex', -); +]; -$ifmib_oids = array( +$ifmib_oids = [ 'ifDescr', 'ifAdminStatus', 'ifOperStatus', @@ -123,18 +123,18 @@ $ifmib_oids = array( 'ifOutErrors', 'ifInDiscards', 'ifOutDiscards', -); +]; -$table_base_oids = array( +$table_base_oids = [ 'ifName', 'ifAlias', 'ifDescr', 'ifHighSpeed', 'ifOperStatus', 'ifAdminStatus', -); +]; -$hc_mappings = array( +$hc_mappings = [ 'ifHCInOctets' => 'ifInOctets', 'ifHCOutOctets' => 'ifOutOctets', 'ifHCInUcastPkts' => 'ifInUcastPkts', @@ -143,9 +143,9 @@ $hc_mappings = array( 'ifHCOutBroadcastPkts' => 'ifOutBroadcastPkts', 'ifHCInMulticastPkts' => 'ifInMulticastPkts', 'ifHCOutMulticastPkts' => 'ifOutMulticastPkts', -); +]; -$hc_oids = array( +$hc_oids = [ 'ifInMulticastPkts', 'ifInBroadcastPkts', 'ifOutMulticastPkts', @@ -160,18 +160,18 @@ $hc_oids = array( 'ifHCOutBroadcastPkts', 'ifPromiscuousMode', 'ifConnectorPresent', -); +]; -$nonhc_oids = array( +$nonhc_oids = [ 'ifSpeed', 'ifInOctets', 'ifInUcastPkts', 'ifInUnknownProtos', 'ifOutOctets', 'ifOutUcastPkts', -); +]; -$shared_oids = array( +$shared_oids = [ 'ifInErrors', 'ifOutErrors', 'ifInNUcastPkts', @@ -182,7 +182,7 @@ $shared_oids = array( 'ifLastChange', 'ifType', 'ifMtu', -); +]; $dot3_oids = [ 'dot3StatsIndex', @@ -197,7 +197,7 @@ $ports = $ports_mapped['ports']; // // Rename any old RRD files still named after the previous ifIndex based naming schema. foreach ($ports_mapped['maps']['ifIndex'] as $ifIndex => $port_id) { - foreach (array ('', '-adsl', '-dot3') as $suffix) { + foreach (['', '-adsl', '-dot3'] as $suffix) { $old_rrd_name = "port-$ifIndex$suffix"; $new_rrd_name = getPortRrdName($port_id, ltrim($suffix, '-')); @@ -217,12 +217,13 @@ if ($device['os'] === 'f5' && (version_compare($device['version'], '11.2.0', '>= // remove the deleted and disabled ports and mark them skipped $polled_ports = array_filter($ports, function ($port) use ($ports) { $ports[$port['ifIndex']]['skipped'] = true; - return !($port['deleted'] || $port['disabled']); + + return ! ($port['deleted'] || $port['disabled']); }); // only try to guess if we should walk base oids if selected_ports is set only globally $walk_base = false; - if (!Config::has("os.{$device['os']}.polling.selected_ports") && !array_key_exists('selected_ports', $device['attribs'])) { + if (! Config::has("os.{$device['os']}.polling.selected_ports") && ! array_key_exists('selected_ports', $device['attribs'])) { // if less than 5 ports or less than 10% of the total ports are skipped, walk the base oids instead of get $polled_port_count = count($polled_ports); $total_port_count = count($ports); @@ -241,7 +242,7 @@ if ($device['os'] === 'f5' && (version_compare($device['version'], '11.2.0', '>= $port_stats[$ifIndex]['ifType'] = $port['ifType']; // we keep it as it is not included in $base_oids if (is_port_valid($port, $device)) { - if (!$walk_base) { + if (! $walk_base) { // we didn't walk,so snmpget the base oids $base_oids = implode(".$ifIndex ", $table_base_oids) . ".$ifIndex"; $port_stats = snmp_get_multi($device, $base_oids, '-OQUst', 'IF-MIB', null, $port_stats); @@ -266,7 +267,7 @@ if ($device['os'] === 'f5' && (version_compare($device['version'], '11.2.0', '>= } else { $full_oids = array_merge($nonhc_oids, $shared_oids); } - $oids = implode(".$ifIndex ", $full_oids) . ".$ifIndex"; + $oids = implode(".$ifIndex ", $full_oids) . ".$ifIndex"; $extra_oids = implode(".$ifIndex ", $dot3_oids) . ".$ifIndex"; unset($full_oids); @@ -283,7 +284,7 @@ if ($device['os'] === 'f5' && (version_compare($device['version'], '11.2.0', '>= echo 'Full ports polling '; // For devices that are on the bad_ifXentry list, try fetching ifAlias to have nice interface descriptions. - if (!in_array(strtolower($device['hardware']), array_map('strtolower', (array)Config::getOsSetting($device['os'], 'bad_ifXEntry', [])))) { + if (! in_array(strtolower($device['hardware']), array_map('strtolower', (array) Config::getOsSetting($device['os'], 'bad_ifXEntry', [])))) { $port_stats = snmpwalk_cache_oid($device, 'ifXEntry', $port_stats, 'IF-MIB'); } else { $port_stats = snmpwalk_cache_oid($device, 'ifAlias', $port_stats, 'IF-MIB', null, '-OQUst'); @@ -291,8 +292,8 @@ if ($device['os'] === 'f5' && (version_compare($device['version'], '11.2.0', '>= } $hc_test = array_slice($port_stats, 0, 1); // If the device doesn't have ifXentry data, fetch ifEntry instead. - if ((!isset($hc_test[0]['ifHCInOctets']) && !is_numeric($hc_test[0]['ifHCInOctets'])) || - ((!isset($hc_test[0]['ifHighSpeed']) && !is_numeric($hc_test[0]['ifHighSpeed'])))) { + if ((! isset($hc_test[0]['ifHCInOctets']) && ! is_numeric($hc_test[0]['ifHCInOctets'])) || + ((! isset($hc_test[0]['ifHighSpeed']) && ! is_numeric($hc_test[0]['ifHighSpeed'])))) { $port_stats = snmpwalk_cache_oid($device, 'ifEntry', $port_stats, 'IF-MIB', null, '-OQUst'); } else { // For devices with ifXentry data, only specific ifEntry keys are fetched to reduce SNMP load @@ -334,7 +335,7 @@ if (Config::get('enable_ports_poe')) { $port_stats_poe = snmpwalk_cache_oid($device, 'cpeExtPsePortEntry', [], 'CISCO-POWER-ETHERNET-EXT-MIB'); $port_ent_to_if = snmpwalk_cache_oid($device, 'portIfIndex', [], 'CISCO-STACK-MIB'); - if (!$port_ent_to_if) { + if (! $port_ent_to_if) { $ifTable_ifDescr = snmpwalk_cache_oid($device, 'ifDescr', [], 'IF-MIB'); $port_ent_to_if = []; foreach ($ifTable_ifDescr as $if_index => $if_descr) { @@ -353,31 +354,31 @@ if (Config::get('enable_ports_poe')) { //We replace the ENTITY EntIndex by the IfIndex using the portIfIndex table (stored in $port_ent_to_if). //Result is merged into $port_stats if ($port_ent_to_if[$p_index] && $port_ent_to_if[$p_index]['portIfIndex'] && $port_stats[$port_ent_to_if[$p_index]['portIfIndex']]) { - $port_stats[$port_ent_to_if[$p_index]['portIfIndex']]=$port_stats[$port_ent_to_if[$p_index]['portIfIndex']]+$p_stats; + $port_stats[$port_ent_to_if[$p_index]['portIfIndex']] = $port_stats[$port_ent_to_if[$p_index]['portIfIndex']] + $p_stats; } } } elseif ($device['os'] == 'vrp') { - echo 'HwPoePortEntry' ; + echo 'HwPoePortEntry'; - $vrp_poe_oids = array( + $vrp_poe_oids = [ 'hwPoePortReferencePower', 'hwPoePortMaximumPower', 'hwPoePortConsumingPower', 'hwPoePortPeakPower', 'hwPoePortEnable', - ); + ]; foreach ($vrp_poe_oids as $oid) { $port_stats = snmpwalk_cache_oid($device, $oid, $port_stats, 'HUAWEI-POE-MIB'); } } elseif ($device['os'] == 'linksys-ss') { - echo 'rlPethPsePort' ; + echo 'rlPethPsePort'; - $linksys_poe_oids = array( + $linksys_poe_oids = [ 'pethPsePortAdminEnable', 'rlPethPsePortPowerLimit', 'rlPethPsePortOutputPower', - ); + ]; foreach ($linksys_poe_oids as $oid) { $port_stats_temp = snmpwalk_cache_oid($device, $oid, $port_stats_temp, 'LINKSYS-POE-MIB:POWER-ETHERNET-MIB'); @@ -392,7 +393,7 @@ if (Config::get('enable_ports_poe')) { if ($device['os_group'] == 'cisco' && $device['os'] != 'asa') { foreach ($pagp_oids as $oid) { - $pagp_port_stats = snmpwalk_cache_oid($device, $oid, array(), 'CISCO-PAGP-MIB'); + $pagp_port_stats = snmpwalk_cache_oid($device, $oid, [], 'CISCO-PAGP-MIB'); } if (count($pagp_port_stats) > 0) { foreach ($pagp_port_stats as $p_index => $p_stats) { @@ -450,68 +451,67 @@ foreach ($port_stats as $ifIndex => $port) { d_echo(' valid'); // Port newly discovered? - if (!$port_id || empty($ports[$port_id])) { + if (! $port_id || empty($ports[$port_id])) { /** - * When using the ifName or ifDescr as means to map discovered ports to - * known ports in the DB (think of port association mode) it's possible - * that we're facing the problem that the ifName or ifDescr polled from - * the device is unset or an empty string (like when querying some ubnt - * devices...). If this happends we have no way to map this port to any - * port found in the database. As reported this situation may occur for - * the time of one poll and might resolve automagically before the next - * poller run happens. Without this special case this would lead to new - * ports added to the database each time this situation occurs. To give - * the user the choice between »a lot of new ports« and »some poll runs - * are missed but ports stay stable« the 'ignore_unmapable_port' option - * has been added to configure this behaviour. To skip the port in this - * loop is sufficient as the next loop is looping only over ports found - * in the database and "maps back". As we did not add a new port to the - * DB here, there's no port to be mapped to. - * - * I'm using the in_array() check here, as I'm not sure if an "ifIndex" - * can be legally set to 0, which would yield True when checking if the - * value is empty(). - */ + * When using the ifName or ifDescr as means to map discovered ports to + * known ports in the DB (think of port association mode) it's possible + * that we're facing the problem that the ifName or ifDescr polled from + * the device is unset or an empty string (like when querying some ubnt + * devices...). If this happends we have no way to map this port to any + * port found in the database. As reported this situation may occur for + * the time of one poll and might resolve automagically before the next + * poller run happens. Without this special case this would lead to new + * ports added to the database each time this situation occurs. To give + * the user the choice between »a lot of new ports« and »some poll runs + * are missed but ports stay stable« the 'ignore_unmapable_port' option + * has been added to configure this behaviour. To skip the port in this + * loop is sufficient as the next loop is looping only over ports found + * in the database and "maps back". As we did not add a new port to the + * DB here, there's no port to be mapped to. + * + * I'm using the in_array() check here, as I'm not sure if an "ifIndex" + * can be legally set to 0, which would yield True when checking if the + * value is empty(). + */ if (Config::get('ignore_unmapable_port') === true && in_array($port[$port_association_mode], ['', null])) { continue; } - $port_id = dbInsert(array('device_id' => $device['device_id'], 'ifIndex' => $ifIndex, 'ifName' => $ifName), 'ports'); - dbInsert(array('port_id' => $port_id), 'ports_statistics'); - $ports[$port_id] = dbFetchRow('SELECT * FROM `ports` WHERE `port_id` = ?', array($port_id)); - echo 'Adding: '.$ifName.'('.$ifIndex.')('.$port_id.')'; + $port_id = dbInsert(['device_id' => $device['device_id'], 'ifIndex' => $ifIndex, 'ifName' => $ifName], 'ports'); + dbInsert(['port_id' => $port_id], 'ports_statistics'); + $ports[$port_id] = dbFetchRow('SELECT * FROM `ports` WHERE `port_id` = ?', [$port_id]); + echo 'Adding: ' . $ifName . '(' . $ifIndex . ')(' . $port_id . ')'; } elseif ($ports[$port_id]['deleted'] == 1) { // Port re-discovered after previous deletion? - dbUpdate(array('deleted' => '0'), 'ports', '`port_id` = ?', array($port_id)); + dbUpdate(['deleted' => '0'], 'ports', '`port_id` = ?', [$port_id]); $ports[$port_id]['deleted'] = '0'; } if ($ports[$port_id]['ports_statistics_port_id'] === null) { // in case the port was created before we created the table - dbInsert(array('port_id' => $port_id), 'ports_statistics'); + dbInsert(['port_id' => $port_id], 'ports_statistics'); } /** Assure stable bidirectional port mapping between DB and polled data - * - * Store the *current* ifIndex in the port info array containing all port information - * fetched from the database, as this is the only means we have to map ports_stats we - * just polled from the device to a port in $ports. All code below an includeed below - * will and has to map a port using it's ifIndex. - */ + * + * Store the *current* ifIndex in the port info array containing all port information + * fetched from the database, as this is the only means we have to map ports_stats we + * just polled from the device to a port in $ports. All code below an includeed below + * will and has to map a port using it's ifIndex. + */ $ports[$port_id]['ifIndex'] = $ifIndex; $port_stats[$ifIndex]['port_id'] = $port_id; - /* Build a list of all ports, identified by their port_id, found within this poller run. */ + /* Build a list of all ports, identified by their port_id, found within this poller run. */ $ports_found[] = $port_id; } elseif (empty($ports[$port_id]['skipped'])) { // Port vanished (mark as deleted) (except when skipped by selective port polling) if ($ports[$port_id]['deleted'] != '1') { - dbUpdate(array('deleted' => '1'), 'ports', '`port_id` = ?', array($port_id)); + dbUpdate(['deleted' => '1'], 'ports', '`port_id` = ?', [$port_id]); $ports[$port_id]['deleted'] = '1'; } } } // End new interface detection - echo "\n"; // get last poll time to optimize poll_time, poll_prev and poll_period in table db @@ -521,7 +521,7 @@ $device_global_ports = [ 'poll_period' => ($polled - $port['poll_time']), ]; -$globally_updated_port_ids = array(); +$globally_updated_port_ids = []; // Loop ports in the DB and update where necessary foreach ($ports as $port) { @@ -542,7 +542,7 @@ foreach ($ports as $port) { */ if (! in_array($port_id, $ports_found)) { if ($port['deleted'] != '1') { - dbUpdate(array('deleted' => '1'), 'ports', '`device_id` = ? AND `port_id` = ?', array($device['device_id'], $port_id)); + dbUpdate(['deleted' => '1'], 'ports', '`device_id` = ? AND `port_id` = ?', [$device['device_id'], $port_id]); echo "{$port_info_string}deleted.\n"; } continue; @@ -559,9 +559,9 @@ foreach ($ports as $port) { $polled_period = ($polled - $port['poll_time']); - $port['update'] = array(); - $port['update_extended'] = array(); - $port['state'] = array(); + $port['update'] = []; + $port['update_extended'] = []; + $port['state'] = []; if ($port_association_mode != "ifIndex") { $port['update']['ifIndex'] = $ifIndex; @@ -608,7 +608,7 @@ foreach ($ports as $port) { // update ifLastChange. only in the db, not rrd if (isset($this_port['ifLastChange']) && is_numeric($this_port['ifLastChange'])) { - if ((int)$this_port['ifLastChange'] != (int)$port['ifLastChange']) { + if ((int) $this_port['ifLastChange'] != (int) $port['ifLastChange']) { $port['update']['ifLastChange'] = $this_port['ifLastChange']; } } elseif ($port['ifLastChange'] != 0) { @@ -628,12 +628,12 @@ foreach ($ports as $port) { } // Set VLAN and Trunk from Q-BRIDGE-MIB - if (!isset($this_port['ifVlan']) && isset($this_port['dot1qPvid'])) { + if (! isset($this_port['ifVlan']) && isset($this_port['dot1qPvid'])) { $this_port['ifVlan'] = $this_port['dot1qPvid']; } // Set ifConnectorPresent to null when the device does not support IF-MIB truth values. - if (isset($this_port['ifConnectorPresent']) && !in_array($this_port['ifConnectorPresent'], ['true', 'false'])) { + if (isset($this_port['ifConnectorPresent']) && ! in_array($this_port['ifConnectorPresent'], ['true', 'false'])) { $this_port['ifConnectorPresent'] = null; } @@ -643,7 +643,6 @@ foreach ($ports as $port) { // attempt to fill missing fields port_fill_missing($this_port, $device); - // Update IF-MIB data $tune_port = false; foreach ($data_oids as $oid) { @@ -658,8 +657,8 @@ foreach ($ports as $port) { } } - if ($port[$oid] != $this_port[$oid] && !isset($this_port[$oid])) { - $port['update'][$oid] = array('NULL'); + if ($port[$oid] != $this_port[$oid] && ! isset($this_port[$oid])) { + $port['update'][$oid] = ['NULL']; log_event($oid . ': ' . $port[$oid] . ' -> NULL', $device, 'interface', 4, $port['port_id']); if ($debug) { d_echo($oid . ': ' . $port[$oid] . ' -> NULL '); @@ -696,7 +695,7 @@ foreach ($ports as $port) { } } else { if (in_array($oid, ['ifOperStatus', 'ifAdminStatus', 'ifSpeed', 'ifHighSpeed'])) { - if ($port[$oid.'_prev'] == null) { + if ($port[$oid . '_prev'] == null) { $port['update'][$oid . '_prev'] = $this_port[$oid]; } } @@ -705,21 +704,21 @@ foreach ($ports as $port) { // Parse description (usually ifAlias) if config option set if (Config::has('port_descr_parser') && is_file(Config::get('install_dir') . '/' . Config::get('port_descr_parser'))) { - $port_attribs = array( + $port_attribs = [ 'type', 'descr', 'circuit', 'speed', 'notes', - ); + ]; include Config::get('install_dir') . '/' . Config::get('port_descr_parser'); foreach ($port_attribs as $attrib) { $attrib_key = 'port_descr_' . $attrib; if ($port_ifAlias[$attrib] != $port[$attrib_key]) { - if (!isset($port_ifAlias[$attrib])) { - $port_ifAlias[$attrib] = array('NULL'); + if (! isset($port_ifAlias[$attrib])) { + $port_ifAlias[$attrib] = ['NULL']; $log_port = 'NULL'; } else { $log_port = $port_ifAlias[$attrib]; @@ -732,7 +731,7 @@ foreach ($ports as $port) { } }//end if - if (!empty($port['skipped'])) { + if (! empty($port['skipped'])) { // We don't care about statistics for skipped selective polling ports d_echo("$port_id skipped because selective polling ports is set."); } elseif ($port['ifOperStatus'] == "down" && $port['ifOperStatus_prev'] == "down" && $this_port['ifOperStatus'] == "down" && $this_port['ifLastChange'] == $port['ifLastChange']) { @@ -744,7 +743,7 @@ foreach ($ports as $port) { $_stat_oids = array_merge($stat_oids_db, $stat_oids_db_extended); foreach ($_stat_oids as $oid) { $port_update = 'update'; - $extended_metric = !in_array($oid, $stat_oids_db, true); + $extended_metric = ! in_array($oid, $stat_oids_db, true); if ($extended_metric) { $port_update = 'update_extended'; } @@ -766,7 +765,6 @@ foreach ($ports as $port) { $port[$port_update][$oid . '_rate'] = $oid_rate; $port[$port_update][$oid . '_delta'] = $oid_diff; - d_echo("\n $oid ($oid_diff B) $oid_rate Bps $polled_period secs\n"); }//end if }//end foreach @@ -783,7 +781,7 @@ foreach ($ports as $port) { // If we have a valid ifSpeed we should populate the stats for checking if (is_numeric($this_port['ifSpeed']) && $this_port['ifSpeed'] > 0) { - $port['stats']['ifInBits_perc'] = round(($port['stats']['ifInBits_rate'] / $this_port['ifSpeed'] * 100)); + $port['stats']['ifInBits_perc'] = round(($port['stats']['ifInBits_rate'] / $this_port['ifSpeed'] * 100)); $port['stats']['ifOutBits_perc'] = round(($port['stats']['ifOutBits_rate'] / $this_port['ifSpeed'] * 100)); } @@ -811,7 +809,7 @@ foreach ($ports as $port) { ->addDataset('INMULTICASTPKTS', 'DERIVE', 0, 12500000000) ->addDataset('OUTMULTICASTPKTS', 'DERIVE', 0, 12500000000); - $fields = array( + $fields = [ 'INOCTETS' => $this_port['ifInOctets'], 'OUTOCTETS' => $this_port['ifOutOctets'], 'INERRORS' => $this_port['ifInErrors'], @@ -827,7 +825,7 @@ foreach ($ports as $port) { 'OUTBROADCASTPKTS' => $this_port['ifOutBroadcastPkts'], 'INMULTICASTPKTS' => $this_port['ifInMulticastPkts'], 'OUTMULTICASTPKTS' => $this_port['ifOutMulticastPkts'], - ); + ]; // non rrd stats (will be filtered) $fields['ifInUcastPkts_rate'] = $port['ifInUcastPkts_rate']; @@ -891,7 +889,7 @@ foreach ($ports as $port) { } foreach ($port['update'] as $key => $val_check) { - if (!isset($val_check)) { + if (! isset($val_check)) { unset($port['update'][$key]); } } @@ -899,18 +897,18 @@ foreach ($ports as $port) { // Update Database if $port['update'] is not empty // or if previous poll time $port['poll_time'] is different from device globally previous port time $device_global_ports["poll_prev"] // This could happen if disabled port was enabled since last polling - if (!empty($port['update']) || $device_global_ports["poll_prev"] != $port['poll_time']) { + if (! empty($port['update']) || $device_global_ports["poll_prev"] != $port['poll_time']) { $port['update']['poll_time'] = $polled; $port['update']['poll_prev'] = $port['poll_time']; $port['update']['poll_period'] = $polled_period; - $updated = dbUpdate($port['update'], 'ports', '`port_id` = ?', array($port_id)); + $updated = dbUpdate($port['update'], 'ports', '`port_id` = ?', [$port_id]); - if (!empty($port['update_extended'])) { - $updated += dbUpdate($port['update_extended'], 'ports_statistics', '`port_id` = ?', array($port_id)); + if (! empty($port['update_extended'])) { + $updated += dbUpdate($port['update_extended'], 'ports_statistics', '`port_id` = ?', [$port_id]); } d_echo("$updated updated"); } else { - $globally_updated_port_ids[] = $port_id; + $globally_updated_port_ids[] = $port_id; } // End Update Database } diff --git a/includes/polling/ports/cisco-if-extension.inc.php b/includes/polling/ports/cisco-if-extension.inc.php index 0795a4ab9b..7a9cb90674 100644 --- a/includes/polling/ports/cisco-if-extension.inc.php +++ b/includes/polling/ports/cisco-if-extension.inc.php @@ -38,7 +38,7 @@ if (isset($this_port['cieIfInRuntsErrs'])) { /* * Populate data for RRD */ - $rrd_data = array(); + $rrd_data = []; foreach ($cisco_if_extension_oids as $oid) { $ds_name = str_replace('cieIf', '', $oid); $rrd_data[$ds_name] = $this_port[$oid]; diff --git a/includes/polling/ports/f5.inc.php b/includes/polling/ports/f5.inc.php index ff68d87eda..ace302e184 100644 --- a/includes/polling/ports/f5.inc.php +++ b/includes/polling/ports/f5.inc.php @@ -1,29 +1,28 @@ . -* -* @package LibreNMS -* @link http://librenms.org -* @copyright 2016 Neil Lathwood -* @author Neil Lathwood -*/ - -$f5_stats = snmpwalk_cache_oid($device, 'sysIfxStat', array(), 'F5-BIGIP-SYSTEM-MIB'); + * f5.inc.php + * + * LibreNMS F5 Ports include + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + * + * @package LibreNMS + * @link http://librenms.org + * @copyright 2016 Neil Lathwood + * @author Neil Lathwood + */ +$f5_stats = snmpwalk_cache_oid($device, 'sysIfxStat', [], 'F5-BIGIP-SYSTEM-MIB'); unset($f5_stats[0]); foreach ($ifmib_oids as $oid) { @@ -31,7 +30,7 @@ foreach ($ifmib_oids as $oid) { $tmp_port_stats = snmpwalk_cache_oid($device, $oid, $tmp_port_stats, 'IF-MIB', null, '-OQUst'); } -$required = array( +$required = [ 'ifName' => 'sysIfxStatName', 'ifHighSpeed' => 'sysIfxStatHighSpeed', 'ifHCInOctets' => 'sysIfxStatHcInOctets', @@ -44,7 +43,7 @@ $required = array( 'ifHCOutBroadcastPkts' => 'sysIfxStatHcOutBroadcastPkts', 'ifConnectorPresent' => 'sysIfxStatConnectorPresent', 'ifAlias' => 'sysIfxStatAlias', -); +]; foreach ($tmp_port_stats as $index => $tmp_stats) { $descr = $tmp_port_stats[$index]['ifDescr']; diff --git a/includes/polling/ports/os/airos-af-ltu.inc.php b/includes/polling/ports/os/airos-af-ltu.inc.php index da86a8adab..e0d6a585e5 100644 --- a/includes/polling/ports/os/airos-af-ltu.inc.php +++ b/includes/polling/ports/os/airos-af-ltu.inc.php @@ -22,8 +22,7 @@ * @copyright 2020 Denny Friebe * @author Denny Friebe */ - -$airos_stats = snmpwalk_cache_oid($device, '.1.3.6.1.4.1.41112.1.10.1.6', array(), 'UBNT-AFLTU-MIB'); +$airos_stats = snmpwalk_cache_oid($device, '.1.3.6.1.4.1.41112.1.10.1.6', [], 'UBNT-AFLTU-MIB'); foreach ($port_stats as $index => $afport_stats) { if ($afport_stats['ifDescr'] == 'eth0') { @@ -41,7 +40,6 @@ foreach ($port_stats as $index => $afport_stats) { * Because "IF-MIB" reads wrong information we remove the existing entry for "eth0" if "afLTUethConnected" * could not be read to prevent wrong information from being stored. */ - unset($port_stats[$index]); } break; diff --git a/includes/polling/ports/os/airos-af.inc.php b/includes/polling/ports/os/airos-af.inc.php index fcbdb1564b..ee836d809f 100644 --- a/includes/polling/ports/os/airos-af.inc.php +++ b/includes/polling/ports/os/airos-af.inc.php @@ -1,6 +1,6 @@ $afport_stats) { diff --git a/includes/polling/ports/os/cmm.inc.php b/includes/polling/ports/os/cmm.inc.php index 5fd35ed1ae..52b6f96c6a 100644 --- a/includes/polling/ports/os/cmm.inc.php +++ b/includes/polling/ports/os/cmm.inc.php @@ -1,28 +1,27 @@ . -* -* @package LibreNMS -* @link http://librenms.org -* @copyright 2018 Paul Heinrichs -* @author Paul Heinrichs -*/ - + * cmm.inc.php + * + * LibreNMS CMM Ports include + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + * + * @package LibreNMS + * @link http://librenms.org + * @copyright 2018 Paul Heinrichs + * @author Paul Heinrichs + */ $cmm_stats = snmpwalk_group($device, 'cmmSwitchTable', 'CMM3-MIB'); $cmm_stats = snmpwalk_group($device, 'cmmPortTable', 'CMM3-MIB', 1, $cmm_stats); @@ -36,7 +35,7 @@ $required = [ 'ifInBroadcastPkts' => 'rxBroadcastPkts', 'ifOutBroadcastPkts' => 'txBroadcastPkts', 'ifInMulticastPkts' => 'rxMulticastPkts', - 'ifOutMulticastPkts' => 'txMulticastPkts' + 'ifOutMulticastPkts' => 'txMulticastPkts', ]; $cmm_ports = []; foreach ($cmm_stats as $index => $port) { @@ -45,8 +44,8 @@ foreach ($cmm_stats as $index => $port) { foreach ($required as $ifEntry => $IfxStat) { $cmm_port[$ifEntry] = $cmm_stats[$index][$IfxStat]; } - $cmm_port['ifName'] = "CMM Port ". $port['portNumber']; - $cmm_port['ifDescr'] = "CMM Port ". $port['portNumber']; + $cmm_port['ifName'] = "CMM Port " . $port['portNumber']; + $cmm_port['ifDescr'] = "CMM Port " . $port['portNumber']; $cmm_port['ifDuplex'] = ($cmm_stats[$index]['duplexStatus'] == 1 ? 'fullDuplex' : 'halfDuplex'); $cmm_port['ifSpeed'] = ($cmm_stats[$index]['linkSpeed'] == 1 ? '100000000' : '10000000'); $cmm_port['ifOperStatus'] = ($cmm_stats[$index]['linkStatus'] == 1 ? "up" : "down"); diff --git a/includes/polling/ports/os/cxr-ts.inc.php b/includes/polling/ports/os/cxr-ts.inc.php index 8e07ae9bba..ceaf73aa62 100644 --- a/includes/polling/ports/os/cxr-ts.inc.php +++ b/includes/polling/ports/os/cxr-ts.inc.php @@ -1,29 +1,28 @@ . -* -* @package LibreNMS -* @link http://librenms.org -* @copyright PipoCanaja 2018 -* @author PipoCanaja -*/ - -$cxr_stats = snmpwalk_cache_oid($device, 'portTable', array(), 'CXR-TS-MIB'); + * cxr-networks.inc.php + * + * LibreNMS CXR Serial Ports include + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + * + * @package LibreNMS + * @link http://librenms.org + * @copyright PipoCanaja 2018 + * @author PipoCanaja + */ +$cxr_stats = snmpwalk_cache_oid($device, 'portTable', [], 'CXR-TS-MIB'); $cxr_stats = snmpwalk_cache_oid($device, 'portStatsTable', $cxr_stats, 'CXR-TS-MIB'); d_echo($cxr_stats); @@ -35,19 +34,19 @@ $offset = 1000; foreach ($cxr_stats as $index => $serialport_stats) { $curIfIndex = $offset + $index; - $port_stats[$curIfIndex]['ifDescr'] = "SerialPort$index"; - $port_stats[$curIfIndex]['ifType'] = 'rs232'; //rs232 - $port_stats[$curIfIndex]['ifName'] = "Serial$index"; - $port_stats[$curIfIndex]['ifInOctets'] = $serialport_stats['bytesReceiveFromV24']; - $port_stats[$curIfIndex]['ifOutOctets'] = $serialport_stats['bytesSendToV24']; - $port_stats[$curIfIndex]['ifSpeed'] = preg_replace("/[^0-9.]/", '', $serialport_stats['baudRate']); + $port_stats[$curIfIndex]['ifDescr'] = "SerialPort$index"; + $port_stats[$curIfIndex]['ifType'] = 'rs232'; //rs232 + $port_stats[$curIfIndex]['ifName'] = "Serial$index"; + $port_stats[$curIfIndex]['ifInOctets'] = $serialport_stats['bytesReceiveFromV24']; + $port_stats[$curIfIndex]['ifOutOctets'] = $serialport_stats['bytesSendToV24']; + $port_stats[$curIfIndex]['ifSpeed'] = preg_replace("/[^0-9.]/", '', $serialport_stats['baudRate']); $port_stats[$curIfIndex]['ifAdminStatus'] = 'up'; - $port_stats[$curIfIndex]['ifOperStatus'] = 'up'; - $port_stats[$curIfIndex]['ifAlias'] = "Port $index, " . $serialport_stats['terminalType'] . ", " . $serialport_stats['mode'] . ", " . $serialport_stats['baudRate']." ".$serialport_stats['nbParStop']; + $port_stats[$curIfIndex]['ifOperStatus'] = 'up'; + $port_stats[$curIfIndex]['ifAlias'] = "Port $index, " . $serialport_stats['terminalType'] . ", " . $serialport_stats['mode'] . ", " . $serialport_stats['baudRate'] . " " . $serialport_stats['nbParStop']; if ($serialport_stats['aliasIpAddress'] != "0.0.0.0") { - $port_stats[$curIfIndex]['ifAlias'] .= ", Alias IP: " . $serialport_stats['aliasIpAddress'] . ":".$serialport_stats['tcpPort']; + $port_stats[$curIfIndex]['ifAlias'] .= ", Alias IP: " . $serialport_stats['aliasIpAddress'] . ":" . $serialport_stats['tcpPort']; } if ($serialport_stats['remoteIpAddress'] != "0.0.0.0") { - $port_stats[$curIfIndex]['ifAlias'] .= ", Remote IP: " . $serialport_stats['remoteIpAddress'] . ":".$serialport_stats['remoteTcpPort']; + $port_stats[$curIfIndex]['ifAlias'] .= ", Remote IP: " . $serialport_stats['remoteIpAddress'] . ":" . $serialport_stats['remoteTcpPort']; } } diff --git a/includes/polling/ports/os/fabos.inc.php b/includes/polling/ports/os/fabos.inc.php index 5a729de8b5..6d400bb9cb 100644 --- a/includes/polling/ports/os/fabos.inc.php +++ b/includes/polling/ports/os/fabos.inc.php @@ -3,6 +3,6 @@ $brocade_stats = snmpwalk_group($device, 'swFCPortName', 'SW-MIB', 1, $brocade_stats); foreach ($brocade_stats as $index => $port) { - $index_brocade=$index + 1073741823; + $index_brocade = $index + 1073741823; $port_stats[$index_brocade]['ifAlias'] = $brocade_stats[$index]['swFCPortName']; } diff --git a/includes/polling/ports/os/infinera-groove.inc.php b/includes/polling/ports/os/infinera-groove.inc.php index e25425d794..cf763ded16 100644 --- a/includes/polling/ports/os/infinera-groove.inc.php +++ b/includes/polling/ports/os/infinera-groove.inc.php @@ -1,71 +1,69 @@ . -* -* @package LibreNMS -* @link http://librenms.org -* @copyright 2019 Nick Hilliard -* @author Nick Hilliard -*/ - - + * infinera-groove.inc.php + * + * LibreNMS ports poller module for Infinera Groove + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + * + * @package LibreNMS + * @link http://librenms.org + * @copyright 2019 Nick Hilliard + * @author Nick Hilliard + */ echo 'Port types:'; -foreach (array ('eth100g', 'eth40g', 'eth10g', 'fc16g', 'fc8g') as $infineratype) { - echo ' '.$infineratype; +foreach (['eth100g', 'eth40g', 'eth10g', 'fc16g', 'fc8g'] as $infineratype) { + echo ' ' . $infineratype; preg_match('/[a-z]+(\d+)g/i', $infineratype, $matches); $infspeed = $matches[1]; - $cg_stats = snmpwalk_cache_multi_oid($device, $infineratype.'Entry', $cg_stats, 'CORIANT-GROOVE-MIB'); - $cg_stats = snmpwalk_cache_multi_oid($device, $infineratype.'Statistics', $cg_stats, 'CORIANT-GROOVE-MIB'); + $cg_stats = snmpwalk_cache_multi_oid($device, $infineratype . 'Entry', $cg_stats, 'CORIANT-GROOVE-MIB'); + $cg_stats = snmpwalk_cache_multi_oid($device, $infineratype . 'Statistics', $cg_stats, 'CORIANT-GROOVE-MIB'); - $required = array( - 'ifAlias' => $infineratype.'AliasName', - 'ifAdminStatus' => $infineratype.'AdminStatus', - 'ifOperStatus' => $infineratype.'OperStatus', + $required = [ + 'ifAlias' => $infineratype . 'AliasName', + 'ifAdminStatus' => $infineratype . 'AdminStatus', + 'ifOperStatus' => $infineratype . 'OperStatus', 'ifType' => 'Ethernet', - 'ifHCInBroadcastPkts' => $infineratype.'StatisticsEntryInBroadcastPackets', - 'ifHCInMulticastPkts' => $infineratype.'StatisticsEntryInMulticastPackets', - 'ifHCInOctets' => $infineratype.'StatisticsEntryInOctets', - 'ifHCInUcastPkts' => $infineratype.'StatisticsEntryInPackets', - 'ifHCOutBroadcastPkts' => $infineratype.'StatisticsEntryOutBroadcastPackets', - 'ifHCOutMulticastPkts' => $infineratype.'StatisticsEntryOutMulticastPackets', - 'ifHCOutOctets' => $infineratype.'StatisticsEntryOutOctets', - 'ifHCOutUcastPkts' => $infineratype.'StatisticsEntryOutPackets', + 'ifHCInBroadcastPkts' => $infineratype . 'StatisticsEntryInBroadcastPackets', + 'ifHCInMulticastPkts' => $infineratype . 'StatisticsEntryInMulticastPackets', + 'ifHCInOctets' => $infineratype . 'StatisticsEntryInOctets', + 'ifHCInUcastPkts' => $infineratype . 'StatisticsEntryInPackets', + 'ifHCOutBroadcastPkts' => $infineratype . 'StatisticsEntryOutBroadcastPackets', + 'ifHCOutMulticastPkts' => $infineratype . 'StatisticsEntryOutMulticastPackets', + 'ifHCOutOctets' => $infineratype . 'StatisticsEntryOutOctets', + 'ifHCOutUcastPkts' => $infineratype . 'StatisticsEntryOutPackets', 'ifHighSpeed' => $infspeed * 1000, - ); + ]; foreach ($cg_stats as $index => $tmp_stats) { $indexids = explode('.', $index); - if (!isset($cg_stats[$index][$infineratype.'AdminStatus'])) { + if (! isset($cg_stats[$index][$infineratype . 'AdminStatus'])) { continue; } // The CLI port name is not available in SNMP - $descr = ( strpos($infineratype, 'eth') === false ) ? $infineratype : $infspeed.'gbe'; + $descr = (strpos($infineratype, 'eth') === false) ? $infineratype : $infspeed . 'gbe'; // 100g and 40g ports use shelfId, slotId, portId // 10g, fc16g and fc8g ports append the subportId with '.' - $descr .= '-'.$indexids[0].'/'.$indexids[1].'/'.$indexids[3]; + $descr .= '-' . $indexids[0] . '/' . $indexids[1] . '/' . $indexids[3]; if ($infspeed < 40) { - $descr .= '.'.$indexids[4]; + $descr .= '.' . $indexids[4]; } // librenms expects the index to be bigint(20) => we grab 3 decimal diff --git a/includes/polling/ports/os/junos.inc.php b/includes/polling/ports/os/junos.inc.php index dd8b42da69..c9fcb29bdd 100644 --- a/includes/polling/ports/os/junos.inc.php +++ b/includes/polling/ports/os/junos.inc.php @@ -1,29 +1,28 @@ . -* -* @package LibreNMS -* @link http://librenms.org -* @copyright 2019 Ruslan Magomedov -* @author Ruslan Magomedov -*/ - -$junos_vcp_stats = snmpwalk_cache_oid($device, 'jnxVirtualChassisPortTable', array(), 'JUNIPER-VIRTUALCHASSIS-MIB'); + * junos.inc.php + * + * LibreNMS Junos VirtualChassis Ports include + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + * + * @package LibreNMS + * @link http://librenms.org + * @copyright 2019 Ruslan Magomedov + * @author Ruslan Magomedov + */ +$junos_vcp_stats = snmpwalk_cache_oid($device, 'jnxVirtualChassisPortTable', [], 'JUNIPER-VIRTUALCHASSIS-MIB'); d_echo($junos_vcp_stats); @@ -45,8 +44,8 @@ foreach ($junos_vcp_stats as $index => $vcp_stats) { $nms_index = '100' . $fpc . $pic . $port; $port_stats[$nms_index]['ifDescr'] = "fpc$index"; - $port_stats[$nms_index]['ifType'] = "vcp"; - $port_stats[$nms_index]['ifName'] = "fpc$index"; + $port_stats[$nms_index]['ifType'] = "vcp"; + $port_stats[$nms_index]['ifName'] = "fpc$index"; $port_stats[$nms_index]['ifHCInOctets'] = $vcp_stats['jnxVirtualChassisPortInOctets']; $port_stats[$nms_index]['ifHCOutOctets'] = $vcp_stats['jnxVirtualChassisPortOutOctets']; $port_stats[$nms_index]['ifHCInUcastPkts'] = $vcp_stats['jnxVirtualChassisPortInPkts']; @@ -55,6 +54,6 @@ foreach ($junos_vcp_stats as $index => $vcp_stats) { $port_stats[$nms_index]['ifOutMulticastPkts'] = $vcp_stats['jnxVirtualChassisPortOutMcasts']; $port_stats[$nms_index]['ifInErrors'] = $vcp_stats['jnxVirtualChassisPortInCRCAlignErrors']; $port_stats[$nms_index]['ifAdminStatus'] = $vcp_stats['jnxVirtualChassisPortAdminStatus']; - $port_stats[$nms_index]['ifOperStatus'] = $vcp_stats['jnxVirtualChassisPortOperStatus']; + $port_stats[$nms_index]['ifOperStatus'] = $vcp_stats['jnxVirtualChassisPortOperStatus']; } } diff --git a/includes/polling/ports/os/nokia-isam.inc.php b/includes/polling/ports/os/nokia-isam.inc.php index 7731160756..4f4a5f317f 100644 --- a/includes/polling/ports/os/nokia-isam.inc.php +++ b/includes/polling/ports/os/nokia-isam.inc.php @@ -1,25 +1,25 @@ . -* -* @package LibreNMS -* @link http://librenms.org -* @copyright 2019 Vitali Kari -* @author Vitali Kari -*/ + * nokia-isam.inc.php + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + * + * @package LibreNMS + * @link http://librenms.org + * @copyright 2019 Vitali Kari + * @author Vitali Kari + */ // Use proprietary asamIfExtCustomerId as ifAlias for Nokia ISAM Plattform. The default IF-MIB fields are here quite meaningless $isam_port_stats = snmpwalk_cache_oid($device, 'asamIfExtCustomerId', [], 'ITF-MIB-EXT', 'nokia-isam'); diff --git a/includes/polling/ports/os/procera.inc.php b/includes/polling/ports/os/procera.inc.php index 2f142bc8e8..993d86e8e6 100644 --- a/includes/polling/ports/os/procera.inc.php +++ b/includes/polling/ports/os/procera.inc.php @@ -1,72 +1,70 @@ . -* -* @package LibreNMS -* @link http://librenms.org -* @copyright 2017 Paul Heinrichs -* @author Paul Heinrichs -*/ - -$packetlogic_stats = snmpwalk_group($device, 'netDeviceTable', 'PACKETLOGIC-CHANNEL-MIB', 1, array()); + * procera.inc.php + * + * LibreNMS Procera Ports include + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + * + * @package LibreNMS + * @link http://librenms.org + * @copyright 2017 Paul Heinrichs + * @author Paul Heinrichs + */ +$packetlogic_stats = snmpwalk_group($device, 'netDeviceTable', 'PACKETLOGIC-CHANNEL-MIB', 1, []); $packetlogic_stats = snmpwalk_group($device, 'channelInfoTable', 'PACKETLOGIC-CHANNEL-MIB', 1, $packetlogic_stats); -$channelTypes = array( - array( +$channelTypes = [ + [ 'type' => 'channelExternal', - 'name' => 'External' - ), - array( + 'name' => 'External', + ], + [ 'type' => 'channelInternal', - 'name' => 'Internal' - ) -); + 'name' => 'Internal', + ], +]; -$required = array( +$required = [ 'ifInOctets' => 'RxBytes', 'ifOutOctets' => 'TxBytes', 'ifInUcastPkts' => 'RxPackets', 'ifOutUcastPkts' => 'TxPackets', 'ifInErrors' => 'RxErrors', 'ifOutErrors' => 'TxErrors', -); +]; // Media Types as per PACKETLOGIC-CHANNEL-MIB -$mediaType = array( - 0 => array('ifDuplex' => null,'ifSpeed' => 0, 'label'=> 'linkdown'), - 1 => array('ifDuplex' => 'halfDuplex', 'ifSpeed' => '10000000', 'label' => 'hd10'), - 2 => array('ifDuplex' => 'fullDuplex', 'ifSpeed' => '10000000', 'label' => 'fd10'), - 3 => array('ifDuplex' => 'halfDuplex', 'ifSpeed' => '100000000', 'label' => 'hd100'), - 4 => array('ifDuplex' => 'fullDuplex', 'ifSpeed' => '100000000', 'label' => 'fd100'), - 5 => array('ifDuplex' => 'fullDuplex', 'ifSpeed' => '1000000000', 'label' => 'fd1000'), - 6 => array('ifDuplex' => 'fullDuplex', 'ifSpeed' => '10000000000', 'label' => 'fd10000') -); - +$mediaType = [ + 0 => ['ifDuplex' => null, 'ifSpeed' => 0, 'label'=> 'linkdown'], + 1 => ['ifDuplex' => 'halfDuplex', 'ifSpeed' => '10000000', 'label' => 'hd10'], + 2 => ['ifDuplex' => 'fullDuplex', 'ifSpeed' => '10000000', 'label' => 'fd10'], + 3 => ['ifDuplex' => 'halfDuplex', 'ifSpeed' => '100000000', 'label' => 'hd100'], + 4 => ['ifDuplex' => 'fullDuplex', 'ifSpeed' => '100000000', 'label' => 'fd100'], + 5 => ['ifDuplex' => 'fullDuplex', 'ifSpeed' => '1000000000', 'label' => 'fd1000'], + 6 => ['ifDuplex' => 'fullDuplex', 'ifSpeed' => '10000000000', 'label' => 'fd10000'], +]; foreach ($packetlogic_stats as $index => $port) { - $procera_port = array(); + $procera_port = []; foreach ($channelTypes as $cType) { foreach ($required as $ifEntry => $IfxStat) { - $procera_port[$ifEntry] = $packetlogic_stats[$index][$cType['type'].$IfxStat][0]; + $procera_port[$ifEntry] = $packetlogic_stats[$index][$cType['type'] . $IfxStat][0]; } - $negotiatedMedia = $packetlogic_stats[$index][$cType['type']."NegotiatedMedia"][0]; - $procera_port['ifName'] = $packetlogic_stats[$index]['channelName'][0]. ' '.$cType['name']; - $procera_port['ifDescr'] = $packetlogic_stats[$index]['channelName'][0]. ' '.$cType['name']; + $negotiatedMedia = $packetlogic_stats[$index][$cType['type'] . "NegotiatedMedia"][0]; + $procera_port['ifName'] = $packetlogic_stats[$index]['channelName'][0] . ' ' . $cType['name']; + $procera_port['ifDescr'] = $packetlogic_stats[$index]['channelName'][0] . ' ' . $cType['name']; $procera_port['ifConnectorPresent'] = ($negotiatedMedia != '0' ? "true" : "false"); $procera_port['ifOperStatus'] = ($packetlogic_stats[$index]['channelActive'][0] == 1 ? "up" : "down"); $procera_port['ifSpeed'] = $mediaType[$negotiatedMedia]['ifSpeed']; diff --git a/includes/polling/ports/os/smartax.inc.php b/includes/polling/ports/os/smartax.inc.php index 211a0f36ba..779430ebd4 100644 --- a/includes/polling/ports/os/smartax.inc.php +++ b/includes/polling/ports/os/smartax.inc.php @@ -1,65 +1,64 @@ . -* -* @package LibreNMS -* @link http://librenms.org -* @copyright 2020 Roman Tutkevich -* @author Roman Tutkevich -*/ - -$inoctets = snmpwalk_cache_oid($device, '.1.3.6.1.4.1.2011.6.128.1.1.4.21.1.15', array()); // hwGponOltEthernetStatisticReceivedBytes -$outoctets = snmpwalk_cache_oid($device, '.1.3.6.1.4.1.2011.6.128.1.1.4.21.1.30', array()); // hwGponOltEthernetStatisticSendBytes -$inbpackets = snmpwalk_cache_oid($device, '.1.3.6.1.4.1.2011.6.128.1.1.4.21.1.5', array()); // hwGponOltEthernetStatisticReceivedBroadcastPakts -$outbpackets = snmpwalk_cache_oid($device, '.1.3.6.1.4.1.2011.6.128.1.1.4.21.1.20', array()); // hwGponOltEthernetStatisticSendBroadcastPakts -$inmpackets = snmpwalk_cache_oid($device, '.1.3.6.1.4.1.2011.6.128.1.1.4.21.1.6', array()); // hwGponOltEthernetStatisticReceivedMulticastPakts -$outmpackets = snmpwalk_cache_oid($device, '.1.3.6.1.4.1.2011.6.128.1.1.4.21.1.21', array()); // hwGponOltEthernetStatisticSendMulticastPakts -$inupackets = snmpwalk_cache_oid($device, '.1.3.6.1.4.1.2011.6.128.1.1.4.21.1.7', array()); // hwGponOltEthernetStatisticReceivedUnicastPakts -$outupackets = snmpwalk_cache_oid($device, '.1.3.6.1.4.1.2011.6.128.1.1.4.21.1.22', array()); // hwGponOltEthernetStatisticSendUnicastPakts + * smartax.inc.php + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + * + * @package LibreNMS + * @link http://librenms.org + * @copyright 2020 Roman Tutkevich + * @author Roman Tutkevich + */ +$inoctets = snmpwalk_cache_oid($device, '.1.3.6.1.4.1.2011.6.128.1.1.4.21.1.15', []); // hwGponOltEthernetStatisticReceivedBytes +$outoctets = snmpwalk_cache_oid($device, '.1.3.6.1.4.1.2011.6.128.1.1.4.21.1.30', []); // hwGponOltEthernetStatisticSendBytes +$inbpackets = snmpwalk_cache_oid($device, '.1.3.6.1.4.1.2011.6.128.1.1.4.21.1.5', []); // hwGponOltEthernetStatisticReceivedBroadcastPakts +$outbpackets = snmpwalk_cache_oid($device, '.1.3.6.1.4.1.2011.6.128.1.1.4.21.1.20', []); // hwGponOltEthernetStatisticSendBroadcastPakts +$inmpackets = snmpwalk_cache_oid($device, '.1.3.6.1.4.1.2011.6.128.1.1.4.21.1.6', []); // hwGponOltEthernetStatisticReceivedMulticastPakts +$outmpackets = snmpwalk_cache_oid($device, '.1.3.6.1.4.1.2011.6.128.1.1.4.21.1.21', []); // hwGponOltEthernetStatisticSendMulticastPakts +$inupackets = snmpwalk_cache_oid($device, '.1.3.6.1.4.1.2011.6.128.1.1.4.21.1.7', []); // hwGponOltEthernetStatisticReceivedUnicastPakts +$outupackets = snmpwalk_cache_oid($device, '.1.3.6.1.4.1.2011.6.128.1.1.4.21.1.22', []); // hwGponOltEthernetStatisticSendUnicastPakts foreach ($inoctets as $index => $value) { - $index=preg_replace("/^(.*?)\.([0-9]+)$/", "$2", $index); + $index = preg_replace("/^(.*?)\.([0-9]+)$/", "$2", $index); $port_stats[$index]['ifHCInOctets'] = $value['enterprises']; } foreach ($outoctets as $index => $value) { - $index=preg_replace("/^(.*?)\.([0-9]+)$/", "$2", $index); + $index = preg_replace("/^(.*?)\.([0-9]+)$/", "$2", $index); $port_stats[$index]['ifHCOutOctets'] = $value['enterprises']; } foreach ($inbpackets as $index => $value) { - $index=preg_replace("/^(.*?)\.([0-9]+)$/", "$2", $index); + $index = preg_replace("/^(.*?)\.([0-9]+)$/", "$2", $index); $port_stats[$index]['ifHCInBroadcastPkts'] = $value['enterprises']; } foreach ($outbpackets as $index => $value) { - $index=preg_replace("/^(.*?)\.([0-9]+)$/", "$2", $index); + $index = preg_replace("/^(.*?)\.([0-9]+)$/", "$2", $index); $port_stats[$index]['ifHCOutBroadcastPkts'] = $value['enterprises']; } foreach ($inmpackets as $index => $value) { - $index=preg_replace("/^(.*?)\.([0-9]+)$/", "$2", $index); + $index = preg_replace("/^(.*?)\.([0-9]+)$/", "$2", $index); $port_stats[$index]['ifHCInMulticastPkts'] = $value['enterprises']; } foreach ($outmpackets as $index => $value) { - $index=preg_replace("/^(.*?)\.([0-9]+)$/", "$2", $index); + $index = preg_replace("/^(.*?)\.([0-9]+)$/", "$2", $index); $port_stats[$index]['ifHCOutMulticastPkts'] = $value['enterprises']; } foreach ($inupackets as $index => $value) { - $index=preg_replace("/^(.*?)\.([0-9]+)$/", "$2", $index); + $index = preg_replace("/^(.*?)\.([0-9]+)$/", "$2", $index); $port_stats[$index]['ifHCInUcastPkts'] = $value['enterprises']; } foreach ($outupackets as $index => $value) { - $index=preg_replace("/^(.*?)\.([0-9]+)$/", "$2", $index); + $index = preg_replace("/^(.*?)\.([0-9]+)$/", "$2", $index); $port_stats[$index]['ifHCOutUcastPkts'] = $value['enterprises']; } diff --git a/includes/polling/ports/os/timos.inc.php b/includes/polling/ports/os/timos.inc.php index 46e869f60d..783ea16eb6 100644 --- a/includes/polling/ports/os/timos.inc.php +++ b/includes/polling/ports/os/timos.inc.php @@ -1,30 +1,30 @@ . -* -* @package LibreNMS -* @link http://librenms.org -* @copyright 2018 Vitali Kari -* @author Vitali Kari -*/ + * timos.inc.php + * + * LibreNMS include timos (nokia) virtual router ports + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + * + * @package LibreNMS + * @link http://librenms.org + * @copyright 2018 Vitali Kari + * @author Vitali Kari + */ // get all virtual router ports and statistics -$timos_vrf_stats = snmpwalk_cache_twopart_oid($device, 'vRtrIfName', array(), 'TIMETRA-VRTR-MIB'); +$timos_vrf_stats = snmpwalk_cache_twopart_oid($device, 'vRtrIfName', [], 'TIMETRA-VRTR-MIB'); $timos_vrf_stats = snmpwalk_cache_twopart_oid($device, 'vRtrIfAlias', $timos_vrf_stats, 'TIMETRA-VRTR-MIB'); $timos_vrf_stats = snmpwalk_cache_twopart_oid($device, 'vRtrIfDescription', $timos_vrf_stats, 'TIMETRA-VRTR-MIB'); $timos_vrf_stats = snmpwalk_cache_twopart_oid($device, 'vRtrIfSpeed', $timos_vrf_stats, 'TIMETRA-VRTR-MIB'); @@ -54,7 +54,7 @@ $translate = [ 'ifHCInOctets' => 'vRtrIfRxBytes', 'ifHCOutOctets' => 'vRtrIfTxBytes', 'ifHCInUcastPkts' => 'vRtrIfRxPkts', - 'ifHCOutUcastPkts' => 'vRtrIfTxPkts' + 'ifHCOutUcastPkts' => 'vRtrIfTxPkts', ]; $timos_ports = []; diff --git a/includes/polling/ports/port-adsl.inc.php b/includes/polling/ports/port-adsl.inc.php index 2cd2d4cc8f..2e98c584b0 100644 --- a/includes/polling/ports/port-adsl.inc.php +++ b/includes/polling/ports/port-adsl.inc.php @@ -68,7 +68,7 @@ if (isset($this_port['adslLineCoding'])) { ->addDataset('AturChanCorrectedBl', 'COUNTER', null, 100000000000) ->addDataset('AturChanUncorrectBl', 'COUNTER', null, 100000000000); - $adsl_oids = array( + $adsl_oids = [ 'AtucCurrSnrMgn', 'AtucCurrAtn', 'AtucCurrOutputPwr', @@ -92,9 +92,9 @@ if (isset($this_port['adslLineCoding'])) { 'AtucChanUncorrectBlks', 'AturChanCorrectedBlks', 'AturChanUncorrectBlks', - ); + ]; - $adsl_db_oids = array( + $adsl_db_oids = [ 'adslLineCoding', 'adslLineType', 'adslAtucInvVendorID', @@ -112,33 +112,33 @@ if (isset($this_port['adslLineCoding'])) { 'adslAturCurrAtn', 'adslAturCurrOutputPwr', 'adslAturCurrAttainableRate', - ); + ]; - $adsl_tenth_oids = array( + $adsl_tenth_oids = [ 'adslAtucCurrSnrMgn', 'adslAtucCurrAtn', 'adslAtucCurrOutputPwr', 'adslAturCurrSnrMgn', 'adslAturCurrAtn', 'adslAturCurrOutputPwr', - ); + ]; foreach ($adsl_tenth_oids as $oid) { $this_port[$oid] = ($this_port[$oid] / 10); } - if (dbFetchCell('SELECT COUNT(*) FROM `ports_adsl` WHERE `port_id` = ?', array($port_id)) == '0') { - dbInsert(array('port_id' => $port_id), 'ports_adsl'); + if (dbFetchCell('SELECT COUNT(*) FROM `ports_adsl` WHERE `port_id` = ?', [$port_id]) == '0') { + dbInsert(['port_id' => $port_id], 'ports_adsl'); } - $port['adsl_update'] = array('port_adsl_updated' => array('NOW()')); + $port['adsl_update'] = ['port_adsl_updated' => ['NOW()']]; foreach ($adsl_db_oids as $oid) { $data = str_replace('"', '', $this_port[$oid]); // FIXME - do we need this? $port['adsl_update'][$oid] = $data; } - dbUpdate($port['adsl_update'], 'ports_adsl', '`port_id` = ?', array($port_id)); + dbUpdate($port['adsl_update'], 'ports_adsl', '`port_id` = ?', [$port_id]); if ($this_port['adslAtucCurrSnrMgn'] > '1280') { $this_port['adslAtucCurrSnrMgn'] = 'U'; @@ -148,12 +148,12 @@ if (isset($this_port['adslLineCoding'])) { $this_port['adslAturCurrSnrMgn'] = 'U'; } - $fields = array(); + $fields = []; foreach ($adsl_oids as $oid) { - $oid = 'adsl'.$oid; + $oid = 'adsl' . $oid; $data = str_replace('"', '', $this_port[$oid]); // Set data to be "unknown" if it's garbled, unexistant or zero - if (!is_numeric($data)) { + if (! is_numeric($data)) { $data = 'U'; } $fields[$oid] = $data; @@ -162,5 +162,5 @@ if (isset($this_port['adslLineCoding'])) { $tags = compact('ifName', 'rrd_name', 'rrd_def'); data_update($device, 'adsl', $tags, $fields); - echo 'ADSL ('.$this_port['adslLineCoding'].'/'.formatRates($this_port['adslAtucChanCurrTxRate']).'/'.formatRates($this_port['adslAturChanCurrTxRate']).')'; + echo 'ADSL (' . $this_port['adslLineCoding'] . '/' . formatRates($this_port['adslAtucChanCurrTxRate']) . '/' . formatRates($this_port['adslAturChanCurrTxRate']) . ')'; }//end if diff --git a/includes/polling/ports/port-etherlike.inc.php b/includes/polling/ports/port-etherlike.inc.php index e3ba295495..fddf9a6200 100644 --- a/includes/polling/ports/port-etherlike.inc.php +++ b/includes/polling/ports/port-etherlike.inc.php @@ -3,7 +3,7 @@ use LibreNMS\RRD\RrdDefinition; if ($this_port['dot3StatsIndex'] and $port['ifType'] == 'ethernetCsmacd') { - $etherlike_oids = array( + $etherlike_oids = [ 'dot3StatsAlignmentErrors', 'dot3StatsFCSErrors', 'dot3StatsSingleCollisionFrames', @@ -17,13 +17,13 @@ if ($this_port['dot3StatsIndex'] and $port['ifType'] == 'ethernetCsmacd') { 'dot3StatsFrameTooLongs', 'dot3StatsInternalMacReceiveErrors', 'dot3StatsSymbolErrors', - ); + ]; - $rrd_oldname= 'etherlike-'.$port['ifIndex']; // TODO: remove oldname check? + $rrd_oldname = 'etherlike-' . $port['ifIndex']; // TODO: remove oldname check? $rrd_name = getPortRrdName($port_id, 'dot3'); $rrd_def = new RrdDefinition(); - $fields = array(); + $fields = []; foreach ($etherlike_oids as $oid) { $oid_ds = str_replace('dot3Stats', '', $oid); $rrd_def->addDataset($oid_ds, 'COUNTER', null, 100000000000); diff --git a/includes/polling/ports/port-poe.inc.php b/includes/polling/ports/port-poe.inc.php index b3eda05667..0b6c0bc6c9 100644 --- a/includes/polling/ports/port-poe.inc.php +++ b/includes/polling/ports/port-poe.inc.php @@ -12,14 +12,14 @@ $rrd_def = RrdDefinition::make() if (($device['os'] == 'vrp')) { //Tested against Huawei 5720 access switches if (isset($this_port['hwPoePortEnable'])) { - $upd = "$polled:".$this_port['hwPoePortReferencePower'].':'.$this_port['hwPoePortMaximumPower'].':'.$this_port['hwPoePortConsumingPower'].':'.$this_port['hwPoePortPeakPower']; + $upd = "$polled:" . $this_port['hwPoePortReferencePower'] . ':' . $this_port['hwPoePortMaximumPower'] . ':' . $this_port['hwPoePortConsumingPower'] . ':' . $this_port['hwPoePortPeakPower']; - $fields = array( - 'PortPwrAllocated' => $this_port['hwPoePortReferencePower'], - 'PortPwrAvailable' => $this_port['hwPoePortMaximumPower'], - 'PortConsumption' => $this_port['hwPoePortConsumingPower'], - 'PortMaxPwrDrawn' => $this_port['hwPoePortPeakPower'], - ); + $fields = [ + 'PortPwrAllocated' => $this_port['hwPoePortReferencePower'], + 'PortPwrAvailable' => $this_port['hwPoePortMaximumPower'], + 'PortConsumption' => $this_port['hwPoePortConsumingPower'], + 'PortMaxPwrDrawn' => $this_port['hwPoePortPeakPower'], + ]; $tags = compact('ifName', 'rrd_name', 'rrd_def'); data_update($device, 'poe', $tags, $fields); @@ -28,14 +28,14 @@ if (($device['os'] == 'vrp')) { } elseif (($device['os'] == 'linksys-ss')) { //Tested 318P if (isset($this_port['pethPsePortAdminEnable'])) { - $upd = "$polled:".$this_port['rlPethPsePortPowerLimit'].':'.$this_port['rlPethPsePortOutputPower']; + $upd = "$polled:" . $this_port['rlPethPsePortPowerLimit'] . ':' . $this_port['rlPethPsePortOutputPower']; - $fields = array( - 'PortPwrAllocated' => $this_port['rlPethPsePortPowerLimit'], - 'PortPwrAvailable' => $this_port['rlPethPsePortPowerLimit'], - 'PortConsumption' => $this_port['rlPethPsePortOutputPower'], - 'PortMaxPwrDrawn' => $this_port['rlPethPsePortPowerLimit'], - ); + $fields = [ + 'PortPwrAllocated' => $this_port['rlPethPsePortPowerLimit'], + 'PortPwrAvailable' => $this_port['rlPethPsePortPowerLimit'], + 'PortConsumption' => $this_port['rlPethPsePortOutputPower'], + 'PortMaxPwrDrawn' => $this_port['rlPethPsePortPowerLimit'], + ]; $tags = compact('ifName', 'rrd_name', 'rrd_def'); data_update($device, 'poe', $tags, $fields); @@ -45,15 +45,15 @@ if (($device['os'] == 'vrp')) { // Code for Cisco IOS and IOSXE, tested on 2960X if (isset($this_port['cpeExtPsePortPwrAllocated'])) { // if we have cpeExtPsePortPwrAllocated, we have the complete array so we can populate the RRD - $upd = "$polled:".$port['cpeExtPsePortPwrAllocated'].':'.$port['cpeExtPsePortPwrAvailable'].':'. - $port['cpeExtPsePortPwrConsumption'].':'.$port['cpeExtPsePortMaxPwrDrawn']; + $upd = "$polled:" . $port['cpeExtPsePortPwrAllocated'] . ':' . $port['cpeExtPsePortPwrAvailable'] . ':' . + $port['cpeExtPsePortPwrConsumption'] . ':' . $port['cpeExtPsePortMaxPwrDrawn']; echo "$this_port[cpeExtPsePortPwrAllocated],$this_port[cpeExtPsePortPwrAvailable],$this_port[cpeExtPsePortPwrConsumption],$this_port[cpeExtPsePortMaxPwrDrawn]\n"; - $fields = array( - 'PortPwrAllocated' => $this_port['cpeExtPsePortPwrAllocated'], - 'PortPwrAvailable' => $this_port['cpeExtPsePortPwrAvailable'], - 'PortConsumption' => $this_port['cpeExtPsePortPwrConsumption'], - 'PortMaxPwrDrawn' => $this_port['cpeExtPsePortMaxPwrDrawn'], - ); + $fields = [ + 'PortPwrAllocated' => $this_port['cpeExtPsePortPwrAllocated'], + 'PortPwrAvailable' => $this_port['cpeExtPsePortPwrAvailable'], + 'PortConsumption' => $this_port['cpeExtPsePortPwrConsumption'], + 'PortMaxPwrDrawn' => $this_port['cpeExtPsePortMaxPwrDrawn'], + ]; $tags = compact('ifName', 'rrd_name', 'rrd_def'); data_update($device, 'poe', $tags, $fields); diff --git a/includes/polling/sensors.inc.php b/includes/polling/sensors.inc.php index e07468a9c1..94f0cd47fc 100644 --- a/includes/polling/sensors.inc.php +++ b/includes/polling/sensors.inc.php @@ -17,7 +17,7 @@ $query = "SELECT `sensor_class` FROM `sensors` WHERE `device_id` = ?"; $params = [$device['device_id']]; $submodules = Config::get('poller_submodules.sensors', []); -if (!empty($submodules)) { +if (! empty($submodules)) { $query .= " AND `sensor_class` IN " . dbGenPlaceholders(count($submodules)); $params = array_merge($params, $submodules); } diff --git a/includes/polling/sensors/ber/junos.inc.php b/includes/polling/sensors/ber/junos.inc.php index ea91330c08..e2f222890b 100644 --- a/includes/polling/sensors/ber/junos.inc.php +++ b/includes/polling/sensors/ber/junos.inc.php @@ -3,7 +3,7 @@ if ($device['os'] == 'junos') { echo 'JunOS: '; - $sensor_exp_value = snmp_get($device, 'JNX-OPT-IF-EXT-MIB::jnxoptIfOTNPMCurrentFECBERExponent.'.$sensor['sensor_index'].'.1', '-Oqv'); - $sensor_value = ($sensor_value)*pow(10, -$sensor_exp_value); + $sensor_exp_value = snmp_get($device, 'JNX-OPT-IF-EXT-MIB::jnxoptIfOTNPMCurrentFECBERExponent.' . $sensor['sensor_index'] . '.1', '-Oqv'); + $sensor_value = ($sensor_value) * pow(10, -$sensor_exp_value); unset($sensor_exp_value); } diff --git a/includes/polling/sensors/current/ict-pdu.inc.php b/includes/polling/sensors/current/ict-pdu.inc.php index d1ed4c9ed9..c867b77538 100644 --- a/includes/polling/sensors/current/ict-pdu.inc.php +++ b/includes/polling/sensors/current/ict-pdu.inc.php @@ -5,5 +5,5 @@ $oid_sensor = $sensor['sensor_oid']; if ($oid_sensor == '.1.3.6.1.4.1.39145.10.8.1.4.0') { $sensor_value = trim(str_replace('"', '', $snmp_data[$oid_sensor])); } else { - $sensor_value = trim(str_replace('"', '', $snmp_data[$sensor['sensor_oid'].'.0'])); + $sensor_value = trim(str_replace('"', '', $snmp_data[$sensor['sensor_oid'] . '.0'])); } diff --git a/includes/polling/sensors/load/dhcpatriot.inc.php b/includes/polling/sensors/load/dhcpatriot.inc.php index 2ddaa85e3e..83f43648fe 100644 --- a/includes/polling/sensors/load/dhcpatriot.inc.php +++ b/includes/polling/sensors/load/dhcpatriot.inc.php @@ -15,13 +15,13 @@ $new_descr = explode('(', $sensor['sensor_descr'])[0] . '(' . $sensor_value . '/ if ($new_divisor != $prev_divisor) { $sensor['sensor_divisor'] = $new_divisor; - dbUpdate(array('sensor_divisor' => $new_divisor), 'sensors', '`sensor_id` = ?', array($sensor['sensor_id'])); + dbUpdate(['sensor_divisor' => $new_divisor], 'sensors', '`sensor_id` = ?', [$sensor['sensor_id']]); log_event('Sensor Divisor Updated: ' . $sensor['sensor_class'] . ' ' . $sensor['sensor_type'] . ' ' . $sensor['sensor_index'] . ' ' . $sensor['sensor_descr'] . ' old_divisor=' . $prev_divisor . ' new_divisor=' . $sensor['sensor_divisor'], $device, 'sensor', 3, $sensor['sensor_id']); } if ($new_descr != $prev_descr) { $sensor['sensor_descr'] = $new_descr; - dbUpdate(array('sensor_descr' => $new_descr), 'sensors', '`sensor_id` = ?', array($sensor['sensor_id'])); + dbUpdate(['sensor_descr' => $new_descr], 'sensors', '`sensor_id` = ?', [$sensor['sensor_id']]); } unset($prev_divisor, $new_divisor, $prev_descr, $new_descr); diff --git a/includes/polling/sensors/pre-cache/aos-emu2.inc.php b/includes/polling/sensors/pre-cache/aos-emu2.inc.php index 29c7cb0b15..5547da0639 100644 --- a/includes/polling/sensors/pre-cache/aos-emu2.inc.php +++ b/includes/polling/sensors/pre-cache/aos-emu2.inc.php @@ -22,7 +22,6 @@ * @copyright 2016 Neil Lathwood * @author Neil Lathwood */ - if ($type == 'temperature') { $sensor_cache['scale'] = snmp_get($device, 'emsStatusSysTempUnits.0', '-OQv', 'PowerNet-MIB'); } diff --git a/includes/polling/sensors/pre-cache/geist-watchdog.inc.php b/includes/polling/sensors/pre-cache/geist-watchdog.inc.php index 58a990bb39..a707600ac0 100644 --- a/includes/polling/sensors/pre-cache/geist-watchdog.inc.php +++ b/includes/polling/sensors/pre-cache/geist-watchdog.inc.php @@ -22,7 +22,6 @@ * @copyright 2017 Neil Lathwood * @author Neil Lathwood */ - if ($type == 'temperature') { $sensor_cache['geist_temp_unit'] = snmp_get($device, 'temperatureUnits.0', '-Oqv', 'GEIST-V4-MIB'); } diff --git a/includes/polling/sensors/state/eds.inc.php b/includes/polling/sensors/state/eds.inc.php index 16bd562db5..3e89573e29 100644 --- a/includes/polling/sensors/state/eds.inc.php +++ b/includes/polling/sensors/state/eds.inc.php @@ -1,6 +1,7 @@ 1) { // multiple issues, check above list - $sensor_value = $is_critical?10:9; + $sensor_value = $is_critical ? 10 : 9; } } - d_echo('Polling hrPrinterDetectedErrorState: '.$sensor_value); + d_echo('Polling hrPrinterDetectedErrorState: ' . $sensor_value); } } diff --git a/includes/polling/sensors/temperature/aos-emu2.inc.php b/includes/polling/sensors/temperature/aos-emu2.inc.php index 1923a535b8..75745e8326 100644 --- a/includes/polling/sensors/temperature/aos-emu2.inc.php +++ b/includes/polling/sensors/temperature/aos-emu2.inc.php @@ -22,5 +22,4 @@ * @copyright 2016 Neil Lathwood * @author Neil Lathwood */ - $sensor_value = fahrenheit_to_celsius($sensor_value, $sensor_cache['scale']); diff --git a/includes/polling/sensors/temperature/eds.inc.php b/includes/polling/sensors/temperature/eds.inc.php index 16bd562db5..3e89573e29 100644 --- a/includes/polling/sensors/temperature/eds.inc.php +++ b/includes/polling/sensors/temperature/eds.inc.php @@ -1,6 +1,7 @@ */ - if ($sensor_cache['geist_temp_unit'] === '0') { $sensor_value = fahrenheit_to_celsius($sensor_value / 10) * 10; } diff --git a/includes/polling/sensors/temperature/netapp.inc.php b/includes/polling/sensors/temperature/netapp.inc.php index 7409ba0378..6be2ddee4a 100644 --- a/includes/polling/sensors/temperature/netapp.inc.php +++ b/includes/polling/sensors/temperature/netapp.inc.php @@ -1,5 +1,5 @@ */ - preg_match('/([0-9]+)/', $sensor_value, $temps); $sensor_value = $temps[0]; diff --git a/includes/polling/storage.inc.php b/includes/polling/storage.inc.php index 0d6b6f5799..0aa844e4a8 100644 --- a/includes/polling/storage.inc.php +++ b/includes/polling/storage.inc.php @@ -2,13 +2,13 @@ use LibreNMS\RRD\RrdDefinition; -foreach (dbFetchRows('SELECT * FROM storage WHERE device_id = ?', array($device['device_id'])) as $storage) { +foreach (dbFetchRows('SELECT * FROM storage WHERE device_id = ?', [$device['device_id']]) as $storage) { $descr = $storage['storage_descr']; $mib = $storage['storage_mib']; - echo 'Storage '. $descr .': ' . $mib . "\n\n\n\n"; + echo 'Storage ' . $descr . ': ' . $mib . "\n\n\n\n"; - $rrd_name = array('storage', $mib, $descr); + $rrd_name = ['storage', $mib, $descr]; $rrd_def = RrdDefinition::make() ->addDataset('used', 'GAUGE', 0) ->addDataset('free', 'GAUGE', 0); @@ -26,18 +26,18 @@ foreach (dbFetchRows('SELECT * FROM storage WHERE device_id = ?', array($device[ $percent = 0; } - echo $percent.'% '; + echo $percent . '% '; - $fields = array( + $fields = [ 'used' => $storage['used'], 'free' => $storage['free'], - ); + ]; $tags = compact('mib', 'descr', 'rrd_name', 'rrd_def'); data_update($device, 'storage', $tags, $fields); // NOTE: casting to string for mysqli bug (fixed by mysqlnd) - $update = dbUpdate(array('storage_used' => (string)$storage['used'], 'storage_free' => (string)$storage['free'], 'storage_size' => (string)$storage['size'], 'storage_units' => $storage['units'], 'storage_perc' => $percent), 'storage', '`storage_id` = ?', array($storage['storage_id'])); + $update = dbUpdate(['storage_used' => (string) $storage['used'], 'storage_free' => (string) $storage['free'], 'storage_size' => (string) $storage['size'], 'storage_units' => $storage['units'], 'storage_perc' => $percent], 'storage', '`storage_id` = ?', [$storage['storage_id']]); echo "\n"; }//end foreach diff --git a/includes/polling/stp.inc.php b/includes/polling/stp.inc.php index 90e446b923..b258bf0fb3 100644 --- a/includes/polling/stp.inc.php +++ b/includes/polling/stp.inc.php @@ -15,7 +15,7 @@ */ // Pre-cache existing state of STP for this device from database -$stp_db = dbFetchRow('SELECT * FROM `stp` WHERE `device_id` = ?', array($device['device_id'])); +$stp_db = dbFetchRow('SELECT * FROM `stp` WHERE `device_id` = ?', [$device['device_id']]); $stpprotocol = snmp_get($device, 'dot1dStpProtocolSpecification.0', '-Oqv', 'RSTP-MIB'); @@ -34,9 +34,9 @@ if ($stpprotocol == 'ieee8021d' || $stpprotocol == 'unknown') { } // read the 802.1D subtree - $stp_raw = snmpwalk_cache_oid($device, 'dot1dStp', array(), 'RSTP-MIB'); + $stp_raw = snmpwalk_cache_oid($device, 'dot1dStp', [], 'RSTP-MIB'); d_echo($stp_raw); - $stp = array( + $stp = [ 'protocolSpecification' => $stp_raw[0]['dot1dStpProtocolSpecification'], 'priority' => $stp_raw[0]['dot1dStpPriority'], 'topChanges' => $stp_raw[0]['dot1dStpTopChanges'], @@ -48,8 +48,8 @@ if ($stpprotocol == 'ieee8021d' || $stpprotocol == 'unknown') { 'forwardDelay' => $stp_raw[0]['dot1dStpForwardDelay'] * $tm, 'bridgeMaxAge' => $stp_raw[0]['dot1dStpBridgeMaxAge'] * $tm, 'bridgeHelloTime' => $stp_raw[0]['dot1dStpBridgeHelloTime'] * $tm, - 'bridgeForwardDelay' => $stp_raw[0]['dot1dStpBridgeForwardDelay'] * $tm - ); + 'bridgeForwardDelay' => $stp_raw[0]['dot1dStpBridgeForwardDelay'] * $tm, + ]; // set device binding $stp['device_id'] = $device['device_id']; @@ -67,7 +67,7 @@ if ($stpprotocol == 'ieee8021d' || $stpprotocol == 'unknown') { $stp['timeSinceTopologyChange'] = $time_since_change; // designated root is stored in format 2 octet bridge priority + MAC address, so we need to normalize it - $dr = str_replace(array(' ', ':', '-'), '', strtolower($stp_raw[0]['dot1dStpDesignatedRoot'])); + $dr = str_replace([' ', ':', '-'], '', strtolower($stp_raw[0]['dot1dStpDesignatedRoot'])); $dr = substr($dr, -12); //remove first two octets $stp['designatedRoot'] = $dr; @@ -113,34 +113,34 @@ if ($stpprotocol == 'ieee8021d' || $stpprotocol == 'unknown') { log_event('STP topology changed after: ' . formatUptime($stp['timeSinceTopologyChange']), $device, 'stp', 4); } // Write to db - dbUpdate($stp, 'stp', 'device_id = ?', array($device['device_id'])); + dbUpdate($stp, 'stp', 'device_id = ?', [$device['device_id']]); echo '.'; } // STP port related stuff foreach ($stp_raw as $port => $value) { if ($port) { // $stp_raw[0] ist not port related so we skip this one - $stp_port = array( + $stp_port = [ 'priority' => $stp_raw[$port]['dot1dStpPortPriority'], 'state' => $stp_raw[$port]['dot1dStpPortState'], 'enable' => $stp_raw[$port]['dot1dStpPortEnable'], 'pathCost' => $stp_raw[$port]['dot1dStpPortPathCost'], 'designatedCost' => $stp_raw[$port]['dot1dStpPortDesignatedCost'], 'designatedPort' => $stp_raw[$port]['dot1dStpPortDesignatedPort'], - 'forwardTransitions' => $stp_raw[$port]['dot1dStpPortForwardTransitions'] - ); + 'forwardTransitions' => $stp_raw[$port]['dot1dStpPortForwardTransitions'], + ]; // set device binding $stp_port['device_id'] = $device['device_id']; // set port binding - $stp_port['port_id'] = dbFetchCell('SELECT port_id FROM `ports` WHERE `device_id` = ? AND `ifIndex` = ?', array($device['device_id'], $stp_raw[$port]['dot1dStpPort'])); + $stp_port['port_id'] = dbFetchCell('SELECT port_id FROM `ports` WHERE `device_id` = ? AND `ifIndex` = ?', [$device['device_id'], $stp_raw[$port]['dot1dStpPort']]); - $dr = str_replace(array(' ', ':', '-'), '', strtolower($stp_raw[$port]['dot1dStpPortDesignatedRoot'])); + $dr = str_replace([' ', ':', '-'], '', strtolower($stp_raw[$port]['dot1dStpPortDesignatedRoot'])); $dr = substr($dr, -12); //remove first two octets $stp_port['designatedRoot'] = $dr; - $db = str_replace(array(' ', ':', '-'), '', strtolower($stp_raw[$port]['dot1dStpPortDesignatedBridge'])); + $db = str_replace([' ', ':', '-'], '', strtolower($stp_raw[$port]['dot1dStpPortDesignatedBridge'])); $db = substr($db, -12); //remove first two octets $stp_port['designatedBridge'] = $db; @@ -148,7 +148,7 @@ if ($stpprotocol == 'ieee8021d' || $stpprotocol == 'unknown') { // It seems that PBN guys don't care about ieee 802.1d :-( // So try to find the right port with some crazy conversations $dp_value = dechex($stp_port['priority']); - $dp_value = $dp_value.'00'; + $dp_value = $dp_value . '00'; $dp_value = hexdec($dp_value); if ($stp_raw[$port]['dot1dStpPortDesignatedPort']) { $dp = $stp_raw[$port]['dot1dStpPortDesignatedPort'] - $dp_value; @@ -163,7 +163,7 @@ if ($stpprotocol == 'ieee8021d' || $stpprotocol == 'unknown') { //d_echo($stp_port); // Update db - dbUpdate($stp_port, 'ports_stp', '`device_id` = ? AND `port_id` = ?', array($device['device_id'], $stp_port['port_id'])); + dbUpdate($stp_port, 'ports_stp', '`device_id` = ? AND `port_id` = ?', [$device['device_id'], $stp_port['port_id']]); echo '.'; } } diff --git a/includes/polling/toner.inc.php b/includes/polling/toner.inc.php index 556bdd0f67..00ce372b58 100644 --- a/includes/polling/toner.inc.php +++ b/includes/polling/toner.inc.php @@ -2,21 +2,21 @@ use LibreNMS\RRD\RrdDefinition; -$toner_data = dbFetchRows('SELECT * FROM toner WHERE device_id = ?', array($device['device_id'])); +$toner_data = dbFetchRows('SELECT * FROM toner WHERE device_id = ?', [$device['device_id']]); foreach ($toner_data as $toner) { - echo 'Checking toner '.$toner['toner_descr'].'... '; + echo 'Checking toner ' . $toner['toner_descr'] . '... '; $raw_toner = snmp_get($device, $toner['toner_oid'], '-OUqnv'); $tonerperc = get_toner_levels($device, $raw_toner, $toner['toner_capacity']); - echo $tonerperc." %\n"; + echo $tonerperc . " %\n"; - $tags = array( + $tags = [ 'rrd_def' => RrdDefinition::make()->addDataset('toner', 'GAUGE', 0, 20000), - 'rrd_name' => array('toner', $toner['toner_index']), - 'rrd_oldname' => array('toner', $toner['toner_descr']), + 'rrd_name' => ['toner', $toner['toner_index']], + 'rrd_oldname' => ['toner', $toner['toner_descr']], 'index' => $toner['toner_index'], - ); + ]; data_update($device, 'toner', $tags, $tonerperc); // Log empty supplies (but only once) @@ -29,5 +29,5 @@ foreach ($toner_data as $toner) { log_event('Toner ' . $toner['toner_descr'] . ' was replaced (new level: ' . $tonerperc . '%)', $device, 'toner', 3, $toner['toner_id']); } - dbUpdate(array('toner_current' => $tonerperc, 'toner_capacity' => $toner['toner_capacity']), 'toner', '`toner_id` = ?', array($toner['toner_id'])); + dbUpdate(['toner_current' => $tonerperc, 'toner_capacity' => $toner['toner_capacity']], 'toner', '`toner_id` = ?', [$toner['toner_id']]); }//end foreach diff --git a/includes/polling/ucd-diskio.inc.php b/includes/polling/ucd-diskio.inc.php index cc913e5094..6188b149b7 100644 --- a/includes/polling/ucd-diskio.inc.php +++ b/includes/polling/ucd-diskio.inc.php @@ -2,10 +2,10 @@ use LibreNMS\RRD\RrdDefinition; -$diskio_data = dbFetchRows('SELECT * FROM `ucd_diskio` WHERE `device_id` = ?', array($device['device_id'])); +$diskio_data = dbFetchRows('SELECT * FROM `ucd_diskio` WHERE `device_id` = ?', [$device['device_id']]); if (count($diskio_data)) { - $diskio_cache = array(); + $diskio_cache = []; $diskio_cache = snmpwalk_cache_oid($device, 'diskIOEntry', $diskio_cache, 'UCD-DISKIO-MIB'); foreach ($diskio_data as $diskio) { @@ -13,26 +13,26 @@ if (count($diskio_data)) { $entry = $diskio_cache[$index]; - echo $diskio['diskio_descr'].' '; + echo $diskio['diskio_descr'] . ' '; d_echo($entry); - $tags = array( - 'rrd_name' => array('ucd_diskio', $diskio['diskio_descr']), + $tags = [ + 'rrd_name' => ['ucd_diskio', $diskio['diskio_descr']], 'rrd_def' => RrdDefinition::make() ->addDataset('read', 'DERIVE', 0, 125000000000) ->addDataset('written', 'DERIVE', 0, 125000000000) ->addDataset('reads', 'DERIVE', 0, 125000000000) ->addDataset('writes', 'DERIVE', 0, 125000000000), 'descr' => $diskio['diskio_descr'], - ); + ]; - $fields = array( + $fields = [ 'read' => $entry['diskIONReadX'], 'written' => $entry['diskIONWrittenX'], 'reads' => $entry['diskIOReads'], 'writes' => $entry['diskIOWrites'], - ); + ]; data_update($device, 'ucd_diskio', $tags, $fields); }//end foreach diff --git a/includes/polling/ucd-mib.inc.php b/includes/polling/ucd-mib.inc.php index dc7e05caf8..3891f70d40 100644 --- a/includes/polling/ucd-mib.inc.php +++ b/includes/polling/ucd-mib.inc.php @@ -31,7 +31,7 @@ use LibreNMS\RRD\RrdDefinition; // UCD-SNMP-MIB::ssCpuRawWait.0 // UCD-SNMP-MIB::ssCpuRawSteal.0 -$ss = snmpwalk_cache_oid($device, 'systemStats', array(), 'UCD-SNMP-MIB'); +$ss = snmpwalk_cache_oid($device, 'systemStats', [], 'UCD-SNMP-MIB'); $ss = $ss[0]; if (is_numeric($ss['ssCpuRawUser']) && is_numeric($ss['ssCpuRawNice']) && is_numeric($ss['ssCpuRawSystem']) && is_numeric($ss['ssCpuRawIdle'])) { @@ -41,12 +41,12 @@ if (is_numeric($ss['ssCpuRawUser']) && is_numeric($ss['ssCpuRawNice']) && is_num ->addDataset('nice', 'COUNTER', 0) ->addDataset('idle', 'COUNTER', 0); - $fields = array( + $fields = [ 'user' => $ss['ssCpuRawUser'], 'system' => $ss['ssCpuRawSystem'], 'nice' => $ss['ssCpuRawNice'], 'idle' => $ss['ssCpuRawIdle'], - ); + ]; $tags = compact('rrd_def'); data_update($device, 'ucd_cpu', $tags, $fields); @@ -55,7 +55,7 @@ if (is_numeric($ss['ssCpuRawUser']) && is_numeric($ss['ssCpuRawNice']) && is_num } // This is how we'll collect in the future, start now so people don't have zero data. -$collect_oids = array( +$collect_oids = [ 'ssCpuRawUser', 'ssCpuRawNice', 'ssCpuRawSystem', @@ -72,16 +72,16 @@ $collect_oids = array( 'ssRawSwapOut', 'ssCpuRawWait', 'ssCpuRawSteal', -); +]; foreach ($collect_oids as $oid) { if (is_numeric($ss[$oid])) { - $rrd_name = 'ucd_'.$oid; + $rrd_name = 'ucd_' . $oid; $rrd_def = RrdDefinition::make()->addDataset('value', 'COUNTER', 0); - $fields = array( + $fields = [ 'value' => $ss[$oid], - ); + ]; $tags = compact('oid', 'rrd_name', 'rrd_def'); data_update($device, 'ucd_cpu', $tags, $fields); @@ -151,7 +151,7 @@ if (is_numeric($memTotalReal) && is_numeric($memAvailReal) && is_numeric($memTot ->addDataset('buffered', 'GAUGE', 0, 10000000000) ->addDataset('cached', 'GAUGE', 0, 10000000000); - $fields = array( + $fields = [ 'totalswap' => $memTotalSwap, 'availswap' => $memAvailSwap, 'totalreal' => $memTotalReal, @@ -160,7 +160,7 @@ if (is_numeric($memTotalReal) && is_numeric($memAvailReal) && is_numeric($memTot 'shared' => $memShared, 'buffered' => $memBuffer, 'cached' => $memCached, - ); + ]; $tags = compact('rrd_def'); data_update($device, 'ucd_mem', $tags, $fields); @@ -182,11 +182,11 @@ if (is_numeric($load_raw[2]['laLoadInt'])) { ->addDataset('5min', 'GAUGE', 0) ->addDataset('15min', 'GAUGE', 0); - $fields = array( + $fields = [ '1min' => $load_raw[1]['laLoadInt'], '5min' => $load_raw[2]['laLoadInt'], '15min' => $load_raw[3]['laLoadInt'], - ); + ]; $tags = compact('rrd_def'); data_update($device, 'ucd_load', $tags, $fields); diff --git a/includes/polling/unix-agent.inc.php b/includes/polling/unix-agent.inc.php index 86f6351af3..ce9d4b522c 100644 --- a/includes/polling/unix-agent.inc.php +++ b/includes/polling/unix-agent.inc.php @@ -19,37 +19,37 @@ if ($device['os_group'] == 'unix' || $device['os'] == 'windows') { stream_set_timeout($agent, \LibreNMS\Config::get('unix-agent.read-timeout')); $agentinfo = stream_get_meta_data($agent); - if (!$agent) { - echo 'Connection to UNIX agent failed on port '.$agent_port.'.'; + if (! $agent) { + echo 'Connection to UNIX agent failed on port ' . $agent_port . '.'; } else { // fetch data while not eof and not timed-out - while ((!feof($agent)) && (!$agentinfo['timed_out'])) { + while ((! feof($agent)) && (! $agentinfo['timed_out'])) { $agent_raw .= fgets($agent, 128); - $agentinfo = stream_get_meta_data($agent); + $agentinfo = stream_get_meta_data($agent); } if ($agentinfo['timed_out']) { - echo 'Connection to UNIX agent timed out during fetch on port '.$agent_port.'.'; + echo 'Connection to UNIX agent timed out during fetch on port ' . $agent_port . '.'; } } - $agent_end = microtime(true); + $agent_end = microtime(true); $agent_time = round(($agent_end - $agent_start) * 1000); - if (!empty($agent_raw)) { - echo 'execution time: '.$agent_time.'ms'; + if (! empty($agent_raw)) { + echo 'execution time: ' . $agent_time . 'ms'; - $tags = array( + $tags = [ 'rrd_def' => RrdDefinition::make()->addDataset('time', 'GAUGE', 0), - ); - $fields = array( + ]; + $fields = [ 'time' => $agent_time, - ); + ]; data_update($device, 'agent', $tags, $fields); $os->enableGraph('agent'); - $agentapps = array( + $agentapps = [ "apache", "bind", "ceph", @@ -61,17 +61,17 @@ if ($device['os_group'] == 'unix' || $device['os'] == 'windows') { "rrdcached", "tinydns", "gpsd", - ); + ]; foreach (explode('<<<', $agent_raw) as $section) { [$section, $data] = explode('>>>', $section); - [$sa, $sb] = explode('-', $section, 2); + [$sa, $sb] = explode('-', $section, 2); if (in_array($section, $agentapps)) { $agent_data['app'][$section] = trim($data); } - if (!empty($sa) && !empty($sb)) { + if (! empty($sa) && ! empty($sb)) { $agent_data[$sa][$sb] = trim($data); } else { $agent_data[$section] = trim($data); @@ -92,15 +92,15 @@ if ($device['os_group'] == 'unix' || $device['os'] == 'windows') { } // Unix Processes - if (!empty($agent_data['ps'])) { + if (! empty($agent_data['ps'])) { echo 'Processes: '; - dbDelete('processes', 'device_id = ?', array($device['device_id'])); - $data=array(); + dbDelete('processes', 'device_id = ?', [$device['device_id']]); + $data = []; foreach (explode("\n", $agent_data['ps']) as $process) { $process = preg_replace('/\((.*),([0-9]*),([0-9]*),([0-9\:\.\-]*),([0-9]*)\)\ (.*)/', '\\1|\\2|\\3|\\4|\\5|\\6', $process); [$user, $vsz, $rss, $cputime, $pid, $command] = explode('|', $process, 6); - if (!empty($command)) { - $data[]=array('device_id' => $device['device_id'], 'pid' => $pid, 'user' => $user, 'vsz' => $vsz, 'rss' => $rss, 'cputime' => $cputime, 'command' => $command); + if (! empty($command)) { + $data[] = ['device_id' => $device['device_id'], 'pid' => $pid, 'user' => $user, 'vsz' => $vsz, 'rss' => $rss, 'cputime' => $cputime, 'command' => $command]; } } if (count($data) > 0) { @@ -110,21 +110,21 @@ if ($device['os_group'] == 'unix' || $device['os'] == 'windows') { } // Windows Processes - if (!empty($agent_data['ps:sep(9)'])) { + if (! empty($agent_data['ps:sep(9)'])) { echo 'Processes: '; - dbDelete('processes', 'device_id = ?', array($device['device_id'])); - $data=array(); + dbDelete('processes', 'device_id = ?', [$device['device_id']]); + $data = []; foreach (explode("\n", $agent_data['ps:sep(9)']) as $process) { $process = preg_replace('/\(([^,;]+),([0-9]*),([0-9]*),([0-9]*),([0-9]*),([0-9]*),([0-9]*),([0-9]*),([0-9]*),([0-9]*)?,?([0-9]*)\)(.*)/', '\\1|\\2|\\3|\\4|\\5|\\6|\\7|\\8|\\9|\\10|\\11|\\12', $process); [$user, $VirtualSize, $WorkingSetSize, $zero, $processId, $PageFileUsage, $UserModeTime, $KernelModeTime, $HandleCount, $ThreadCount, $uptime, $process_name] = explode('|', $process, 12); - if (!empty($process_name)) { + if (! empty($process_name)) { $cputime = ($UserModeTime + $KernelModeTime) / 10000000; $days = floor($cputime / 86400); $hours = str_pad(floor(($cputime / 3600) % 24), 2, '0', STR_PAD_LEFT); $minutes = str_pad(floor(($cputime / 60) % 60), 2, '0', STR_PAD_LEFT); $seconds = str_pad(($cputime % 60), 2, '0', STR_PAD_LEFT); $cputime = ($days > 0 ? "$days-" : '') . "$hours:$minutes:$seconds"; - $data[]=array('device_id' => $device['device_id'], 'pid' => $processId, 'user' => $user, 'vsz' => $PageFileUsage + $WorkingSetSize, 'rss' => $WorkingSetSize, 'cputime' => $cputime, 'command' => $process_name); + $data[] = ['device_id' => $device['device_id'], 'pid' => $processId, 'user' => $user, 'vsz' => $PageFileUsage + $WorkingSetSize, 'rss' => $WorkingSetSize, 'cputime' => $cputime, 'command' => $process_name]; } } if (count($data) > 0) { @@ -135,50 +135,50 @@ if ($device['os_group'] == 'unix' || $device['os'] == 'windows') { foreach (array_keys($agent_data['app']) as $key) { if (file_exists("includes/polling/applications/$key.inc.php")) { - d_echo("Enabling $key for ".$device['hostname']." if not yet enabled\n"); + d_echo("Enabling $key for " . $device['hostname'] . " if not yet enabled\n"); if (in_array($key, $agentapps)) { - if (dbFetchCell('SELECT COUNT(*) FROM `applications` WHERE `device_id` = ? AND `app_type` = ?', array($device['device_id'], $key)) == '0') { + if (dbFetchCell('SELECT COUNT(*) FROM `applications` WHERE `device_id` = ? AND `app_type` = ?', [$device['device_id'], $key]) == '0') { echo "Found new application '$key'\n"; - dbInsert(array('device_id' => $device['device_id'], 'app_type' => $key, 'app_status' => '', 'app_instance' => ''), 'applications'); + dbInsert(['device_id' => $device['device_id'], 'app_type' => $key, 'app_status' => '', 'app_instance' => ''], 'applications'); } } } } // memcached - if (!empty($agent_data['app']['memcached'])) { + if (! empty($agent_data['app']['memcached'])) { $agent_data['app']['memcached'] = unserialize($agent_data['app']['memcached']); foreach ($agent_data['app']['memcached'] as $memcached_host => $memcached_data) { - if (dbFetchCell('SELECT COUNT(*) FROM `applications` WHERE `device_id` = ? AND `app_type` = ? AND `app_instance` = ?', array($device['device_id'], 'memcached', $memcached_host)) == '0') { + if (dbFetchCell('SELECT COUNT(*) FROM `applications` WHERE `device_id` = ? AND `app_type` = ? AND `app_instance` = ?', [$device['device_id'], 'memcached', $memcached_host]) == '0') { echo "Found new application 'Memcached' $memcached_host\n"; - dbInsert(array('device_id' => $device['device_id'], 'app_type' => 'memcached', 'app_status' => '', 'app_instance' => $memcached_host), 'applications'); + dbInsert(['device_id' => $device['device_id'], 'app_type' => 'memcached', 'app_status' => '', 'app_instance' => $memcached_host], 'applications'); } } } // DRBD - if (!empty($agent_data['drbd'])) { - $agent_data['app']['drbd'] = array(); + if (! empty($agent_data['drbd'])) { + $agent_data['app']['drbd'] = []; foreach (explode("\n", $agent_data['drbd']) as $drbd_entry) { [$drbd_dev, $drbd_data] = explode(':', $drbd_entry); if (preg_match('/^drbd/', $drbd_dev)) { $agent_data['app']['drbd'][$drbd_dev] = $drbd_data; - if (dbFetchCell('SELECT COUNT(*) FROM `applications` WHERE `device_id` = ? AND `app_type` = ? AND `app_instance` = ?', array($device['device_id'], 'drbd', $drbd_dev)) == '0') { + if (dbFetchCell('SELECT COUNT(*) FROM `applications` WHERE `device_id` = ? AND `app_type` = ? AND `app_instance` = ?', [$device['device_id'], 'drbd', $drbd_dev]) == '0') { echo "Found new application 'DRBd' $drbd_dev\n"; - dbInsert(array('device_id' => $device['device_id'], 'app_type' => 'drbd', 'app_status' => '', 'app_instance' => $drbd_dev), 'applications'); + dbInsert(['device_id' => $device['device_id'], 'app_type' => 'drbd', 'app_status' => '', 'app_instance' => $drbd_dev], 'applications'); } } } } }//end if - # Use agent DMI data if available + // Use agent DMI data if available if (isset($agent_data['dmi'])) { if ($agent_data['dmi']['system-product-name']) { $hardware = ($agent_data['dmi']['system-manufacturer'] ? $agent_data['dmi']['system-manufacturer'] . ' ' : '') . $agent_data['dmi']['system-product-name']; - # Clean up Generic hardware descriptions + // Clean up Generic hardware descriptions DeviceCache::getPrimary()->hardware = rewrite_generic_hardware($hardware); unset($hardware); } @@ -189,7 +189,7 @@ if ($device['os_group'] == 'unix' || $device['os'] == 'windows') { DeviceCache::getPrimary()->save(); } - if (!empty($agent_sensors)) { + if (! empty($agent_sensors)) { echo 'Sensors: '; check_valid_sensors($device, 'temperature', $valid['sensor'], 'agent'); d_echo($agent_sensors); diff --git a/includes/polling/unix-agent/dmi.inc.php b/includes/polling/unix-agent/dmi.inc.php index d03718d082..cdaca547e1 100644 --- a/includes/polling/unix-agent/dmi.inc.php +++ b/includes/polling/unix-agent/dmi.inc.php @@ -4,7 +4,7 @@ $dmi = $agent_data['dmi']; unset($agent_data['dmi']); foreach (explode("\n", $dmi) as $line) { - list($field,$contents) = explode('=', $line, 2); + [$field,$contents] = explode('=', $line, 2); $agent_data['dmi'][$field] = trim($contents); } diff --git a/includes/polling/unix-agent/hddtemp.inc.php b/includes/polling/unix-agent/hddtemp.inc.php index fb186fbc8d..140ef9a054 100644 --- a/includes/polling/unix-agent/hddtemp.inc.php +++ b/includes/polling/unix-agent/hddtemp.inc.php @@ -8,12 +8,12 @@ if (isset($agent_data['hddtemp']) && $agent_data['hddtemp'] != '|') { $diskcount = 0; foreach ($disks as $disk) { - list($blockdevice,$descr,$temperature,$unit) = explode('|', $disk, 4); + [$blockdevice,$descr,$temperature,$unit] = explode('|', $disk, 4); $diskcount++; $temperature = trim(str_replace('C', '', $temperature)); discover_sensor($valid['sensor'], 'temperature', $device, '', $diskcount, 'hddtemp', "$blockdevice: $descr", '1', '1', null, null, null, null, $temperature, 'agent'); - dbUpdate(array('sensor_current' => $temperature), 'sensors', '`sensor_index` = ? AND `sensor_class` = ? AND `poller_type` = ? AND `device_id` = ?', array($diskcount, 'temperature', 'agent', $device['device_id'])); - $tmp_agent_sensors = dbFetchRow("SELECT * FROM `sensors` WHERE `sensor_index` = ? AND `device_id` = ? AND `sensor_class` = 'temperature' AND `poller_type` = 'agent' AND `sensor_deleted` = 0 LIMIT 1", array($diskcount, $device['device_id'])); + dbUpdate(['sensor_current' => $temperature], 'sensors', '`sensor_index` = ? AND `sensor_class` = ? AND `poller_type` = ? AND `device_id` = ?', [$diskcount, 'temperature', 'agent', $device['device_id']]); + $tmp_agent_sensors = dbFetchRow("SELECT * FROM `sensors` WHERE `sensor_index` = ? AND `device_id` = ? AND `sensor_class` = 'temperature' AND `poller_type` = 'agent' AND `sensor_deleted` = 0 LIMIT 1", [$diskcount, $device['device_id']]); $tmp_agent_sensors['new_value'] = $temperature; $agent_sensors[] = $tmp_agent_sensors; unset($tmp_agent_sensors); diff --git a/includes/polling/unix-agent/munin-plugins.inc.php b/includes/polling/unix-agent/munin-plugins.inc.php index f8818aa78c..002ef47eb2 100644 --- a/includes/polling/unix-agent/munin-plugins.inc.php +++ b/includes/polling/unix-agent/munin-plugins.inc.php @@ -3,57 +3,57 @@ // Plugins use LibreNMS\RRD\RrdDefinition; -if (!empty($agent_data['munin'])) { +if (! empty($agent_data['munin'])) { echo 'Munin Plugins:'; d_echo($agent_data['munin']); // Build array of existing plugins - $plugins_dbq = dbFetchRows('SELECT * FROM `munin_plugins` WHERE `device_id` = ?', array($device['device_id'])); + $plugins_dbq = dbFetchRows('SELECT * FROM `munin_plugins` WHERE `device_id` = ?', [$device['device_id']]); foreach ($plugins_dbq as $plugin_db) { $plugins_db[$plugin_db['mplug_type']]['id'] = $plugin_db['mplug_id']; } - $old_plugins_rrd_dir = $host_rrd.'plugins'; - $plugins_rrd_dir = $host_rrd.'munin'; - if (is_dir($old_plugins_rrd_dir) && !is_dir($plugins_rrd_dir)) { + $old_plugins_rrd_dir = $host_rrd . 'plugins'; + $plugins_rrd_dir = $host_rrd . 'munin'; + if (is_dir($old_plugins_rrd_dir) && ! is_dir($plugins_rrd_dir)) { rename($old_plugins_rrd_dir, $plugins_rrd_dir); } - if (!is_dir($plugins_rrd_dir)) { + if (! is_dir($plugins_rrd_dir)) { mkdir($plugins_rrd_dir); echo "Created directory : $plugins_rrd_dir\n"; } foreach ($agent_data['munin'] as $plugin_type => $plugin_data) { - $plugin = array(); + $plugin = []; echo "\nPlugin: $plugin_type"; - $base_rrd_name = 'munin/'.$plugin_type; + $base_rrd_name = 'munin/' . $plugin_type; d_echo("\n[$plugin_data]\n"); foreach (explode("\n", $plugin_data) as $line) { - list($key, $value) = explode(' ', $line, 2); + [$key, $value] = explode(' ', $line, 2); if (preg_match('/^graph_/', $key)) { - list(,$key) = explode('_', $key); + [,$key] = explode('_', $key); $plugin['graph'][$key] = $value; } else { - list($metric,$key) = explode('.', $key); + [$metric,$key] = explode('.', $key); $plugin['values'][$metric][$key] = $value; } } - if (!is_array($plugins_db[$plugin_type])) { - $insert = array( + if (! is_array($plugins_db[$plugin_type])) { + $insert = [ 'device_id' => $device['device_id'], 'mplug_type' => $plugin_type, - 'mplug_instance' => ($instance == null ? array('NULL') : $instance), + 'mplug_instance' => ($instance == null ? ['NULL'] : $instance), 'mplug_category' => ($plugin['graph']['category'] == null ? 'general' : strtolower($plugin['graph']['category'])), - 'mplug_title' => ($plugin['graph']['title'] == null ? array('NULL') : $plugin['graph']['title']), - 'mplug_vlabel' => ($plugin['graph']['vlabel'] == null ? array('NULL') : $plugin['graph']['vlabel']), - 'mplug_args' => ($plugin['graph']['args'] == null ? array('NULL') : $plugin['graph']['args']), - 'mplug_info' => ($plugin['graph']['info'] == null ? array('NULL') : $plugin['graph']['info']), - ); + 'mplug_title' => ($plugin['graph']['title'] == null ? ['NULL'] : $plugin['graph']['title']), + 'mplug_vlabel' => ($plugin['graph']['vlabel'] == null ? ['NULL'] : $plugin['graph']['vlabel']), + 'mplug_args' => ($plugin['graph']['args'] == null ? ['NULL'] : $plugin['graph']['args']), + 'mplug_info' => ($plugin['graph']['info'] == null ? ['NULL'] : $plugin['graph']['info']), + ]; $mplug_id = dbInsert($insert, 'munin_plugins'); } else { $mplug_id = $plugins_db[$plugin_type]['id']; @@ -62,9 +62,9 @@ if (!empty($agent_data['munin'])) { if ($mplug_id) { echo " ID: $mplug_id"; - $dbq = dbFetchRows('SELECT * FROM `munin_plugins_ds` WHERE `mplug_id` = ?', array($mplug_id)); + $dbq = dbFetchRows('SELECT * FROM `munin_plugins_ds` WHERE `mplug_id` = ?', [$mplug_id]); foreach ($dbq as $v) { - $vu = $v['mplug_id'].'_'.$v['ds_name']; + $vu = $v['mplug_id'] . '_' . $v['ds_name']; $ds_list[$vu] = 1; } @@ -86,21 +86,21 @@ if (!empty($agent_data['munin'])) { $data['draw'] = 'LINE1.5'; } - $ds_uniq = $mplug_id.'_'.$name; + $ds_uniq = $mplug_id . '_' . $name; - $fields = array( + $fields = [ 'val' => $data['value'], - ); + ]; - $tags = array( + $tags = [ 'plugin' => $plugin_type, 'rrd_def' => RrdDefinition::make()->addDataset('val', $data['type']), - 'rrd_name' => $base_rrd_name . '_' . $name - ); + 'rrd_name' => $base_rrd_name . '_' . $name, + ]; data_update($device, 'munin-plugins', $tags, $fields); if (empty($ds_list[$ds_uniq])) { - $insert = array( + $insert = [ 'mplug_id' => $mplug_id, 'ds_name' => $name, 'ds_type' => $data['type'], @@ -119,8 +119,8 @@ if (!empty($agent_data['munin'])) { 'ds_sum' => $data['sum'], 'ds_stack' => $data['stack'], 'ds_line' => $data['line'], - ); - $ds_id = dbInsert($insert, 'munin_plugins_ds'); + ]; + $ds_id = dbInsert($insert, 'munin_plugins_ds'); }//end if }//end foreach } else { diff --git a/includes/polling/unix-agent/packages.inc.php b/includes/polling/unix-agent/packages.inc.php index 5baff4cade..a315173b67 100644 --- a/includes/polling/unix-agent/packages.inc.php +++ b/includes/polling/unix-agent/packages.inc.php @@ -4,79 +4,79 @@ $pkgs_id = []; $pkgs_db_id = []; // RPM -if (!empty($agent_data['rpm'])) { +if (! empty($agent_data['rpm'])) { echo "\nRPM Packages: "; // Build array of existing packages $manager = 'rpm'; - $pkgs_db_db = dbFetchRows('SELECT * FROM `packages` WHERE `device_id` = ?', array($device['device_id'])); + $pkgs_db_db = dbFetchRows('SELECT * FROM `packages` WHERE `device_id` = ?', [$device['device_id']]); foreach ($pkgs_db_db as $pkg_db) { - $pkgs_db[$pkg_db['manager']][$pkg_db['name']][$pkg_db['arch']][$pkg_db['version']][$pkg_db['build']]['id'] = $pkg_db['pkg_id']; + $pkgs_db[$pkg_db['manager']][$pkg_db['name']][$pkg_db['arch']][$pkg_db['version']][$pkg_db['build']]['id'] = $pkg_db['pkg_id']; $pkgs_db[$pkg_db['manager']][$pkg_db['name']][$pkg_db['arch']][$pkg_db['version']][$pkg_db['build']]['status'] = $pkg_db['status']; - $pkgs_db[$pkg_db['manager']][$pkg_db['name']][$pkg_db['arch']][$pkg_db['version']][$pkg_db['build']]['size'] = $pkg_db['size']; - $pkgs_db_id[$pkg_db['pkg_id']]['text'] = $pkg_db['manager'].'-'.$pkg_db['name'].'-'.$pkg_db['arch'].'-'.$pkg_db['version'].'-'.$pkg_db['build']; + $pkgs_db[$pkg_db['manager']][$pkg_db['name']][$pkg_db['arch']][$pkg_db['version']][$pkg_db['build']]['size'] = $pkg_db['size']; + $pkgs_db_id[$pkg_db['pkg_id']]['text'] = $pkg_db['manager'] . '-' . $pkg_db['name'] . '-' . $pkg_db['arch'] . '-' . $pkg_db['version'] . '-' . $pkg_db['build']; $pkgs_db_id[$pkg_db['pkg_id']]['manager'] = $pkg_db['manager']; - $pkgs_db_id[$pkg_db['pkg_id']]['name'] = $pkg_db['name']; - $pkgs_db_id[$pkg_db['pkg_id']]['arch'] = $pkg_db['arch']; + $pkgs_db_id[$pkg_db['pkg_id']]['name'] = $pkg_db['name']; + $pkgs_db_id[$pkg_db['pkg_id']]['arch'] = $pkg_db['arch']; $pkgs_db_id[$pkg_db['pkg_id']]['version'] = $pkg_db['version']; - $pkgs_db_id[$pkg_db['pkg_id']]['build'] = $pkg_db['build']; + $pkgs_db_id[$pkg_db['pkg_id']]['build'] = $pkg_db['build']; } foreach (explode("\n", $agent_data['rpm']) as $package) { - list($name, $version, $build, $arch, $size) = explode(' ', $package); + [$name, $version, $build, $arch, $size] = explode(' ', $package); $pkgs[$manager][$name][$arch][$version][$build]['manager'] = $manager; - $pkgs[$manager][$name][$arch][$version][$build]['name'] = $name; - $pkgs[$manager][$name][$arch][$version][$build]['arch'] = $arch; + $pkgs[$manager][$name][$arch][$version][$build]['name'] = $name; + $pkgs[$manager][$name][$arch][$version][$build]['arch'] = $arch; $pkgs[$manager][$name][$arch][$version][$build]['version'] = $version; - $pkgs[$manager][$name][$arch][$version][$build]['build'] = $build; - $pkgs[$manager][$name][$arch][$version][$build]['size'] = $size; - $pkgs[$manager][$name][$arch][$version][$build]['status'] = '1'; - $text = $manager.'-'.$name.'-'.$arch.'-'.$version.'-'.$build; + $pkgs[$manager][$name][$arch][$version][$build]['build'] = $build; + $pkgs[$manager][$name][$arch][$version][$build]['size'] = $size; + $pkgs[$manager][$name][$arch][$version][$build]['status'] = '1'; + $text = $manager . '-' . $name . '-' . $arch . '-' . $version . '-' . $build; $pkgs_id[] = $pkgs[$manager][$name][$arch][$version][$build]; } }//end if // DPKG -if (!empty($agent_data['dpkg'])) { +if (! empty($agent_data['dpkg'])) { echo "\nDEB Packages: "; // Build array of existing packages $manager = 'deb'; - $pkgs_db_db = dbFetchRows('SELECT * FROM `packages` WHERE `device_id` = ?', array($device['device_id'])); + $pkgs_db_db = dbFetchRows('SELECT * FROM `packages` WHERE `device_id` = ?', [$device['device_id']]); foreach ($pkgs_db_db as $pkg_db) { - $pkgs_db[$pkg_db['manager']][$pkg_db['name']][$pkg_db['arch']][$pkg_db['version']][$pkg_db['build']]['id'] = $pkg_db['pkg_id']; + $pkgs_db[$pkg_db['manager']][$pkg_db['name']][$pkg_db['arch']][$pkg_db['version']][$pkg_db['build']]['id'] = $pkg_db['pkg_id']; $pkgs_db[$pkg_db['manager']][$pkg_db['name']][$pkg_db['arch']][$pkg_db['version']][$pkg_db['build']]['status'] = $pkg_db['status']; - $pkgs_db[$pkg_db['manager']][$pkg_db['name']][$pkg_db['arch']][$pkg_db['version']][$pkg_db['build']]['size'] = $pkg_db['size']; - $pkgs_db_id[$pkg_db['pkg_id']]['text'] = $pkg_db['manager'].'-'.$pkg_db['name'].'-'.$pkg_db['arch'].'-'.$pkg_db['version'].'-'.$pkg_db['build']; + $pkgs_db[$pkg_db['manager']][$pkg_db['name']][$pkg_db['arch']][$pkg_db['version']][$pkg_db['build']]['size'] = $pkg_db['size']; + $pkgs_db_id[$pkg_db['pkg_id']]['text'] = $pkg_db['manager'] . '-' . $pkg_db['name'] . '-' . $pkg_db['arch'] . '-' . $pkg_db['version'] . '-' . $pkg_db['build']; $pkgs_db_id[$pkg_db['pkg_id']]['manager'] = $pkg_db['manager']; - $pkgs_db_id[$pkg_db['pkg_id']]['name'] = $pkg_db['name']; - $pkgs_db_id[$pkg_db['pkg_id']]['arch'] = $pkg_db['arch']; + $pkgs_db_id[$pkg_db['pkg_id']]['name'] = $pkg_db['name']; + $pkgs_db_id[$pkg_db['pkg_id']]['arch'] = $pkg_db['arch']; $pkgs_db_id[$pkg_db['pkg_id']]['version'] = $pkg_db['version']; - $pkgs_db_id[$pkg_db['pkg_id']]['build'] = $pkg_db['build']; + $pkgs_db_id[$pkg_db['pkg_id']]['build'] = $pkg_db['build']; } foreach (explode("\n", $agent_data['dpkg']) as $package) { - list($name, $version, $arch, $size) = explode(' ', $package); + [$name, $version, $arch, $size] = explode(' ', $package); $build = ''; $pkgs[$manager][$name][$arch][$version][$build]['manager'] = $manager; - $pkgs[$manager][$name][$arch][$version][$build]['name'] = $name; - $pkgs[$manager][$name][$arch][$version][$build]['arch'] = $arch; + $pkgs[$manager][$name][$arch][$version][$build]['name'] = $name; + $pkgs[$manager][$name][$arch][$version][$build]['arch'] = $arch; $pkgs[$manager][$name][$arch][$version][$build]['version'] = $version; - $pkgs[$manager][$name][$arch][$version][$build]['build'] = $build; - $pkgs[$manager][$name][$arch][$version][$build]['size'] = ($size * 1024); - $pkgs[$manager][$name][$arch][$version][$build]['status'] = '1'; - $text = $manager.'-'.$name.'-'.$arch.'-'.$version.'-'.$build; + $pkgs[$manager][$name][$arch][$version][$build]['build'] = $build; + $pkgs[$manager][$name][$arch][$version][$build]['size'] = ($size * 1024); + $pkgs[$manager][$name][$arch][$version][$build]['status'] = '1'; + $text = $manager . '-' . $name . '-' . $arch . '-' . $version . '-' . $build; $pkgs_id[] = $pkgs[$manager][$name][$arch][$version][$build]; } }//end if // This is run for all "packages" and is common to RPM/DEB/etc foreach ($pkgs_id as $pkg) { - $name = $pkg['name']; + $name = $pkg['name']; $version = $pkg['version']; - $build = $pkg['build']; - $arch = $pkg['arch']; - $size = $pkg['size']; + $build = $pkg['build']; + $arch = $pkg['arch']; + $size = $pkg['size']; // echo(str_pad($name, 20)." ".str_pad($version, 10)." ".str_pad($build, 10)." ".$arch."\n"); // echo($name." "); @@ -91,8 +91,8 @@ foreach ($pkgs_id as $pkg) { $pkg_update['size'] = $size; } - if (!empty($pkg_update)) { - dbUpdate($pkg_update, 'packages', '`pkg_id` = ?', array($id)); + if (! empty($pkg_update)) { + dbUpdate($pkg_update, 'packages', '`pkg_id` = ?', [$id]); echo 'u'; } else { echo '.'; @@ -102,7 +102,7 @@ foreach ($pkgs_id as $pkg) { } else { if (count($pkgs[$manager][$name][$arch], 1) > '10' || count($pkgs_db[$manager][$name][$arch], 1) == '0') { dbInsert( - array( + [ 'device_id' => $device['device_id'], 'name' => $name, 'manager' => $manager, @@ -111,33 +111,33 @@ foreach ($pkgs_id as $pkg) { 'build' => $build, 'arch' => $arch, 'size' => $size, - ), + ], 'packages' ); if ($build != '') { - $dbuild = '-'.$build; + $dbuild = '-' . $build; } else { $dbuild = ''; } - echo '+'.$name.'-'.$version.$dbuild.'-'.$arch; + echo '+' . $name . '-' . $version . $dbuild . '-' . $arch; log_event('Package installed: ' . $name . ' (' . $arch . ') version ' . $version . $dbuild, $device, 'package', 3); } elseif (count($pkgs_db[$manager][$name][$arch], 1)) { - $pkg_c = dbFetchRow('SELECT * FROM `packages` WHERE `device_id` = ? AND `manager` = ? AND `name` = ? and `arch` = ? ORDER BY version DESC, build DESC', array($device['device_id'], $manager, $name, $arch)); + $pkg_c = dbFetchRow('SELECT * FROM `packages` WHERE `device_id` = ? AND `manager` = ? AND `name` = ? and `arch` = ? ORDER BY version DESC, build DESC', [$device['device_id'], $manager, $name, $arch]); if ($pkg_c['build'] != '') { - $pkg_c_dbuild = '-'.$pkg_c['build']; + $pkg_c_dbuild = '-' . $pkg_c['build']; } else { $pkg_c_dbuild = ''; } - echo 'U('.$pkg_c['name'].'-'.$pkg_c['version'].$pkg_c_dbuild.'|'.$name.'-'.$version.$dbuild.')'; - $pkg_update = array( + echo 'U(' . $pkg_c['name'] . '-' . $pkg_c['version'] . $pkg_c_dbuild . '|' . $name . '-' . $version . $dbuild . ')'; + $pkg_update = [ 'version' => $version, 'build' => $build, 'status' => '1', 'size' => $size, - ); - dbUpdate($pkg_update, 'packages', '`pkg_id` = ?', array($pkg_c['pkg_id'])); + ]; + dbUpdate($pkg_update, 'packages', '`pkg_id` = ?', [$pkg_c['pkg_id']]); log_event('Package updated: ' . $name . ' (' . $arch . ') from ' . $pkg_c['version'] . $pkg_c_dbuild . ' to ' . $version . $dbuild, $device, 'package', 3); unset($pkgs_db_id[$pkg_c['pkg_id']]); }//end if @@ -147,8 +147,8 @@ foreach ($pkgs_id as $pkg) { // Packages foreach ($pkgs_db_id as $id => $pkg) { - dbDelete('packages', '`pkg_id` = ?', array($id)); - echo '-'.$pkg['text']; + dbDelete('packages', '`pkg_id` = ?', [$id]); + echo '-' . $pkg['text']; log_event('Package removed: ' . $pkg['name'] . ' ' . $pkg['arch'] . ' ' . $pkg['version'] . ($pkg['build'] != '' ? '-' . $pkg['build'] : ''), $device, 'package', 3); } diff --git a/includes/polling/wireless/cambium-250.inc.php b/includes/polling/wireless/cambium-250.inc.php index 50b6096fa2..e86e04557a 100644 --- a/includes/polling/wireless/cambium-250.inc.php +++ b/includes/polling/wireless/cambium-250.inc.php @@ -46,10 +46,10 @@ if (is_numeric($txModulation) && is_numeric($rxModulation)) { $rrd_def = RrdDefinition::make() ->addDataset('txModulation', 'GAUGE', 0, 24) ->addDataset('rxModulation', 'GAUGE', 0, 24); - $fields = array( + $fields = [ 'txModuation' => $txModulation, 'rxModulation' => $rxModulation, - ); + ]; $tags = compact('rrd_def'); data_update($device, 'cambium-250-modulationMode', $tags, $fields); @@ -78,9 +78,9 @@ if (is_numeric($txModulation) && is_numeric($rxModulation)) { $ssr = snmp_get($device, "signalStrengthRatio.0", "-Ovqn", "CAMBIUM-PTP250-MIB"); if (is_numeric($ssr)) { $rrd_def = RrdDefinition::make()->addDataset('ssr', 'GAUGE', -150, 150); - $fields = array( + $fields = [ 'ssr' => $ssr, - ); + ]; $tags = compact('rrd_def'); data_update($device, 'cambium-250-ssr', $tags, $fields); diff --git a/includes/polling/wireless/cambium-650.inc.php b/includes/polling/wireless/cambium-650.inc.php index 06b5e3cc82..40d36c187e 100644 --- a/includes/polling/wireless/cambium-650.inc.php +++ b/includes/polling/wireless/cambium-650.inc.php @@ -33,17 +33,16 @@ use LibreNMS\RRD\RrdDefinition; // $os->enableGraph('cambium_650_rawReceivePower'); // } - $txModulation = snmp_get($device, ".1.3.6.1.4.1.17713.7.12.15.0", "-Ovqn", ""); $rxModulation = snmp_get($device, ".1.3.6.1.4.1.17713.7.12.14.0", "-Ovqn", ""); if (is_numeric($txModulation) && is_numeric($rxModulation)) { $rrd_def = RrdDefinition::make() ->addDataset('txModulation', 'GAUGE', 0, 24) ->addDataset('rxModulation', 'GAUGE', 0, 24); - $fields = array( + $fields = [ 'txModuation' => $txModulation, 'rxModulation' => $rxModulation, - ); + ]; $tags = compact('rrd_def'); data_update($device, 'cambium-650-modulationMode', $tags, $fields); $os->enableGraph('cambium_650_modulationMode'); @@ -70,9 +69,9 @@ if (is_numeric($txModulation) && is_numeric($rxModulation)) { $ssr = snmp_get($device, "signalStrengthRatio.0", "-Ovqn", "CAMBIUM-PTP650-MIB"); if (is_numeric($ssr)) { $rrd_def = RrdDefinition::make()->addDataset('ssr', 'GAUGE', -150, 150); - $fields = array( + $fields = [ 'ssr' => $ssr, - ); + ]; $tags = compact('rrd_def'); data_update($device, 'cambium-650-ssr', $tags, $fields); $os->enableGraph('cambium_650_ssr'); diff --git a/includes/polling/wireless/cambium-epmp.inc.php b/includes/polling/wireless/cambium-epmp.inc.php index 7e6208c10d..ef929a8bdc 100644 --- a/includes/polling/wireless/cambium-epmp.inc.php +++ b/includes/polling/wireless/cambium-epmp.inc.php @@ -29,10 +29,10 @@ if (is_numeric($cambiumGPSNumTrackedSat) && is_numeric($cambiumGPSNumVisibleSat) $rrd_def = RrdDefinition::make() ->addDataset('numTracked', 'GAUGE', 0, 100000) ->addDataset('numVisible', 'GAUGE', 0, 100000); - $fields = array( + $fields = [ 'numTracked' => $cambiumGPSNumTrackedSat, - 'numVisible' => $cambiumGPSNumVisibleSat - ); + 'numVisible' => $cambiumGPSNumVisibleSat, + ]; $tags = compact('rrd_def'); data_update($device, 'cambium-epmp-gps', $tags, $fields); $os->enableGraph('cambium_epmp_gps'); @@ -44,10 +44,10 @@ if (is_numeric($cambiumSTAUplinkMCSMode) && is_numeric($cambiumSTADownlinkMCSMod $rrd_def = RrdDefinition::make() ->addDataset('uplinkMCSMode', 'GAUGE', -30, 30) ->addDataset('downlinkMCSMode', 'GAUGE', -30, 30); - $fields = array( + $fields = [ 'uplinkMCSMode' => $cambiumSTAUplinkMCSMode, - 'downlinkMCSMode' => $cambiumSTADownlinkMCSMode - ); + 'downlinkMCSMode' => $cambiumSTADownlinkMCSMode, + ]; $tags = compact('rrd_def'); data_update($device, 'cambium-epmp-modulation', $tags, $fields); $os->enableGraph('cambium_epmp_modulation'); @@ -72,11 +72,11 @@ if (is_numeric($sysNetworkEntryAttempt) && is_numeric($sysNetworkEntrySuccess) & ->addDataset('entryAttempt', 'GAUGE', 0, 100000) ->addDataset('entryAccess', 'GAUGE', 0, 100000) ->addDataset('authFailure', 'GAUGE', 0, 100000); - $fields = array( + $fields = [ 'entryAttempt' => $sysNetworkEntryAttempt, 'entryAccess' => $sysNetworkEntrySuccess, - 'authFailure' => $sysNetworkEntryAuthenticationFailure - ); + 'authFailure' => $sysNetworkEntryAuthenticationFailure, + ]; $tags = compact('rrd_def'); data_update($device, 'cambium-epmp-access', $tags, $fields); $os->enableGraph('cambium_epmp_access'); @@ -85,9 +85,9 @@ if (is_numeric($sysNetworkEntryAttempt) && is_numeric($sysNetworkEntrySuccess) & $gpsSync = snmp_get($device, "cambiumEffectiveSyncSource.0", "-Ovqn", "CAMBIUM-PMP80211-MIB"); if (is_numeric($gpsSync)) { $rrd_def = RrdDefinition::make()->addDataset('gpsSync', 'GAUGE', 0, 4); - $fields = array( + $fields = [ 'gpsSync' => $gpsSync, - ); + ]; $tags = compact('rrd_def'); data_update($device, 'cambium-epmp-gpsSync', $tags, $fields); $os->enableGraph('cambium_epmp_gpsSync'); @@ -112,17 +112,17 @@ $dlWLanTotalAvailableFrameTimePerSecond = $multi_get_array[0]["CAMBIUM-PMP80211- $dlWLanTotalUsedFrameTimePerSecond = $multi_get_array[0]["CAMBIUM-PMP80211-MIB::dlWLanTotalUsedFrameTimePerSecond"]; if (is_numeric($ulWLanTotalAvailableFrameTimePerSecond) && is_numeric($ulWLanTotalUsedFrameTimePerSecond) && is_numeric($ulWLanTotalAvailableFrameTimePerSecond) && is_numeric($ulWLanTotalUsedFrameTimePerSecond)) { - $ulWlanFrameUtilization = round((($ulWLanTotalUsedFrameTimePerSecond/$ulWLanTotalAvailableFrameTimePerSecond)*100), 2); - $dlWlanFrameUtilization = round((($dlWLanTotalUsedFrameTimePerSecond/$dlWLanTotalAvailableFrameTimePerSecond)*100), 2); + $ulWlanFrameUtilization = round((($ulWLanTotalUsedFrameTimePerSecond / $ulWLanTotalAvailableFrameTimePerSecond) * 100), 2); + $dlWlanFrameUtilization = round((($dlWLanTotalUsedFrameTimePerSecond / $dlWLanTotalAvailableFrameTimePerSecond) * 100), 2); d_echo($dlWlanFrameUtilization); d_echo($ulWlanFrameUtilization); $rrd_def = RrdDefinition::make() ->addDataset('ulwlanfrut', 'GAUGE', 0, 100000) ->addDataset('dlwlanfrut', 'GAUGE', 0, 100000); - $fields = array( - 'ulwlanframeutilization' => $ulWlanFrameUtilization, - 'dlwlanframeutilization' => $dlWlanFrameUtilization - ); + $fields = [ + 'ulwlanframeutilization' => $ulWlanFrameUtilization, + 'dlwlanframeutilization' => $dlWlanFrameUtilization, + ]; $tags = compact('rrd_def'); data_update($device, 'cambium-epmp-frameUtilization', $tags, $fields); $os->enableGraph('cambium-epmp-frameUtilization'); diff --git a/includes/polling/wireless/cambium-generic.inc.php b/includes/polling/wireless/cambium-generic.inc.php index a2fbcf7b25..c225421b4d 100644 --- a/includes/polling/wireless/cambium-generic.inc.php +++ b/includes/polling/wireless/cambium-generic.inc.php @@ -17,10 +17,10 @@ if (strstr($hardware, 'CMM') == false) { $rrd_def = RrdDefinition::make() ->addDataset('fecInErrorsCount', 'GAUGE', 0, 100000) ->addDataset('fecOutErrorsCount', 'GAUGE', 0, 100000); - $fields = array( + $fields = [ 'fecInErrorsCount' => $fecInErrorsCount, 'fecOutErrorsCount' => $fecOutErrorsCount, - ); + ]; $tags = compact('rrd_def'); data_update($device, 'cambium-generic-errorCount', $tags, $fields); $os->enableGraph('cambium_generic_errorCount'); @@ -30,9 +30,9 @@ if (strstr($hardware, 'CMM') == false) { $crcErrors = snmp_get($device, "fecCRCError.0", "-Ovqn", "WHISP-BOX-MIBV2-MIB"); if (is_numeric($crcErrors)) { $rrd_def = RrdDefinition::make()->addDataset('crcErrors', 'GAUGE', 0, 100000); - $fields = array( + $fields = [ 'crcErrors' => $crcErrors, - ); + ]; $tags = compact('rrd_def'); data_update($device, 'cambium-generic-crcErrors', $tags, $fields); $os->enableGraph('cambium_generic_crcErrors'); @@ -46,11 +46,11 @@ if (strstr($hardware, 'CMM') == false) { ->addDataset('vertical', 'GAUGE', -150, 0) ->addDataset('horizontal', 'GAUGE', -150, 0) ->addDataset('combined', 'GAUGE', -150, 0); - $fields = array( + $fields = [ 'vertical' => floatval($vertical), 'horizontal' => floatval($horizontal), 'combined' => $combined, - ); + ]; $tags = compact('rrd_def'); data_update($device, 'cambium-generic-signalHV', $tags, $fields); $os->enableGraph('cambium_generic_signalHV'); @@ -60,9 +60,9 @@ if (strstr($hardware, 'CMM') == false) { $rssi = snmp_get($device, "1.3.6.1.4.1.161.19.3.2.2.2.0", "-Ovqn", ""); if (is_numeric($rssi)) { $rrd_def = RrdDefinition::make()->addDataset('rssi', 'GAUGE', 0, 5000); - $fields = array( + $fields = [ 'rssi' => $rssi, - ); + ]; $tags = compact('rrd_def'); data_update($device, 'cambium-generic-rssi', $tags, $fields); $os->enableGraph('cambium_generic_rssi'); @@ -72,9 +72,9 @@ if (strstr($hardware, 'CMM') == false) { $jitter = snmp_get($device, "jitter.0", "-Ovqn", "WHISP-SM-MIB"); if (is_numeric($jitter)) { $rrd_def = RrdDefinition::make()->addDataset('jitter', 'GAUGE', 0, 20); - $fields = array( + $fields = [ 'jitter' => $jitter, - ); + ]; $tags = compact('rrd_def'); data_update($device, 'cambium-generic-jitter', $tags, $fields); $os->enableGraph('cambium_generic_jitter'); @@ -87,10 +87,10 @@ if (strstr($hardware, 'CMM') == false) { $rrd_def = RrdDefinition::make() ->addDataset('horizontal', 'GAUGE', -100, 100) ->addDataset('vertical', 'GAUGE', -100, 100); - $fields = array( + $fields = [ 'horizontal' => $horizontal, 'vertical' => $vertical, - ); + ]; $tags = compact('rrd_def'); data_update($device, 'cambium-generic-450-slaveHV', $tags, $fields); $os->enableGraph('cambium_generic_450_slaveHV'); @@ -100,9 +100,9 @@ if (strstr($hardware, 'CMM') == false) { $ssr = str_replace('"', "", snmp_get($device, "signalStrengthRatio.0", "-Ovqn", "WHISP-SM-MIB")); if (is_numeric($ssr)) { $rrd_def = RrdDefinition::make()->addDataset('ssr', 'GAUGE', -150, 150); - $fields = array( + $fields = [ 'ssr' => $ssr, - ); + ]; $tags = compact('rrd_def'); data_update($device, 'cambium-generic-450-slaveSSR', $tags, $fields); $os->enableGraph('cambium_generic_450_slaveSSR'); @@ -115,10 +115,10 @@ if (strstr($hardware, 'CMM') == false) { $rrd_def = RrdDefinition::make() ->addDataset('horizontal', 'GAUGE', 0, 100) ->addDataset('vertical', 'GAUGE', 0, 100); - $fields = array( + $fields = [ 'horizontal' => $horizontal, 'vertical' => $vertical, - ); + ]; $tags = compact('rrd_def'); data_update($device, 'cambium-generic-450-slaveSNR', $tags, $fields); $os->enableGraph('cambium_generic_450_slaveSNR'); @@ -137,9 +137,9 @@ if (strstr($hardware, 'AP') || strstr($hardware, 'Master') || strstr($hardware, } if (is_numeric($gpsStatus)) { $rrd_def = RrdDefinition::make()->addDataset('whispGPSStats', 'GAUGE', 0, 4); - $fields = array( + $fields = [ 'whispGPSStats' => $gpsStatus, - ); + ]; $tags = compact('rrd_def'); data_update($device, 'cambium-generic-whispGPSStats', $tags, $fields); $os->enableGraph('cambium_generic_whispGPSStats'); @@ -152,10 +152,10 @@ if (strstr($hardware, 'AP') || strstr($hardware, 'Master') || strstr($hardware, $rrd_def = RrdDefinition::make() ->addDataset('visible', 'GAUGE', 0, 1000) ->addDataset('tracked', 'GAUGE', 0, 1000); - $fields = array( + $fields = [ 'visible' => floatval($visible), 'tracked' => floatval($tracked), - ); + ]; $tags = compact('rrd_def'); data_update($device, 'cambium-generic-gpsStats', $tags, $fields); $os->enableGraph('cambium_generic_gpsStats'); @@ -166,9 +166,9 @@ if (strstr($hardware, 'AP') || strstr($hardware, 'Master') || strstr($hardware, $lastLevel = str_replace('"', "", snmp_get($device, "lastPowerLevel.2", "-Ovqn", "WHISP-APS-MIB")); if (is_numeric($lastLevel)) { $rrd_def = RrdDefinition::make()->addDataset('last', 'GAUGE', -100, 0); - $fields = array( - 'last' => $lastLevel, - ); + $fields = [ + 'last' => $lastLevel, + ]; $tags = compact('rrd_def'); data_update($device, 'cambium-generic-450-powerlevel', $tags, $fields); $os->enableGraph('cambium_generic_450_powerlevel'); @@ -182,10 +182,10 @@ if (strstr($version, 'AP') == false) { $rrd_def = RrdDefinition::make() ->addDataset('horizontal', 'GAUGE', -100, 0) ->addDataset('vertical', 'GAUGE', -100, 0); - $fields = array( + $fields = [ 'horizontal' => $horizontal, 'vertical' => $vertical, - ); + ]; $tags = compact('rrd_def'); data_update($device, 'cambium-generic-450-linkRadioDbm', $tags, $fields); $os->enableGraph('cambium_generic_450_linkRadioDbm'); @@ -198,10 +198,10 @@ if (strstr($version, 'AP') == false) { $rrd_def = RrdDefinition::make() ->addDataset('horizontal', 'GAUGE', 0, 100) ->addDataset('vertical', 'GAUGE', 0, 100); - $fields = array( + $fields = [ 'horizontal' => $horizontal, 'vertical' => $vertical, - ); + ]; $tags = compact('rrd_def'); data_update($device, 'cambium-generic-450-ptpSNR', $tags, $fields); $os->enableGraph('cambium_generic_450_ptpSNR'); @@ -211,9 +211,9 @@ if (strstr($version, 'AP') == false) { $ssr = str_replace('"', "", snmp_get($device, "linkSignalStrengthRatio.2", "-Ovqn", "WHISP-APS-MIB")); if (is_numeric($ssr)) { $rrd_def = RrdDefinition::make()->addDataset('ssr', 'GAUGE', -150, 150); - $fields = array( - 'ssr' => $ssr, - ); + $fields = [ + 'ssr' => $ssr, + ]; $tags = compact('rrd_def'); data_update($device, 'cambium-generic-450-masterSSR', $tags, $fields); $os->enableGraph('cambium_generic_450_masterSSR'); @@ -232,12 +232,12 @@ if (strstr($version, 'AP') == false) { ->addDataset('min', 'GAUGE', -100, 0) ->addDataset('max', 'GAUGE', -100, 0) ->addDataset('avg', 'GAUGE', -100, 0); - $fields = array( + $fields = [ 'dbm' => $dbmRadio, 'min' => $minRadio, 'max' => $maxRadio, 'avg' => $avgRadio, - ); + ]; $tags = compact('rrd_def'); data_update($device, 'cambium-generic-radioDbm', $tags, $fields); $os->enableGraph('cambium_generic_radioDbm'); @@ -254,10 +254,10 @@ if (strstr($version, 'AP')) { $rrd_def = RrdDefinition::make() ->addDataset('regCount', 'GAUGE', 0, 15000) ->addDataset('failed', 'GAUGE', 0, 15000); - $fields = array( + $fields = [ 'regCount' => $registered, 'failed' => $failed, - ); + ]; $tags = compact('rrd_def'); data_update($device, 'cambium-generic-regCount', $tags, $fields); $os->enableGraph('cambium_generic_regCount'); @@ -272,9 +272,9 @@ if (strstr($version, 'AP')) { } else { $freq = $freq / 10000; } - $fields = array( + $fields = [ 'freq' => $freq, - ); + ]; $tags = compact('rrd_def'); data_update($device, 'cambium-generic-freq', $tags, $fields); $os->enableGraph('cambium_generic_freq'); diff --git a/includes/polling/wireless/canopy-generic.inc.php b/includes/polling/wireless/canopy-generic.inc.php index a0834613d2..982afaeddc 100644 --- a/includes/polling/wireless/canopy-generic.inc.php +++ b/includes/polling/wireless/canopy-generic.inc.php @@ -18,10 +18,10 @@ if (strstr($hardware, 'CMM') == false) { ->addDataset('fecInErrorsCount', 'GAUGE', 0, 100000) ->addDataset('fecOutErrorsCount', 'GAUGE', 0, 100000); - $fields = array( + $fields = [ 'fecInErrorsCount' => $fecInErrorsCount, 'fecOutErrorsCount' => $fecOutErrorsCount, - ); + ]; $tags = compact('rrd_def'); data_update($device, 'canopy-generic-errorCount', $tags, $fields); $os->enableGraph('canopy_generic_errorCount'); @@ -31,9 +31,9 @@ if (strstr($hardware, 'CMM') == false) { $crcErrors = snmp_get($device, "fecCRCError.0", "-Ovqn", "WHISP-BOX-MIBV2-MIB"); if (is_numeric($crcErrors)) { $rrd_def = RrdDefinition::make()->addDataset('crcErrors', 'GAUGE', 0, 100000); - $fields = array( + $fields = [ 'crcErrors' => $crcErrors, - ); + ]; $tags = compact('rrd_def'); data_update($device, 'canopy-generic-crcErrors', $tags, $fields); $os->enableGraph('canopy_generic_crcErrors'); @@ -47,11 +47,11 @@ if (strstr($hardware, 'CMM') == false) { ->addDataset('vertical', 'GAUGE', -150, 0) ->addDataset('horizontal', 'GAUGE', -150, 0) ->addDataset('combined', 'GAUGE', -150, 0); - $fields = array( + $fields = [ 'vertical' => floatval($vertical), 'horizontal' => floatval($horizontal), 'combined' => $combined, - ); + ]; $tags = compact('rrd_def'); data_update($device, 'canopy-generic-signalHV', $tags, $fields); $os->enableGraph('canopy_generic_signalHV'); @@ -74,9 +74,9 @@ if (strstr($hardware, 'CMM') == false) { $jitter = snmp_get($device, "jitter.0", "-Ovqn", "WHISP-SM-MIB"); if (is_numeric($jitter)) { $rrd_def = RrdDefinition::make()->addDataset('jitter', 'GAUGE', 0, 20); - $fields = array( + $fields = [ 'jitter' => $jitter, - ); + ]; $tags = compact('rrd_def'); data_update($device, 'canopy-generic-jitter', $tags, $fields); $os->enableGraph('canopy_generic_jitter'); @@ -90,10 +90,10 @@ if (strstr($hardware, 'CMM') == false) { ->addDataset('horizontal', 'GAUGE', -100, 100) ->addDataset('vertical', 'GAUGE', -100, 100); - $fields = array( + $fields = [ 'horizontal' => $horizontal, 'vertical' => $vertical, - ); + ]; $tags = compact('rrd_def'); data_update($device, 'canopy-generic-450-slaveHV', $tags, $fields); $os->enableGraph('canopy_generic_450_slaveHV'); @@ -103,9 +103,9 @@ if (strstr($hardware, 'CMM') == false) { $ssr = str_replace('"', "", snmp_get($device, "signalStrengthRatio.0", "-Ovqn", "WHISP-SM-MIB")); if (is_numeric($ssr)) { $rrd_def = RrdDefinition::make()->addDataset('ssr', 'GAUGE', -150, 150); - $fields = array( + $fields = [ 'ssr' => $ssr, - ); + ]; $tags = compact('rrd_def'); data_update($device, 'canopy-generic-450-slaveSSR', $tags, $fields); $os->enableGraph('canopy_generic_450_slaveSSR'); @@ -118,10 +118,10 @@ if (strstr($hardware, 'CMM') == false) { $rrd_def = RrdDefinition::make() ->addDataset('horizontal', 'GAUGE', 0, 100) ->addDataset('vertical', 'GAUGE', 0, 100); - $fields = array( + $fields = [ 'horizontal' => $horizontal, 'vertical' => $vertical, - ); + ]; $tags = compact('rrd_def'); data_update($device, 'canopy-generic-450-slaveSNR', $tags, $fields); $os->enableGraph('canopy_generic_450_slaveSNR'); @@ -156,10 +156,10 @@ if (strstr($hardware, 'AP') || strstr($hardware, 'Master') || strstr($hardware, $rrd_def = RrdDefinition::make() ->addDataset('visible', 'GAUGE', 0, 1000) ->addDataset('tracked', 'GAUGE', 0, 1000); - $fields = array( + $fields = [ 'visible' => floatval($visible), 'tracked' => floatval($tracked), - ); + ]; $tags = compact('rrd_def'); data_update($device, 'canopy-generic-gpsStats', $tags, $fields); $os->enableGraph('canopy_generic_gpsStats'); @@ -174,10 +174,10 @@ if (strstr($version, 'AP') == false) { $rrd_def = RrdDefinition::make() ->addDataset('horizontal', 'GAUGE', -100, 0) ->addDataset('vertical', 'GAUGE', -100, 0); - $fields = array( + $fields = [ 'horizontal' => $horizontal, 'vertical' => $vertical, - ); + ]; $tags = compact('rrd_def'); data_update($device, 'canopy-generic-450-linkRadioDbm', $tags, $fields); $os->enableGraph('canopy_generic_450_linkRadioDbm'); @@ -187,9 +187,9 @@ if (strstr($version, 'AP') == false) { $lastLevel = str_replace('"', "", snmp_get($device, "lastPowerLevel.2", "-Ovqn", "WHISP-APS-MIB")); if (is_numeric($lastLevel)) { $rrd_def = RrdDefinition::make()->addDataset('last', 'GAUGE', -100, 0); - $fields = array( + $fields = [ 'last' => $lastLevel, - ); + ]; $tags = compact('rrd_def'); data_update($device, 'canopy-generic-450-powerlevel', $tags, $fields); $os->enableGraph('canopy_generic_450_powerlevel'); @@ -216,9 +216,9 @@ if (strstr($version, 'AP') == false) { $ssr = str_replace('"', "", snmp_get($device, "linkSignalStrengthRatio.2", "-Ovqn", "WHISP-APS-MIB")); if (is_numeric($ssr)) { $rrd_def = RrdDefinition::make()->addDataset('ssr', 'GAUGE', -150, 150); - $fields = array( + $fields = [ 'ssr' => $ssr, - ); + ]; $tags = compact('rrd_def'); data_update($device, 'canopy-generic-450-masterSSR', $tags, $fields); $os->enableGraph('canopy_generic_450_masterSSR'); @@ -238,12 +238,12 @@ if (strstr($version, 'AP') == false) { ->addDataset('max', 'GAUGE', -100, 0) ->addDataset('avg', 'GAUGE', -100, 0); - $fields = array( + $fields = [ 'dbm' => $dbmRadio, 'min' => $minRadio, 'max' => $maxRadio, 'avg' => $avgRadio, - ); + ]; $tags = compact('rrd_def'); data_update($device, 'canopy-generic-radioDbm', $tags, $fields); $os->enableGraph('canopy_generic_radioDbm'); @@ -266,10 +266,10 @@ if (strstr($version, 'AP')) { $rrd_def = RrdDefinition::make() ->addDataset('regCount', 'GAUGE', 0, 15000) ->addDataset('failed', 'GAUGE', 0, 15000); - $fields = array( + $fields = [ 'regCount' => $registered, 'failed' => $failed, - ); + ]; $tags = compact('rrd_def'); data_update($device, 'canopy-generic-regCount', $tags, $fields); $os->enableGraph('canopy_generic_regCount'); diff --git a/includes/polling/wireless/xirrus.inc.php b/includes/polling/wireless/xirrus.inc.php index 5e4ac1f235..0235ade0e4 100644 --- a/includes/polling/wireless/xirrus.inc.php +++ b/includes/polling/wireless/xirrus.inc.php @@ -2,7 +2,7 @@ use LibreNMS\RRD\RrdDefinition; -$associations=array(); +$associations = []; // if this config flag is true, don't poll for stations // this in case of large APs which may have many stations @@ -10,21 +10,21 @@ $associations=array(); if (\LibreNMS\Config::get('xirrus_disable_stations') != true) { // station associations // custom RRDs and graph as each AP may have 16 radios - $assoc = snmpwalk_cache_oid($device, 'XIRRUS-MIB::stationAssociationIAP', array(), 'XIRRUS-MIB'); + $assoc = snmpwalk_cache_oid($device, 'XIRRUS-MIB::stationAssociationIAP', [], 'XIRRUS-MIB'); foreach ($assoc as $s) { $radio = array_pop($s); - $associations[$radio] = (int)$associations[$radio] + 1; + $associations[$radio] = (int) $associations[$radio] + 1; } unset($radio); unset($assoc); // write to rrds foreach ($associations as $radio => $count) { $measurement = 'xirrus_users'; - $rrd_name = array($measurement, $radio); + $rrd_name = [$measurement, $radio]; $rrd_def = RrdDefinition::make()->addDataset('stations', 'GAUGE', 0, 3200); - $fields = array( - 'stations' => $count - ); + $fields = [ + 'stations' => $count, + ]; $tags = compact('radio', 'rrd_name', 'rrd_def'); data_update($device, $measurement, $tags, $fields); }