diff --git a/includes/device-groups.inc.php b/includes/device-groups.inc.php index db3c75ee2..f9ee7f4ac 100644 --- a/includes/device-groups.inc.php +++ b/includes/device-groups.inc.php @@ -25,6 +25,8 @@ * @subpackage Devices */ +use LibreNMS\Config; + /** * Add a new device group * @param $pattern diff --git a/includes/functions.php b/includes/functions.php index c57a751bf..f4e4addae 100644 --- a/includes/functions.php +++ b/includes/functions.php @@ -2143,47 +2143,55 @@ function printStats() { global $snmp_stats, $db_stats, $rrd_stats; - printf( - "SNMP [%d/%.2fs]: Get[%d/%.2fs] Getnext[%d/%.2fs] Walk[%d/%.2fs]\n", - array_sum($snmp_stats['ops']), - array_sum($snmp_stats['time']), - $snmp_stats['ops']['snmpget'], - $snmp_stats['time']['snmpget'], - $snmp_stats['ops']['snmpgetnext'], - $snmp_stats['time']['snmpgetnext'], - $snmp_stats['ops']['snmpwalk'], - $snmp_stats['time']['snmpwalk'] - ); - printf( - "MySQL [%d/%.2fs]: Cell[%d/%.2fs] Row[%d/%.2fs] Rows[%d/%.2fs] Column[%d/%.2fs] Update[%d/%.2fs] Insert[%d/%.2fs] Delete[%d/%.2fs]\n", - array_sum($db_stats['ops']), - array_sum($db_stats['time']), - $db_stats['ops']['fetchcell'], - $db_stats['time']['fetchcell'], - $db_stats['ops']['fetchrow'], - $db_stats['time']['fetchrow'], - $db_stats['ops']['fetchrows'], - $db_stats['time']['fetchrows'], - $db_stats['ops']['fetchcolumn'], - $db_stats['time']['fetchcolumn'], - $db_stats['ops']['update'], - $db_stats['time']['update'], - $db_stats['ops']['insert'], - $db_stats['time']['insert'], - $db_stats['ops']['delete'], - $db_stats['time']['delete'] - ); - printf( - "RRD [%d/%.2fs]: Update[%d/%.2fs] Create [%d/%.2fs] Other[%d/%.2fs]\n", - array_sum($rrd_stats['ops']), - array_sum($rrd_stats['time']), - $rrd_stats['ops']['update'], - $rrd_stats['time']['update'], - $rrd_stats['ops']['create'], - $rrd_stats['time']['create'], - $rrd_stats['ops']['other'], - $rrd_stats['time']['other'] - ); + if ($snmp_stats) { + printf( + "SNMP [%d/%.2fs]: Get[%d/%.2fs] Getnext[%d/%.2fs] Walk[%d/%.2fs]\n", + array_sum($snmp_stats['ops']), + array_sum($snmp_stats['time']), + $snmp_stats['ops']['snmpget'], + $snmp_stats['time']['snmpget'], + $snmp_stats['ops']['snmpgetnext'], + $snmp_stats['time']['snmpgetnext'], + $snmp_stats['ops']['snmpwalk'], + $snmp_stats['time']['snmpwalk'] + ); + } + + if ($db_stats) { + printf( + "MySQL [%d/%.2fs]: Cell[%d/%.2fs] Row[%d/%.2fs] Rows[%d/%.2fs] Column[%d/%.2fs] Update[%d/%.2fs] Insert[%d/%.2fs] Delete[%d/%.2fs]\n", + array_sum($db_stats['ops']), + array_sum($db_stats['time']), + $db_stats['ops']['fetchcell'], + $db_stats['time']['fetchcell'], + $db_stats['ops']['fetchrow'], + $db_stats['time']['fetchrow'], + $db_stats['ops']['fetchrows'], + $db_stats['time']['fetchrows'], + $db_stats['ops']['fetchcolumn'], + $db_stats['time']['fetchcolumn'], + $db_stats['ops']['update'], + $db_stats['time']['update'], + $db_stats['ops']['insert'], + $db_stats['time']['insert'], + $db_stats['ops']['delete'], + $db_stats['time']['delete'] + ); + } + + if ($rrd_stats) { + printf( + "RRD [%d/%.2fs]: Update[%d/%.2fs] Create [%d/%.2fs] Other[%d/%.2fs]\n", + array_sum($rrd_stats['ops']), + array_sum($rrd_stats['time']), + $rrd_stats['ops']['update'], + $rrd_stats['time']['update'], + $rrd_stats['ops']['create'], + $rrd_stats['time']['create'], + $rrd_stats['ops']['other'], + $rrd_stats['time']['other'] + ); + } } /** diff --git a/includes/polling/functions.inc.php b/includes/polling/functions.inc.php index c89b7fab8..295a80fed 100644 --- a/includes/polling/functions.inc.php +++ b/includes/polling/functions.inc.php @@ -244,7 +244,8 @@ function poll_device($device, $options) echo 'Device ID: ' . $device['device_id'] . PHP_EOL; echo 'OS: ' . $device['os']; $ip = dnslookup($device); - $db_ip = inet_pton($ip); + + $db_ip = isset($ip) ? inet_pton($ip) : null; if (!empty($db_ip) && inet6_ntop($db_ip) != inet6_ntop($device['ip'])) { log_event('Device IP changed to ' . $ip, $device, 'system', 3);