NSLOOKUP v0.1.5
This commit is contained in:
2
.github/workflows/update_sponsors_table.yml
vendored
2
.github/workflows/update_sponsors_table.yml
vendored
@@ -2,7 +2,7 @@ name: 🤖Automation - Update Sponsors Table
|
|||||||
|
|
||||||
on:
|
on:
|
||||||
schedule:
|
schedule:
|
||||||
- cron: '47 20 * * *' # Set your preferred schedule (UTC)
|
- cron: '30 11 * * *' # Set your preferred schedule (UTC)
|
||||||
|
|
||||||
jobs:
|
jobs:
|
||||||
update-table:
|
update-table:
|
||||||
|
|||||||
@@ -3,7 +3,7 @@ import subprocess
|
|||||||
|
|
||||||
import conf
|
import conf
|
||||||
import re
|
import re
|
||||||
from helper import timeNowTZ, get_setting, get_setting_value,resolve_device_name_dig, resolve_device_name_pholus, check_IP_format
|
from helper import timeNowTZ, get_setting, get_setting_value,resolve_device_name_dig, resolve_device_name_pholus, get_device_name_nslookup, check_IP_format
|
||||||
from logger import mylog, print_log
|
from logger import mylog, print_log
|
||||||
from const import vendorsPath
|
from const import vendorsPath
|
||||||
|
|
||||||
@@ -286,6 +286,7 @@ def update_devices_names (db):
|
|||||||
notFound = 0
|
notFound = 0
|
||||||
|
|
||||||
foundDig = 0
|
foundDig = 0
|
||||||
|
foundNsLookup = 0
|
||||||
foundPholus = 0
|
foundPholus = 0
|
||||||
|
|
||||||
# BUGFIX #97 - Updating name of Devices w/o IP
|
# BUGFIX #97 - Updating name of Devices w/o IP
|
||||||
@@ -318,6 +319,13 @@ def update_devices_names (db):
|
|||||||
if newName != nameNotFound:
|
if newName != nameNotFound:
|
||||||
foundDig += 1
|
foundDig += 1
|
||||||
|
|
||||||
|
# Resolve device name with NSLOOKUP plugin data
|
||||||
|
if newName == nameNotFound:
|
||||||
|
newName = get_device_name_nslookup(db, device['dev_MAC'], device['dev_LastIP'])
|
||||||
|
|
||||||
|
if newName != nameNotFound:
|
||||||
|
foundNsLookup += 1
|
||||||
|
|
||||||
# Resolve with Pholus
|
# Resolve with Pholus
|
||||||
if newName == nameNotFound:
|
if newName == nameNotFound:
|
||||||
# Try MAC matching
|
# Try MAC matching
|
||||||
@@ -341,7 +349,7 @@ def update_devices_names (db):
|
|||||||
recordsToUpdate.append ([newName, device['dev_MAC']])
|
recordsToUpdate.append ([newName, device['dev_MAC']])
|
||||||
|
|
||||||
# Print log
|
# Print log
|
||||||
mylog('verbose', ['[Update Device Name] Names Found (DiG/Pholus): ', len(recordsToUpdate), " (",foundDig,"/",foundPholus ,")"] )
|
mylog('verbose', ['[Update Device Name] Names Found (DiG/NSlookup/Pholus): ', len(recordsToUpdate), " (",foundDig,"/",foundNsLookup,"/",foundPholus ,")"] )
|
||||||
mylog('verbose', ['[Update Device Name] Names Not Found : ', len(recordsNotFound)] )
|
mylog('verbose', ['[Update Device Name] Names Not Found : ', len(recordsNotFound)] )
|
||||||
|
|
||||||
# update not found devices with (name not found)
|
# update not found devices with (name not found)
|
||||||
|
|||||||
@@ -361,6 +361,33 @@ def check_IP_format (pIP):
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
#-------------------------------------------------------------------------------
|
||||||
|
def get_device_name_nslookup(db, pMAC, pIP):
|
||||||
|
|
||||||
|
nameNotFound = "(name not found)"
|
||||||
|
|
||||||
|
sql = db.sql
|
||||||
|
|
||||||
|
name = nameNotFound
|
||||||
|
|
||||||
|
# get names from the NSLOOKUP plugin entries
|
||||||
|
sql.execute(
|
||||||
|
f"""
|
||||||
|
SELECT Watched_Value2 FROM Plugins_Objects
|
||||||
|
WHERE
|
||||||
|
Plugin = 'NSLOOKUP' AND
|
||||||
|
(Object_PrimaryID = '{pMAC}' OR Object_SecondaryID = '{pIP}')
|
||||||
|
"""
|
||||||
|
)
|
||||||
|
nslookupEntry = sql.fetchall()
|
||||||
|
db.commitDB()
|
||||||
|
|
||||||
|
if len(nslookupEntry) != 0:
|
||||||
|
name = nslookupEntry[0][0]
|
||||||
|
|
||||||
|
return name
|
||||||
|
|
||||||
|
|
||||||
#-------------------------------------------------------------------------------
|
#-------------------------------------------------------------------------------
|
||||||
def resolve_device_name_dig (pMAC, pIP):
|
def resolve_device_name_dig (pMAC, pIP):
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user