diff --git a/LibreNMS/OS/Ios.php b/LibreNMS/OS/Ios.php index f7da5e8782..70e1879fe3 100644 --- a/LibreNMS/OS/Ios.php +++ b/LibreNMS/OS/Ios.php @@ -26,16 +26,17 @@ namespace LibreNMS\OS; use LibreNMS\Device\WirelessSensor; -use LibreNMS\Interfaces\Discovery\ProcessorDiscovery; use LibreNMS\Interfaces\Discovery\Sensors\WirelessClientsDiscovery; use LibreNMS\Interfaces\Discovery\Sensors\WirelessRssiDiscovery; -use LibreNMS\OS; use LibreNMS\OS\Shared\Cisco; +use LibreNMS\OS\Traits\CiscoCellular; class Ios extends Cisco implements WirelessClientsDiscovery, WirelessRssiDiscovery { + use CiscoCellular; + /** * @return array Sensors */ @@ -89,30 +90,4 @@ class Ios extends Cisco implements } return $sensors; } - - /** - * Discover wireless RSSI (Received Signal Strength Indicator). This is in dBm. Type is rssi. - * Returns an array of LibreNMS\Device\Sensor objects that have been discovered - * - * @return array - */ - public function discoverWirelessRssi() - { - $sensors = array(); - - $data = snmpwalk_cache_oid($this->getDevice(), 'c3gCurrentGsmRssi', array(), 'CISCO-WAN-3G-MIB'); - foreach ($data as $index => $entry) { - $sensors[] = new WirelessSensor( - 'rssi', - $this->getDeviceId(), - '.1.3.6.1.4.1.9.9.661.1.3.4.1.1.1.' . $index, - 'ios', - $index, - 'RSSI: Chain ' . str_replace('1.', '', $index), - $entry['c3gCurrentGsmRssi.1'] - ); - } - - return $sensors; - } } diff --git a/LibreNMS/OS/Iosxe.php b/LibreNMS/OS/Iosxe.php index f6a19567c5..cf2b0079ff 100644 --- a/LibreNMS/OS/Iosxe.php +++ b/LibreNMS/OS/Iosxe.php @@ -25,6 +25,10 @@ namespace LibreNMS\OS; -class Iosxe extends Ciscowlc +use LibreNMS\Interfaces\Discovery\Sensors\WirelessRssiDiscovery; +use LibreNMS\OS\Traits\CiscoCellular; + +class Iosxe extends Ciscowlc implements WirelessRssiDiscovery { + use CiscoCellular; } diff --git a/LibreNMS/OS/Traits/CiscoCellular.php b/LibreNMS/OS/Traits/CiscoCellular.php new file mode 100644 index 0000000000..5738fb3dad --- /dev/null +++ b/LibreNMS/OS/Traits/CiscoCellular.php @@ -0,0 +1,57 @@ +. + * + * @package LibreNMS + * @link http://librenms.org + * @copyright 2019 Tony Murray + * @author Tony Murray + */ + +namespace LibreNMS\OS\Traits; + +use LibreNMS\Device\WirelessSensor; + +trait CiscoCellular +{ + /** + * Discover wireless RSSI (Received Signal Strength Indicator). This is in dBm. Type is rssi. + * Returns an array of LibreNMS\Device\Sensor objects that have been discovered + * + * @return array + */ + public function discoverWirelessRssi() + { + $sensors = array(); + + $data = snmpwalk_cache_oid($this->getDevice(), 'c3gCurrentGsmRssi', array(), 'CISCO-WAN-3G-MIB'); + foreach ($data as $index => $entry) { + $sensors[] = new WirelessSensor( + 'rssi', + $this->getDeviceId(), + '.1.3.6.1.4.1.9.9.661.1.3.4.1.1.1.' . $index, + 'ios', + $index, + 'RSSI: Chain ' . str_replace('1.', '', $index), + $entry['c3gCurrentGsmRssi.1'] + ); + } + + return $sensors; + } +}