SNMP walk attempt at #258

This commit is contained in:
Jokob-sk
2023-06-24 06:55:24 +10:00
parent f430587965
commit a318a15cad

View File

@@ -90,23 +90,25 @@ def get_entries(newEntries):
with open(log_file, 'a') as run_logfile: with open(log_file, 'a') as run_logfile:
for line in newLines: for line in newLines:
# debug # debug
run_logfile.write(line) run_logfile.write(line)
tmpSplt = line.split('"') tmpSplt = line.split('"')
if len(tmpSplt) == 3: if len(tmpSplt) == 3:
ipStr = tmpSplt[0].split('.')[-4:] # Get the last 4 elements to extract the IP
macStr = tmpSplt[1].strip().split(' ') # Remove leading/trailing spaces from MAC
ipStr = tmpSplt[0].split('.') # contains IP if 'iso.' in line and len(ipStr) == 4:
macAddress = ':'.join(macStr)
ipAddress = '.'.join(ipStr)
macStr = tmpSplt[1].split(' ') # contains MAC
if 'iso.' in line and len(ipStr) == 16:
tmpEntry = plugin_object_class( tmpEntry = plugin_object_class(
f'{macStr[0]}:{macStr[1]}:{macStr[2]}:{macStr[3]}:{macStr[4]}:{macStr[5]}', macAddress,
f'{ipStr[12]}.{ipStr[13]}.{ipStr[14]}.{ipStr[15]}'.strip(), ipAddress,
watched1='(unknown)', watched1='(unknown)',
watched2=snmpwalkArgs[6], # router IP watched2=snmpwalkArgs[6], # router IP
extra=line extra=line
) )
newEntries.append(tmpEntry) newEntries.append(tmpEntry)