From c59ae3c537b67cfa2276504d407b6bfdca5a3684 Mon Sep 17 00:00:00 2001 From: Tony Murray Date: Tue, 2 May 2017 08:12:04 -0500 Subject: [PATCH] Improve discovery output. Only output type names if we actually attempt to discover data for that type. (#6551) --- LibreNMS/Device/Sensor.php | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/LibreNMS/Device/Sensor.php b/LibreNMS/Device/Sensor.php index a87f5972ab..d560e3dfee 100644 --- a/LibreNMS/Device/Sensor.php +++ b/LibreNMS/Device/Sensor.php @@ -425,14 +425,14 @@ class Sensor implements DiscoveryModule, PollerModule protected static function discoverType(OS $os, $type) { - echo "$type: "; - $typeInterface = static::getDiscoveryInterface($type); if (!interface_exists($typeInterface)) { echo "ERROR: Discovery Interface doesn't exist! $typeInterface\n"; } - if ($os instanceof $typeInterface) { + $have_discovery = $os instanceof $typeInterface; + if ($have_discovery) { + echo "$type: "; $function = static::getDiscoveryMethod($type); $sensors = $os->$function(); if (!is_array($sensors)) { @@ -447,7 +447,9 @@ class Sensor implements DiscoveryModule, PollerModule self::sync($os->getDeviceId(), $type, $sensors); - echo PHP_EOL; + if ($have_discovery) { + echo PHP_EOL; + } } private static function checkForDuplicateSensors($sensors)