diff --git a/LibreNMS/Modules/OS.php b/LibreNMS/Modules/OS.php index 64130c5a0d..8586d996b7 100644 --- a/LibreNMS/Modules/OS.php +++ b/LibreNMS/Modules/OS.php @@ -24,8 +24,7 @@ namespace LibreNMS\Modules; -use LibreNMS\Config; -use LibreNMS\Interfaces\Discovery\OSDiscovery; +use App\Models\Location; use LibreNMS\Interfaces\Module; use LibreNMS\Interfaces\Polling\OSPolling; use LibreNMS\Util\Url; @@ -36,18 +35,17 @@ class OS implements Module { $this->updateLocation($os); $this->sysContact($os); - if ($os instanceof OSDiscovery) { - // null out values in case they aren't filled. - $os->getDevice()->fill([ - 'hardware' => null, - 'version' => null, - 'features' => null, - 'serial' => null, - 'icon' => null, - ]); - $os->discoverOS($os->getDevice()); - } + // null out values in case they aren't filled. + $os->getDevice()->fill([ + 'hardware' => null, + 'version' => null, + 'features' => null, + 'serial' => null, + 'icon' => null, + ]); + + $os->discoverOS($os->getDevice()); $this->handleChanges($os); } @@ -75,7 +73,7 @@ class OS implements Module $deviceModel->features = ($features ?? $deviceModel->features) ?: null; $deviceModel->serial = ($serial ?? $deviceModel->serial) ?: null; if (! empty($location)) { - $deviceModel->setLocation($location); + $deviceModel->setLocation(new Location(['location' => $location])); } } @@ -93,7 +91,7 @@ class OS implements Module $device->icon = basename(Url::findOsImage($device->os, $device->features, null, 'images/os/')); - echo trans('device.attributes.location') . ": $device->location\n"; + echo trans('device.attributes.location') . ': ' . optional($device->location)->display() . PHP_EOL; foreach (['hardware', 'version', 'features', 'serial'] as $attribute) { echo \App\Observers\DeviceObserver::attributeChangedMessage($attribute, $device->$attribute, $device->getOriginal($attribute)) . PHP_EOL; } @@ -101,18 +99,18 @@ class OS implements Module $device->save(); } - private function updateLocation(\LibreNMS\OS $os, $altLocation = null) + private function updateLocation(\LibreNMS\OS $os) { $device = $os->getDevice(); - if ($device->override_sysLocation == 0) { - $device->setLocation(snmp_get($os->getDeviceArray(), 'sysLocation.0', '-Ovq', 'SNMPv2-MIB')); + if ($device->override_sysLocation) { + optional($device->location)->lookupCoordinates(); + } else { + $new = $os->fetchLocation(); // fetch location data from device + $new->lookupCoordinates(); + $device->setLocation($new); } - // make sure the location has coordinates - if (Config::get('geoloc.latlng', true) && $device->location && ! $device->location->hasCoordinates()) { - $device->location->lookupCoordinates(); - $device->location->save(); - } + optional($device->location)->save(); } private function sysContact(\LibreNMS\OS $os) diff --git a/LibreNMS/OS/Airos.php b/LibreNMS/OS/Airos.php index c54c0a7186..0061cfc21d 100644 --- a/LibreNMS/OS/Airos.php +++ b/LibreNMS/OS/Airos.php @@ -25,6 +25,7 @@ namespace LibreNMS\OS; use App\Models\Device; +use App\Models\Location; use LibreNMS\Device\WirelessSensor; use LibreNMS\Interfaces\Discovery\OSDiscovery; use LibreNMS\Interfaces\Discovery\Sensors\WirelessCapacityDiscovery; @@ -67,6 +68,16 @@ class Airos extends OS implements } } + public function fetchLocation(): Location + { + $location = parent::fetchLocation(); + + // fix longitude having an extra - in the middle after the decimal point + $location->lng = preg_replace('/(-?\d+)\.-?(\d+)/', '$1.$2', $location->getAttributes()['lng']); + + return $location; + } + /** * Discover wireless frequency. This is in Hz. Type is frequency. * Returns an array of LibreNMS\Device\Sensor objects that have been discovered diff --git a/LibreNMS/OS/Traits/YamlOSDiscovery.php b/LibreNMS/OS/Traits/YamlOSDiscovery.php index c65cfe9950..16c8c03437 100644 --- a/LibreNMS/OS/Traits/YamlOSDiscovery.php +++ b/LibreNMS/OS/Traits/YamlOSDiscovery.php @@ -26,6 +26,7 @@ namespace LibreNMS\OS\Traits; use App\Models\Device; +use App\Models\Location; use Illuminate\Support\Arr; use Log; @@ -43,7 +44,6 @@ trait YamlOSDiscovery 'hardware', 'features', 'serial', - 'location', ]; public function discoverOS(Device $device): void @@ -61,18 +61,12 @@ trait YamlOSDiscovery $oids = Arr::only($os_yaml, $this->osFields); $fetch_oids = array_unique(Arr::flatten($oids)); $numeric = $this->isNumeric($fetch_oids); - $flags = $numeric ? '-OUQn' : '-OUQ'; - $data = snmp_get_multi_oid($this->getDeviceArray(), $fetch_oids, $flags); + $data = $this->fetch($fetch_oids, $numeric); Log::debug('Yaml OS data:', $data); foreach ($oids as $field => $oid_list) { if ($value = $this->findFirst($data, $oid_list, $numeric)) { - if ($field == 'location') { - $device->setLocation($value); - continue; - } - // extract via regex if requested if (isset($os_yaml["{$field}_regex"])) { $this->parseRegex($os_yaml["{$field}_regex"], $value); @@ -86,6 +80,26 @@ trait YamlOSDiscovery } } + public function fetchLocation(): Location + { + $os_yaml = $this->getDiscovery('os'); + $name = $os_yaml['location'] ?? 'SNMPv2-MIB::sysLocation.0'; + $lat = $os_yaml['lat'] ?? null; + $lng = $os_yaml['long'] ?? null; + + $oids = array_filter([$name, $lat, $lng]); + $numeric = $this->isNumeric($oids); + $data = $this->fetch($oids, $numeric); + + Log::debug('Yaml location data:', $data); + + return new Location([ + 'location' => $this->findFirst($data, $name, $numeric), + 'lat' => $this->findFirst($data, $lat, $numeric), + 'lng' => $this->findFirst($data, $lng, $numeric), + ]); + } + private function findFirst($data, $oids, $numeric = false) { foreach (Arr::wrap($oids) as $oid) { @@ -131,6 +145,11 @@ trait YamlOSDiscovery } } + private function fetch(array $oids, $numeric) + { + return snmp_get_multi_oid($this->getDeviceArray(), $oids, $numeric ? '-OUQn' : '-OUQ'); + } + private function isNumeric($oids) { foreach ($oids as $oid) { diff --git a/app/Models/Device.php b/app/Models/Device.php index 42e09bf718..72ed0c18a1 100644 --- a/app/Models/Device.php +++ b/app/Models/Device.php @@ -324,15 +324,33 @@ class Device extends BaseModel return $this->attribs->pluck('attrib_value', 'attrib_type')->toArray(); } - public function setLocation($location_text) + /** + * Update the location to the correct location and update GPS if needed + * + * @param \App\Models\Location $location location data + */ + public function setLocation(Location $location) { - $location_text = $location_text ? Rewrite::location($location_text) : null; + $location->location = $location->location ? Rewrite::location($location->location) : null; - $this->location_id = null; - if ($location_text) { - $location = Location::firstOrCreate(['location' => $location_text]); + if (! $location->location) { // disassociate if the location name is empty + $this->location_id = null; + + return; + } + + $coord = array_filter($location->only(['lat', 'lng'])); + if (! $this->relationLoaded('location') || optional($this->location)->location !== $location->location) { + if (! $location->exists) { // don't fetch if new location persisted to the DB, just use it + $location = Location::firstOrCreate(['location' => $location->location], $coord); + } $this->location()->associate($location); } + + // save new coords if needed + if ($this->location) { + $this->location->fill($coord)->save(); + } } // ---- Accessors/Mutators ---- diff --git a/app/Models/Location.php b/app/Models/Location.php index 8627c248e5..89379a563d 100644 --- a/app/Models/Location.php +++ b/app/Models/Location.php @@ -81,10 +81,7 @@ class Location extends Model if (! $this->hasCoordinates() && $this->location) { $this->parseCoordinates(); - if (! $this->hasCoordinates() && - \LibreNMS\Config::get('geoloc.latlng', true) && - (! $this->id || $this->timestamp && $this->timestamp->diffInDays() > 2) - ) { + if (! $this->hasCoordinates() && \LibreNMS\Config::get('geoloc.latlng', true)) { $this->fetchCoordinates(); $this->updateTimestamps(); } @@ -98,7 +95,8 @@ class Location extends Model */ public function display() { - return trim(preg_replace($this->location_regex, '', $this->location)) ?: $this->location; + return (trim(preg_replace($this->location_regex, '', $this->location)) ?: $this->location) + . ($this->coordinatesValid() ? " [$this->lat, $this->lng]" : ''); } protected function parseCoordinates() @@ -122,8 +120,8 @@ class Location extends Model // ---- Query scopes ---- /** - * @param Builder $query - * @param User $user + * @param Builder $query + * @param User $user * @return Builder */ public function scopeHasAccess($query, $user) diff --git a/includes/definitions/discovery/airos-af-ltu.yaml b/includes/definitions/discovery/airos-af-ltu.yaml index 5499692d6a..b8096d0478 100644 --- a/includes/definitions/discovery/airos-af-ltu.yaml +++ b/includes/definitions/discovery/airos-af-ltu.yaml @@ -3,12 +3,13 @@ modules: os: hardware: UBNT-AFLTU-MIB::afLTUDevModel.0 version: UBNT-AFLTU-MIB::afLTUFirmwareVersion.0 + lat: UBNT-AFLTU-MIB::afLTUgpsLat.0 + long: UBNT-AFLTU-MIB::afLTUgpsLon.0 processors: data: - - oid: ubntHostCpuLoad + oid: afLTUCpuUsage num_oid: '.1.3.6.1.4.1.41112.1.10.1.3.6' - precision: 100 sensors: state: data: diff --git a/includes/definitions/discovery/airos.yaml b/includes/definitions/discovery/airos.yaml index f2907b7eef..322f4de182 100644 --- a/includes/definitions/discovery/airos.yaml +++ b/includes/definitions/discovery/airos.yaml @@ -1,5 +1,8 @@ mib: UBNT-AirMAX-MIB modules: + os: + lat: UBNT-AirMAX-MIB::ubntGpsLat.0 + long: UBNT-AirMAX-MIB::ubntGpsLon.0 processors: data: - diff --git a/includes/definitions/discovery/epmp.yaml b/includes/definitions/discovery/epmp.yaml index 5c841db211..05fd0e9117 100644 --- a/includes/definitions/discovery/epmp.yaml +++ b/includes/definitions/discovery/epmp.yaml @@ -1,5 +1,10 @@ mib: CAMBIUM-PMP80211-MIB modules: + os: + version: CAMBIUM-PMP80211-MIB::cambiumCurrentuImageVersion.0 + serial: CAMBIUM-PMP80211-MIB::cambiumEPMPMSN.0 + lat: CAMBIUM-PMP80211-MIB::cambiumDeviceLatitude.0 + long: CAMBIUM-PMP80211-MIB::cambiumDeviceLongitude.0 processors: data: - diff --git a/includes/functions.php b/includes/functions.php index 4efeed7d34..2b8fa1a75c 100644 --- a/includes/functions.php +++ b/includes/functions.php @@ -2234,7 +2234,7 @@ function get_db_schema() function get_device_oid_limit($device) { // device takes priority - if ($device['attribs']['snmp_max_oid'] > 0) { + if (! empty($device['attribs']['snmp_max_oid'])) { return $device['attribs']['snmp_max_oid']; } diff --git a/includes/polling/functions.inc.php b/includes/polling/functions.inc.php index 47191544ec..4eff2f8a78 100644 --- a/includes/polling/functions.inc.php +++ b/includes/polling/functions.inc.php @@ -159,7 +159,7 @@ function record_sensor_data($device, $all_sensors) foreach ($all_sensors as $sensor) { $class = ucfirst($sensor['sensor_class']); $unit = $supported_sensors[$class]; - $sensor_value = $sensor['new_value']; + $sensor_value = is_string($sensor['new_value']) ? floatval($sensor['new_value']) : $sensor['new_value']; $prev_sensor_value = $sensor['sensor_current']; if ($sensor_value == -32768 || is_nan($sensor_value)) { diff --git a/includes/polling/os/epmp.inc.php b/includes/polling/os/epmp.inc.php index 9464bd08d2..a122ab879f 100644 --- a/includes/polling/os/epmp.inc.php +++ b/includes/polling/os/epmp.inc.php @@ -28,8 +28,6 @@ if ($epmp_ap == 1) { } } -$version = snmp_get($device, 'cambiumCurrentuImageVersion.0', '-Oqv', 'CAMBIUM-PMP80211-MIB'); - $cambiumGPSNumTrackedSat = snmp_get($device, 'cambiumGPSNumTrackedSat.0', '-Ovqn', 'CAMBIUM-PMP80211-MIB'); $cambiumGPSNumVisibleSat = snmp_get($device, 'cambiumGPSNumVisibleSat.0', '-Ovqn', 'CAMBIUM-PMP80211-MIB'); if (is_numeric($cambiumGPSNumTrackedSat) && is_numeric($cambiumGPSNumVisibleSat)) { @@ -80,12 +78,12 @@ if (is_numeric($sysNetworkEntryAttempt) && is_numeric($sysNetworkEntrySuccess) & $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']; -$ulWLanTotalUsedFrameTimePerSecond = $multi_get_array[0]['CAMBIUM-PMP80211-MIB::ulWLanTotalUsedFrameTimePerSecond']; -$dlWLanTotalAvailableFrameTimePerSecond = $multi_get_array[0]['CAMBIUM-PMP80211-MIB::dlWLanTotalAvailableFrameTimePerSecond']; -$dlWLanTotalUsedFrameTimePerSecond = $multi_get_array[0]['CAMBIUM-PMP80211-MIB::dlWLanTotalUsedFrameTimePerSecond']; +$ulWLanTotalAvailableFrameTimePerSecond = $multi_get_array[0]['CAMBIUM-PMP80211-MIB::ulWLanTotalAvailableFrameTimePerSecond'] ?? null; +$ulWLanTotalUsedFrameTimePerSecond = $multi_get_array[0]['CAMBIUM-PMP80211-MIB::ulWLanTotalUsedFrameTimePerSecond'] ?? null; +$dlWLanTotalAvailableFrameTimePerSecond = $multi_get_array[0]['CAMBIUM-PMP80211-MIB::dlWLanTotalAvailableFrameTimePerSecond'] ?? null; +$dlWLanTotalUsedFrameTimePerSecond = $multi_get_array[0]['CAMBIUM-PMP80211-MIB::dlWLanTotalUsedFrameTimePerSecond'] ?? null; -if (is_numeric($ulWLanTotalAvailableFrameTimePerSecond) && is_numeric($ulWLanTotalUsedFrameTimePerSecond) && is_numeric($ulWLanTotalAvailableFrameTimePerSecond) && is_numeric($ulWLanTotalUsedFrameTimePerSecond)) { +if (is_numeric($ulWLanTotalAvailableFrameTimePerSecond) && is_numeric($ulWLanTotalUsedFrameTimePerSecond) && $ulWLanTotalAvailableFrameTimePerSecond && $ulWLanTotalUsedFrameTimePerSecond) { $ulWlanFrameUtilization = round((($ulWLanTotalUsedFrameTimePerSecond / $ulWLanTotalAvailableFrameTimePerSecond) * 100), 2); $dlWlanFrameUtilization = round((($dlWLanTotalUsedFrameTimePerSecond / $dlWLanTotalAvailableFrameTimePerSecond) * 100), 2); d_echo($dlWlanFrameUtilization); diff --git a/misc/discovery_schema.json b/misc/discovery_schema.json index 0b7a3ca251..b1c4e9de4b 100644 --- a/misc/discovery_schema.json +++ b/misc/discovery_schema.json @@ -28,9 +28,7 @@ "string" ] }, - "oid": { - "type": "string" - }, + "oid": {"$ref": "#/definitions/oid"}, "percent_used": { "type": "string" }, @@ -80,21 +78,13 @@ "os": { "type": "object", "properties": { - "version": { - "type": ["string", "array"] - }, - "hardware": { - "type": ["string", "array"] - }, - "features": { - "type": ["string", "array"] - }, - "serial": { - "type": ["string", "array"] - }, - "location": { - "type": ["string", "array"] - }, + "version": {"$ref": "#/definitions/oids"}, + "hardware": {"$ref": "#/definitions/oids"}, + "features": {"$ref": "#/definitions/oids"}, + "serial": {"$ref": "#/definitions/oids"}, + "lat": {"$ref": "#/definitions/oid"}, + "location": {"$ref": "#/definitions/oids"}, + "long": {"$ref": "#/definitions/oid"}, "sysDescr_regex": { "type": ["string", "array"] }, @@ -142,9 +132,7 @@ "items": { "type": "object", "properties": { - "oid": { - "type": "string" - }, + "oid": {"$ref": "#/definitions/oid"}, "num_oid": { "type": "string" }, @@ -160,9 +148,7 @@ "precision": { "type": "integer" }, - "value": { - "type": "string" - }, + "value": {"$ref": "#/definitions/oid"}, "type": { "type": "string" }, @@ -206,9 +192,7 @@ "items": { "type": "object", "properties": { - "oid": { - "type": "string" - }, + "oid": {"$ref": "#/definitions/oid"}, "value": { "type": "string" }, @@ -318,12 +302,7 @@ "items": { "type": "object", "properties": { - "oid": { - "type": "array", - "items": { - "type": "string" - } - }, + "oid": {"$ref": "#/definitions/oids"}, "snmp_flags": { "type": [ "string", @@ -370,15 +349,19 @@ "modules" ], "definitions": { + "oid": { + "type": "string" + }, + "oids": { + "type": ["string", "array"], + "items": { + "type": "string" + } + }, "pre-cache": { "type": "object", "properties": { - "oids": { - "type": "array", - "items": { - "type": "string" - } - }, + "oids": {"$ref": "#/definitions/oids"}, "snmp_flags": { "type": [ "string", diff --git a/tests/data/epmp.json b/tests/data/epmp.json index c21dcae9eb..a2b99383fa 100644 --- a/tests/data/epmp.json +++ b/tests/data/epmp.json @@ -21,21 +21,711 @@ "discovery": { "devices": [ { - "sysName": "", + "sysName": "", "sysObjectID": ".1.3.6.1.4.1.17713.21", "sysDescr": "Cambium ePMP", - "sysContact": null, - "version": null, + "sysContact": "", + "version": "4.5.6", "hardware": null, "features": null, "os": "epmp", "type": "wireless", - "serial": null, + "serial": "E2NF3572D8XT", "icon": "cambium.svg", - "location": null + "location": "" + } + ] + }, + "poller": { + "devices": [ + { + "sysName": "", + "sysObjectID": ".1.3.6.1.4.1.17713.21", + "sysDescr": "Cambium ePMP", + "sysContact": "", + "version": "4.5.6", + "hardware": "ePTP Master", + "features": null, + "os": "epmp", + "type": "wireless", + "serial": "E2NF3572D8XT", + "icon": "cambium.svg", + "location": "" + } + ] + } + }, + "ports": { + "discovery": { + "ports": [ + { + "port_descr_type": null, + "port_descr_descr": null, + "port_descr_circuit": null, + "port_descr_speed": null, + "port_descr_notes": null, + "ifDescr": "LAN interface 1", + "ifName": "LAN interface 1", + "portName": null, + "ifIndex": 1, + "ifSpeed": null, + "ifSpeed_prev": null, + "ifConnectorPresent": null, + "ifPromiscuousMode": null, + "ifHighSpeed": null, + "ifHighSpeed_prev": null, + "ifOperStatus": "up", + "ifOperStatus_prev": null, + "ifAdminStatus": null, + "ifAdminStatus_prev": null, + "ifDuplex": null, + "ifMtu": null, + "ifType": "ethernetCsmacd", + "ifAlias": "LAN interface 1", + "ifPhysAddress": null, + "ifHardType": null, + "ifLastChange": 0, + "ifVlan": "", + "ifTrunk": null, + "counter_in": null, + "counter_out": null, + "ignore": 0, + "disabled": 0, + "detailed": 0, + "deleted": 0, + "pagpOperationMode": null, + "pagpPortState": null, + "pagpPartnerDeviceId": null, + "pagpPartnerLearnMethod": null, + "pagpPartnerIfIndex": null, + "pagpPartnerGroupIfIndex": null, + "pagpPartnerDeviceName": null, + "pagpEthcOperationMode": null, + "pagpDeviceId": null, + "pagpGroupIfIndex": null, + "ifInUcastPkts": null, + "ifInUcastPkts_prev": null, + "ifInUcastPkts_delta": null, + "ifInUcastPkts_rate": null, + "ifOutUcastPkts": null, + "ifOutUcastPkts_prev": null, + "ifOutUcastPkts_delta": null, + "ifOutUcastPkts_rate": null, + "ifInErrors": null, + "ifInErrors_prev": null, + "ifInErrors_delta": null, + "ifInErrors_rate": null, + "ifOutErrors": null, + "ifOutErrors_prev": null, + "ifOutErrors_delta": null, + "ifOutErrors_rate": null, + "ifInOctets": null, + "ifInOctets_prev": null, + "ifInOctets_delta": null, + "ifInOctets_rate": null, + "ifOutOctets": null, + "ifOutOctets_prev": null, + "ifOutOctets_delta": null, + "ifOutOctets_rate": null, + "poll_prev": null, + "ifInNUcastPkts": null, + "ifInNUcastPkts_prev": null, + "ifInNUcastPkts_delta": null, + "ifInNUcastPkts_rate": null, + "ifOutNUcastPkts": null, + "ifOutNUcastPkts_prev": null, + "ifOutNUcastPkts_delta": null, + "ifOutNUcastPkts_rate": null, + "ifInDiscards": null, + "ifInDiscards_prev": null, + "ifInDiscards_delta": null, + "ifInDiscards_rate": null, + "ifOutDiscards": null, + "ifOutDiscards_prev": null, + "ifOutDiscards_delta": null, + "ifOutDiscards_rate": null, + "ifInUnknownProtos": null, + "ifInUnknownProtos_prev": null, + "ifInUnknownProtos_delta": null, + "ifInUnknownProtos_rate": null, + "ifInBroadcastPkts": null, + "ifInBroadcastPkts_prev": null, + "ifInBroadcastPkts_delta": null, + "ifInBroadcastPkts_rate": null, + "ifOutBroadcastPkts": null, + "ifOutBroadcastPkts_prev": null, + "ifOutBroadcastPkts_delta": null, + "ifOutBroadcastPkts_rate": null, + "ifInMulticastPkts": null, + "ifInMulticastPkts_prev": null, + "ifInMulticastPkts_delta": null, + "ifInMulticastPkts_rate": null, + "ifOutMulticastPkts": null, + "ifOutMulticastPkts_prev": null, + "ifOutMulticastPkts_delta": null, + "ifOutMulticastPkts_rate": null + }, + { + "port_descr_type": null, + "port_descr_descr": null, + "port_descr_circuit": null, + "port_descr_speed": null, + "port_descr_notes": null, + "ifDescr": "WLAN interface", + "ifName": "WLAN interface", + "portName": null, + "ifIndex": 2, + "ifSpeed": null, + "ifSpeed_prev": null, + "ifConnectorPresent": null, + "ifPromiscuousMode": null, + "ifHighSpeed": null, + "ifHighSpeed_prev": null, + "ifOperStatus": "up", + "ifOperStatus_prev": null, + "ifAdminStatus": null, + "ifAdminStatus_prev": null, + "ifDuplex": null, + "ifMtu": null, + "ifType": "ieee80211", + "ifAlias": "WLAN interface", + "ifPhysAddress": null, + "ifHardType": null, + "ifLastChange": 0, + "ifVlan": "", + "ifTrunk": null, + "counter_in": null, + "counter_out": null, + "ignore": 0, + "disabled": 0, + "detailed": 0, + "deleted": 0, + "pagpOperationMode": null, + "pagpPortState": null, + "pagpPartnerDeviceId": null, + "pagpPartnerLearnMethod": null, + "pagpPartnerIfIndex": null, + "pagpPartnerGroupIfIndex": null, + "pagpPartnerDeviceName": null, + "pagpEthcOperationMode": null, + "pagpDeviceId": null, + "pagpGroupIfIndex": null, + "ifInUcastPkts": null, + "ifInUcastPkts_prev": null, + "ifInUcastPkts_delta": null, + "ifInUcastPkts_rate": null, + "ifOutUcastPkts": null, + "ifOutUcastPkts_prev": null, + "ifOutUcastPkts_delta": null, + "ifOutUcastPkts_rate": null, + "ifInErrors": null, + "ifInErrors_prev": null, + "ifInErrors_delta": null, + "ifInErrors_rate": null, + "ifOutErrors": null, + "ifOutErrors_prev": null, + "ifOutErrors_delta": null, + "ifOutErrors_rate": null, + "ifInOctets": null, + "ifInOctets_prev": null, + "ifInOctets_delta": null, + "ifInOctets_rate": null, + "ifOutOctets": null, + "ifOutOctets_prev": null, + "ifOutOctets_delta": null, + "ifOutOctets_rate": null, + "poll_prev": null, + "ifInNUcastPkts": null, + "ifInNUcastPkts_prev": null, + "ifInNUcastPkts_delta": null, + "ifInNUcastPkts_rate": null, + "ifOutNUcastPkts": null, + "ifOutNUcastPkts_prev": null, + "ifOutNUcastPkts_delta": null, + "ifOutNUcastPkts_rate": null, + "ifInDiscards": null, + "ifInDiscards_prev": null, + "ifInDiscards_delta": null, + "ifInDiscards_rate": null, + "ifOutDiscards": null, + "ifOutDiscards_prev": null, + "ifOutDiscards_delta": null, + "ifOutDiscards_rate": null, + "ifInUnknownProtos": null, + "ifInUnknownProtos_prev": null, + "ifInUnknownProtos_delta": null, + "ifInUnknownProtos_rate": null, + "ifInBroadcastPkts": null, + "ifInBroadcastPkts_prev": null, + "ifInBroadcastPkts_delta": null, + "ifInBroadcastPkts_rate": null, + "ifOutBroadcastPkts": null, + "ifOutBroadcastPkts_prev": null, + "ifOutBroadcastPkts_delta": null, + "ifOutBroadcastPkts_rate": null, + "ifInMulticastPkts": null, + "ifInMulticastPkts_prev": null, + "ifInMulticastPkts_delta": null, + "ifInMulticastPkts_rate": null, + "ifOutMulticastPkts": null, + "ifOutMulticastPkts_prev": null, + "ifOutMulticastPkts_delta": null, + "ifOutMulticastPkts_rate": null + } + ] + }, + "poller": { + "ports": [ + { + "port_descr_type": null, + "port_descr_descr": null, + "port_descr_circuit": null, + "port_descr_speed": null, + "port_descr_notes": null, + "ifDescr": "LAN interface 1", + "ifName": "LAN interface 1", + "portName": null, + "ifIndex": 1, + "ifSpeed": 1000000000000000, + "ifSpeed_prev": null, + "ifConnectorPresent": "true", + "ifPromiscuousMode": "false", + "ifHighSpeed": 1000000000, + "ifHighSpeed_prev": null, + "ifOperStatus": "up", + "ifOperStatus_prev": "up", + "ifAdminStatus": "up", + "ifAdminStatus_prev": null, + "ifDuplex": null, + "ifMtu": 1500, + "ifType": "ethernetCsmacd", + "ifAlias": "LAN interface 1", + "ifPhysAddress": "000456ab43ba", + "ifHardType": null, + "ifLastChange": 4199835466, + "ifVlan": "", + "ifTrunk": null, + "counter_in": null, + "counter_out": null, + "ignore": 0, + "disabled": 0, + "detailed": 0, + "deleted": 0, + "pagpOperationMode": null, + "pagpPortState": null, + "pagpPartnerDeviceId": null, + "pagpPartnerLearnMethod": null, + "pagpPartnerIfIndex": null, + "pagpPartnerGroupIfIndex": null, + "pagpPartnerDeviceName": null, + "pagpEthcOperationMode": null, + "pagpDeviceId": null, + "pagpGroupIfIndex": null, + "ifInUcastPkts": 2467620304, + "ifInUcastPkts_prev": 0, + "ifInUcastPkts_delta": null, + "ifInUcastPkts_rate": null, + "ifOutUcastPkts": 1306793183, + "ifOutUcastPkts_prev": 0, + "ifOutUcastPkts_delta": null, + "ifOutUcastPkts_rate": null, + "ifInErrors": 0, + "ifInErrors_prev": 0, + "ifInErrors_delta": null, + "ifInErrors_rate": null, + "ifOutErrors": 0, + "ifOutErrors_prev": 0, + "ifOutErrors_delta": null, + "ifOutErrors_rate": null, + "ifInOctets": 3377931056550, + "ifInOctets_prev": 0, + "ifInOctets_delta": null, + "ifInOctets_rate": null, + "ifOutOctets": 258804512221, + "ifOutOctets_prev": 0, + "ifOutOctets_delta": null, + "ifOutOctets_rate": null, + "poll_prev": null, + "ifInNUcastPkts": 0, + "ifInNUcastPkts_prev": 0, + "ifInNUcastPkts_delta": null, + "ifInNUcastPkts_rate": null, + "ifOutNUcastPkts": 0, + "ifOutNUcastPkts_prev": 0, + "ifOutNUcastPkts_delta": null, + "ifOutNUcastPkts_rate": null, + "ifInDiscards": 0, + "ifInDiscards_prev": 0, + "ifInDiscards_delta": null, + "ifInDiscards_rate": null, + "ifOutDiscards": 0, + "ifOutDiscards_prev": 0, + "ifOutDiscards_delta": null, + "ifOutDiscards_rate": null, + "ifInUnknownProtos": 0, + "ifInUnknownProtos_prev": 0, + "ifInUnknownProtos_delta": null, + "ifInUnknownProtos_rate": null, + "ifInBroadcastPkts": 63839, + "ifInBroadcastPkts_prev": 0, + "ifInBroadcastPkts_delta": null, + "ifInBroadcastPkts_rate": null, + "ifOutBroadcastPkts": 128026, + "ifOutBroadcastPkts_prev": 0, + "ifOutBroadcastPkts_delta": null, + "ifOutBroadcastPkts_rate": null, + "ifInMulticastPkts": 1055750, + "ifInMulticastPkts_prev": 0, + "ifInMulticastPkts_delta": null, + "ifInMulticastPkts_rate": null, + "ifOutMulticastPkts": 96003, + "ifOutMulticastPkts_prev": 0, + "ifOutMulticastPkts_delta": null, + "ifOutMulticastPkts_rate": null + }, + { + "port_descr_type": null, + "port_descr_descr": null, + "port_descr_circuit": null, + "port_descr_speed": null, + "port_descr_notes": null, + "ifDescr": "WLAN interface", + "ifName": "WLAN interface", + "portName": null, + "ifIndex": 2, + "ifSpeed": 220000000000000, + "ifSpeed_prev": null, + "ifConnectorPresent": "true", + "ifPromiscuousMode": "false", + "ifHighSpeed": 220000000, + "ifHighSpeed_prev": null, + "ifOperStatus": "up", + "ifOperStatus_prev": "up", + "ifAdminStatus": "up", + "ifAdminStatus_prev": null, + "ifDuplex": null, + "ifMtu": 1708, + "ifType": "ieee80211", + "ifAlias": "WLAN interface", + "ifPhysAddress": "000456ab43ba", + "ifHardType": null, + "ifLastChange": 0, + "ifVlan": "", + "ifTrunk": null, + "counter_in": null, + "counter_out": null, + "ignore": 0, + "disabled": 0, + "detailed": 0, + "deleted": 0, + "pagpOperationMode": null, + "pagpPortState": null, + "pagpPartnerDeviceId": null, + "pagpPartnerLearnMethod": null, + "pagpPartnerIfIndex": null, + "pagpPartnerGroupIfIndex": null, + "pagpPartnerDeviceName": null, + "pagpEthcOperationMode": null, + "pagpDeviceId": null, + "pagpGroupIfIndex": null, + "ifInUcastPkts": 1310032403, + "ifInUcastPkts_prev": 0, + "ifInUcastPkts_delta": null, + "ifInUcastPkts_rate": null, + "ifOutUcastPkts": 2467169462, + "ifOutUcastPkts_prev": 0, + "ifOutUcastPkts_delta": null, + "ifOutUcastPkts_rate": null, + "ifInErrors": 0, + "ifInErrors_prev": 0, + "ifInErrors_delta": null, + "ifInErrors_rate": null, + "ifOutErrors": 34880, + "ifOutErrors_prev": 0, + "ifOutErrors_delta": null, + "ifOutErrors_rate": null, + "ifInOctets": 271761841907, + "ifInOctets_prev": 0, + "ifInOctets_delta": null, + "ifInOctets_rate": null, + "ifOutOctets": 3382715573957, + "ifOutOctets_prev": 0, + "ifOutOctets_delta": null, + "ifOutOctets_rate": null, + "poll_prev": null, + "ifInNUcastPkts": 0, + "ifInNUcastPkts_prev": 0, + "ifInNUcastPkts_delta": null, + "ifInNUcastPkts_rate": null, + "ifOutNUcastPkts": 0, + "ifOutNUcastPkts_prev": 0, + "ifOutNUcastPkts_delta": null, + "ifOutNUcastPkts_rate": null, + "ifInDiscards": 0, + "ifInDiscards_prev": 0, + "ifInDiscards_delta": null, + "ifInDiscards_rate": null, + "ifOutDiscards": 31460, + "ifOutDiscards_prev": 0, + "ifOutDiscards_delta": null, + "ifOutDiscards_rate": null, + "ifInUnknownProtos": 0, + "ifInUnknownProtos_prev": 0, + "ifInUnknownProtos_delta": null, + "ifInUnknownProtos_rate": null, + "ifInBroadcastPkts": 64163, + "ifInBroadcastPkts_prev": 0, + "ifInBroadcastPkts_delta": null, + "ifInBroadcastPkts_rate": null, + "ifOutBroadcastPkts": 95864, + "ifOutBroadcastPkts_prev": 0, + "ifOutBroadcastPkts_delta": null, + "ifOutBroadcastPkts_rate": null, + "ifInMulticastPkts": 32093, + "ifInMulticastPkts_prev": 0, + "ifInMulticastPkts_delta": null, + "ifInMulticastPkts_rate": null, + "ifOutMulticastPkts": 1023726, + "ifOutMulticastPkts_prev": 0, + "ifOutMulticastPkts_delta": null, + "ifOutMulticastPkts_rate": null + } + ] + } + }, + "sensors": { + "discovery": { + "sensors": [ + { + "sensor_deleted": 0, + "sensor_class": "count", + "poller_type": "snmp", + "sensor_oid": " .1.3.6.1.4.1.17713.21.2.1.36.0", + "sensor_index": "0", + "sensor_type": "epmp", + "sensor_descr": "DFS Detected Count", + "group": null, + "sensor_divisor": 1, + "sensor_multiplier": 1, + "sensor_current": 0, + "sensor_limit": null, + "sensor_limit_warn": null, + "sensor_limit_low": null, + "sensor_limit_low_warn": null, + "sensor_alert": 1, + "sensor_custom": "No", + "entPhysicalIndex": null, + "entPhysicalIndex_measured": null, + "sensor_prev": null, + "user_func": null, + "state_name": null + }, + { + "sensor_deleted": 0, + "sensor_class": "state", + "poller_type": "snmp", + "sensor_oid": ".1.3.6.1.4.1.17713.21.1.1.6.0", + "sensor_index": "0", + "sensor_type": "cambiumDFSStatus", + "sensor_descr": "DFS Status", + "group": null, + "sensor_divisor": 1, + "sensor_multiplier": 1, + "sensor_current": 1, + "sensor_limit": null, + "sensor_limit_warn": null, + "sensor_limit_low": null, + "sensor_limit_low_warn": null, + "sensor_alert": 1, + "sensor_custom": "No", + "entPhysicalIndex": null, + "entPhysicalIndex_measured": null, + "sensor_prev": null, + "user_func": null, + "state_name": "cambiumDFSStatus" + } + ], + "state_indexes": [ + { + "state_name": "cambiumDFSStatus", + "state_descr": "N/A", + "state_draw_graph": 1, + "state_value": 1, + "state_generic_value": 1 + }, + { + "state_name": "cambiumDFSStatus", + "state_descr": "Channel Availability Check", + "state_draw_graph": 1, + "state_value": 2, + "state_generic_value": 1 + }, + { + "state_name": "cambiumDFSStatus", + "state_descr": "In-Service", + "state_draw_graph": 1, + "state_value": 3, + "state_generic_value": 0 + }, + { + "state_name": "cambiumDFSStatus", + "state_descr": "Radar Signal Detected", + "state_draw_graph": 1, + "state_value": 4, + "state_generic_value": 2 + }, + { + "state_name": "cambiumDFSStatus", + "state_descr": "In-Service Monitoring at Alternative Channel", + "state_draw_graph": 1, + "state_value": 5, + "state_generic_value": 0 + }, + { + "state_name": "cambiumDFSStatus", + "state_descr": "System Not In Service due to DFS", + "state_draw_graph": 1, + "state_value": 6, + "state_generic_value": 2 } ] }, "poller": "matches discovery" + }, + "wireless": { + "discovery": { + "wireless_sensors": [ + { + "sensor_deleted": 0, + "sensor_class": "clients", + "sensor_index": "0", + "sensor_type": "epmp", + "sensor_descr": "Client Count", + "sensor_divisor": 1, + "sensor_multiplier": 1, + "sensor_aggregator": "sum", + "sensor_current": 1, + "sensor_prev": null, + "sensor_limit": null, + "sensor_limit_warn": null, + "sensor_limit_low": null, + "sensor_limit_low_warn": null, + "sensor_alert": 1, + "sensor_custom": "No", + "entPhysicalIndex": null, + "entPhysicalIndex_measured": null, + "sensor_oids": "[\".1.3.6.1.4.1.17713.21.1.2.10.0\"]" + }, + { + "sensor_deleted": 0, + "sensor_class": "snr", + "sensor_index": "0", + "sensor_type": "epmp", + "sensor_descr": "Cambium ePMP SNR", + "sensor_divisor": 1, + "sensor_multiplier": 1, + "sensor_aggregator": "sum", + "sensor_current": 34, + "sensor_prev": null, + "sensor_limit": null, + "sensor_limit_warn": null, + "sensor_limit_low": null, + "sensor_limit_low_warn": null, + "sensor_alert": 1, + "sensor_custom": "No", + "entPhysicalIndex": null, + "entPhysicalIndex_measured": null, + "sensor_oids": "[\".1.3.6.1.4.1.17713.21.1.2.18.0\"]" + }, + { + "sensor_deleted": 0, + "sensor_class": "frequency", + "sensor_index": "0", + "sensor_type": "epmp", + "sensor_descr": "Cambium ePMP Frequency", + "sensor_divisor": 1, + "sensor_multiplier": 1, + "sensor_aggregator": "sum", + "sensor_current": 5210, + "sensor_prev": null, + "sensor_limit": null, + "sensor_limit_warn": null, + "sensor_limit_low": null, + "sensor_limit_low_warn": null, + "sensor_alert": 1, + "sensor_custom": "No", + "entPhysicalIndex": null, + "entPhysicalIndex_measured": null, + "sensor_oids": "[\".1.3.6.1.4.1.17713.21.1.2.1.0\"]" + } + ] + }, + "poller": { + "wireless_sensors": [ + { + "sensor_deleted": 0, + "sensor_class": "clients", + "sensor_index": "0", + "sensor_type": "epmp", + "sensor_descr": "Client Count", + "sensor_divisor": 1, + "sensor_multiplier": 1, + "sensor_aggregator": "sum", + "sensor_current": 1, + "sensor_prev": 1, + "sensor_limit": null, + "sensor_limit_warn": null, + "sensor_limit_low": null, + "sensor_limit_low_warn": null, + "sensor_alert": 1, + "sensor_custom": "No", + "entPhysicalIndex": null, + "entPhysicalIndex_measured": null, + "sensor_oids": "[\".1.3.6.1.4.1.17713.21.1.2.10.0\"]" + }, + { + "sensor_deleted": 0, + "sensor_class": "snr", + "sensor_index": "0", + "sensor_type": "epmp", + "sensor_descr": "Cambium ePMP SNR", + "sensor_divisor": 1, + "sensor_multiplier": 1, + "sensor_aggregator": "sum", + "sensor_current": 34, + "sensor_prev": 34, + "sensor_limit": null, + "sensor_limit_warn": null, + "sensor_limit_low": null, + "sensor_limit_low_warn": null, + "sensor_alert": 1, + "sensor_custom": "No", + "entPhysicalIndex": null, + "entPhysicalIndex_measured": null, + "sensor_oids": "[\".1.3.6.1.4.1.17713.21.1.2.18.0\"]" + }, + { + "sensor_deleted": 0, + "sensor_class": "frequency", + "sensor_index": "0", + "sensor_type": "epmp", + "sensor_descr": "Cambium ePMP Frequency", + "sensor_divisor": 1, + "sensor_multiplier": 1, + "sensor_aggregator": "sum", + "sensor_current": 5210, + "sensor_prev": 5210, + "sensor_limit": null, + "sensor_limit_warn": null, + "sensor_limit_low": null, + "sensor_limit_low_warn": null, + "sensor_alert": 1, + "sensor_custom": "No", + "entPhysicalIndex": null, + "entPhysicalIndex_measured": null, + "sensor_oids": "[\".1.3.6.1.4.1.17713.21.1.2.1.0\"]" + } + ] + } } } diff --git a/tests/snmpsim/epmp.snmprec b/tests/snmpsim/epmp.snmprec index 4ad0d2dddd..87e064407c 100644 --- a/tests/snmpsim/epmp.snmprec +++ b/tests/snmpsim/epmp.snmprec @@ -1,3 +1,83 @@ 1.3.6.1.2.1.1.1.0|4|Cambium ePMP 1.3.6.1.2.1.1.2.0|6|1.3.6.1.4.1.17713.21 +1.3.6.1.2.1.1.3.0|67|192014368 +1.3.6.1.2.1.1.4.0|4| +1.3.6.1.2.1.1.5.0|4| +1.3.6.1.2.1.1.6.0|4| +1.3.6.1.2.1.2.2.1.2.1|4|LAN interface 1 +1.3.6.1.2.1.2.2.1.2.2|4|WLAN interface +1.3.6.1.2.1.2.2.1.3.1|2|6 +1.3.6.1.2.1.2.2.1.3.2|2|71 +1.3.6.1.2.1.2.2.1.4.1|2|1500 +1.3.6.1.2.1.2.2.1.4.2|2|1708 +1.3.6.1.2.1.2.2.1.6.1|4x|000456AB43BA +1.3.6.1.2.1.2.2.1.6.2|4x|000456AB43BA +1.3.6.1.2.1.2.2.1.7.1|2|1 +1.3.6.1.2.1.2.2.1.7.2|2|1 +1.3.6.1.2.1.2.2.1.8.1|2|1 +1.3.6.1.2.1.2.2.1.8.2|2|1 +1.3.6.1.2.1.2.2.1.9.1|67|4199835466 +1.3.6.1.2.1.2.2.1.9.2|67|0 +1.3.6.1.2.1.2.2.1.13.1|65|0 +1.3.6.1.2.1.2.2.1.13.2|65|0 +1.3.6.1.2.1.2.2.1.14.1|65|0 +1.3.6.1.2.1.2.2.1.14.2|65|0 +1.3.6.1.2.1.2.2.1.19.1|65|0 +1.3.6.1.2.1.2.2.1.19.2|65|31460 +1.3.6.1.2.1.2.2.1.20.1|65|0 +1.3.6.1.2.1.2.2.1.20.2|65|34880 +1.3.6.1.2.1.31.1.1.1.1.1|4|LAN interface 1 +1.3.6.1.2.1.31.1.1.1.1.2|4|WLAN interface +1.3.6.1.2.1.31.1.1.1.2.1|65|1055750 +1.3.6.1.2.1.31.1.1.1.2.2|65|32093 +1.3.6.1.2.1.31.1.1.1.3.1|65|63839 +1.3.6.1.2.1.31.1.1.1.3.2|65|64163 +1.3.6.1.2.1.31.1.1.1.4.1|65|96003 +1.3.6.1.2.1.31.1.1.1.4.2|65|1023726 +1.3.6.1.2.1.31.1.1.1.5.1|65|128026 +1.3.6.1.2.1.31.1.1.1.5.2|65|95864 +1.3.6.1.2.1.31.1.1.1.6.1|70|3377931056550 +1.3.6.1.2.1.31.1.1.1.6.2|70|271761841907 +1.3.6.1.2.1.31.1.1.1.7.1|70|2467620304 +1.3.6.1.2.1.31.1.1.1.7.2|70|1310032403 +1.3.6.1.2.1.31.1.1.1.8.1|70|1055750 +1.3.6.1.2.1.31.1.1.1.8.2|70|32093 +1.3.6.1.2.1.31.1.1.1.9.1|70|63839 +1.3.6.1.2.1.31.1.1.1.9.2|70|64163 +1.3.6.1.2.1.31.1.1.1.10.1|70|258804512221 +1.3.6.1.2.1.31.1.1.1.10.2|70|3382715573957 +1.3.6.1.2.1.31.1.1.1.11.1|70|1306793183 +1.3.6.1.2.1.31.1.1.1.11.2|70|2467169462 +1.3.6.1.2.1.31.1.1.1.12.1|70|96003 +1.3.6.1.2.1.31.1.1.1.12.2|70|1023726 +1.3.6.1.2.1.31.1.1.1.13.1|70|128026 +1.3.6.1.2.1.31.1.1.1.13.2|70|95864 +1.3.6.1.2.1.31.1.1.1.15.1|66|1000000000 +1.3.6.1.2.1.31.1.1.1.15.2|66|220000000 +1.3.6.1.2.1.31.1.1.1.16.1|2|2 +1.3.6.1.2.1.31.1.1.1.16.2|2|2 +1.3.6.1.2.1.31.1.1.1.17.1|2|1 +1.3.6.1.2.1.31.1.1.1.17.2|2|1 +1.3.6.1.2.1.31.1.1.1.18.1|4| +1.3.6.1.2.1.31.1.1.1.18.2|4| +1.3.6.1.2.1.31.1.1.1.19.1|67|0 +1.3.6.1.2.1.31.1.1.1.19.2|67|0 +1.3.6.1.4.1.17713.21.1.1.6.0|2|1 +1.3.6.1.4.1.17713.21.1.1.17.0|4|4.5.6 +1.3.6.1.4.1.17713.21.1.1.18.0|4|63.1119936 +1.3.6.1.4.1.17713.21.1.1.19.0|4|-84.67365530000001 +1.3.6.1.4.1.17713.21.1.1.31.0|4|E2NF3572D8XT +1.3.6.1.4.1.17713.21.1.1.33.0|2|5 +1.3.6.1.4.1.17713.21.1.2.1.0|2|5210 +1.3.6.1.4.1.17713.21.1.2.10.0|2|1 +1.3.6.1.4.1.17713.21.1.2.18.0|2|34 +1.3.6.1.4.1.17713.21.2.1.33.0|65|1 +1.3.6.1.4.1.17713.21.2.1.34.0|65|1 +1.3.6.1.4.1.17713.21.2.1.35.0|65|0 +1.3.6.1.4.1.17713.21.2.1.36.0|65|0 +1.3.6.1.4.1.17713.21.2.1.51.0|2|0 +1.3.6.1.4.1.17713.21.2.1.52.0|2|0 +1.3.6.1.4.1.17713.21.2.1.53.0|2|0 +1.3.6.1.4.1.17713.21.2.1.54.0|2|0 1.3.6.1.4.1.17713.21.2.1.64.0|65|420 +1.3.6.1.4.1.17713.21.3.8.2.1.0|2|1