diff --git a/front/plugins/snmp_discovery/README.md b/front/plugins/snmp_discovery/README.md index fc960e77..1d09ecdc 100755 --- a/front/plugins/snmp_discovery/README.md +++ b/front/plugins/snmp_discovery/README.md @@ -6,10 +6,10 @@ A plugin for importing devices from an SNMP enabled router or switch. Specify the following settings in the Settings section of PiAlert: -- `SNMPDSC_routers` - A list of IP addresses of roputers/switches with SNMP turned on. +- `SNMPDSC_routers` - A list of `snmpwalk` commands to execute against IP addresses of roputers/switches with SNMP turned on. For example: `snmpwalk -v 2c -c public -OXsq 192.168.1.1 .1.3.6.1.2.1.3.1.1.2` ### Notes -- Executing the `snmpwalk -v 2c -c public -OXsq .1.3.6.1.2.1.3.1.1.2` command. -- Only IPv4 supported. -- Expected output in format `iso.3.6.1.2.1.3.1.1.2.3.1.192.168.1.2 "6C 6C 6C 6C 6C 6C "`. \ No newline at end of file +- Authentication is not supported. +- Only IPv4 supported. +- Expected output (ingestion) in format `iso.3.6.1.2.1.3.1.1.2.3.1.192.168.1.2 "6C 6C 6C 6C 6C 6C "`. \ No newline at end of file diff --git a/front/plugins/snmp_discovery/config.json b/front/plugins/snmp_discovery/config.json index 56a3ad77..4f888894 100755 --- a/front/plugins/snmp_discovery/config.json +++ b/front/plugins/snmp_discovery/config.json @@ -232,7 +232,7 @@ { "function": "CMD", "type": "text", - "default_value":"python3 /home/pi/pialert/front/plugins/snmp_discovery/script.py routers={routers} ", + "default_value":"python3 /home/pi/pialert/front/plugins/snmp_discovery/script.py routers='{routers}' ", "options": [], "localized": ["name", "description"], "name" : [{ @@ -247,7 +247,7 @@ { "function": "routers", "type": "list", - "default_value":["192.168.1.1"], + "default_value":["snmpwalk -v 2c -c public -OXsq 192.168.1.1 .1.3.6.1.2.1.3.1.1.2"], "options": [], "localized": ["name", "description"], "name" : [{ @@ -256,7 +256,7 @@ }], "description": [{ "language_code":"en_us", - "string" : "The router IP addresses you want to connect to. SNMP has to be enabled on the target devices." + "string" : "A list of snmpwalk commands to execute against IP addresses of roputers/switches with SNMP turned on.

Example:
snmpwalk -v 2c -c public -OXsq 192.168.1.1 .1.3.6.1.2.1.3.1.1.2

Only IPv4 supported. Authentication is not supported." }] }, { diff --git a/front/plugins/snmp_discovery/script.py b/front/plugins/snmp_discovery/script.py index 09ce968d..5529d932 100755 --- a/front/plugins/snmp_discovery/script.py +++ b/front/plugins/snmp_discovery/script.py @@ -1,7 +1,7 @@ #!/usr/bin/env python # Example call -# python3 /home/pi/pialert/front/plugins/snmp_discovery/script.py routers=192.168.1.1 +# python3 /home/pi/pialert/front/plugins/snmp_discovery/script.py routers='snmpwalk -v 2c -c public -OXsq 192.168.1.1 .1.3.6.1.2.1.3.1.1.2' from __future__ import unicode_literals from time import sleep, time, strftime @@ -47,7 +47,7 @@ def main(): if values.routers: - ROUTERS = values.routers.split('=')[1] + ROUTERS = values.routers.split('=')[1].replace('\'','') newEntries = get_entries(newEntries) @@ -73,7 +73,8 @@ def get_entries(newEntries): timeoutSec = 10 - snmpwalkArgs = ['snmpwalk', '-v', '2c', '-c', 'public', '-OXsq', router, '.1.3.6.1.2.1.3.1.1.2'] + # snmpwalkArgs = ['snmpwalk', '-v', '2c', '-c', 'public', '-OXsq', router, '.1.3.6.1.2.1.3.1.1.2'] + snmpwalkArgs = router.split(' ') # Execute N probes and insert in list probes = 1 # N probes