mirror of
https://github.com/jokob-sk/NetAlertX.git
synced 2026-04-04 17:21:23 -07:00
AVAHISCAN / mDNS #815
This commit is contained in:
@@ -19,7 +19,7 @@
|
|||||||
|
|
||||||
SCAN_SUBNETS=['192.168.1.0/24 --interface=eth0']
|
SCAN_SUBNETS=['192.168.1.0/24 --interface=eth0']
|
||||||
TIMEZONE='Europe/Berlin'
|
TIMEZONE='Europe/Berlin'
|
||||||
LOADED_PLUGINS = ['ARPSCAN','CSVBCKP','DBCLNP', 'INTRNT','MAINT','NEWDEV','NSLOOKUP','NTFPRCS', 'AVAHISCAN', 'PHOLUS','SETPWD','SMTP', 'SYNC', 'VNDRPDT', 'WORKFLOWS']
|
LOADED_PLUGINS = ['ARPSCAN','CSVBCKP','DBCLNP', 'INTRNT','MAINT','NEWDEV','NSLOOKUP','NTFPRCS', 'AVAHISCAN', 'SETPWD','SMTP', 'SYNC', 'VNDRPDT', 'WORKFLOWS']
|
||||||
|
|
||||||
DAYS_TO_KEEP_EVENTS=90
|
DAYS_TO_KEEP_EVENTS=90
|
||||||
# Used for generating links in emails. Make sure not to add a trailing slash!
|
# Used for generating links in emails. Make sure not to add a trailing slash!
|
||||||
@@ -28,7 +28,6 @@ REPORT_DASHBOARD_URL='http://netalertx'
|
|||||||
# Make sure at least these scanners are enabled for new installs, other defaults are taken from the config.json
|
# Make sure at least these scanners are enabled for new installs, other defaults are taken from the config.json
|
||||||
INTRNT_RUN='schedule'
|
INTRNT_RUN='schedule'
|
||||||
ARPSCAN_RUN='schedule'
|
ARPSCAN_RUN='schedule'
|
||||||
PHOLUS_RUN='on_new_device'
|
|
||||||
NSLOOKUP_RUN='before_name_updates'
|
NSLOOKUP_RUN='before_name_updates'
|
||||||
|
|
||||||
# Email
|
# Email
|
||||||
|
|||||||
@@ -41,8 +41,6 @@ def main():
|
|||||||
# timeout = get_setting_value('AVAHI_RUN_TIMEOUT')
|
# timeout = get_setting_value('AVAHI_RUN_TIMEOUT')
|
||||||
timeout = 20
|
timeout = 20
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
# Create a database connection
|
# Create a database connection
|
||||||
db = DB() # instance of class DB
|
db = DB() # instance of class DB
|
||||||
db.open()
|
db.open()
|
||||||
@@ -56,7 +54,7 @@ def main():
|
|||||||
# Retrieve devices
|
# Retrieve devices
|
||||||
unknown_devices = device_handler.getUnknown()
|
unknown_devices = device_handler.getUnknown()
|
||||||
|
|
||||||
# # Mock list of devices (replace with actual device_handler.getUnknown() in production)
|
# Mock list of devices (replace with actual device_handler.getUnknown() in production)
|
||||||
# unknown_devices = [
|
# unknown_devices = [
|
||||||
# {'dev_MAC': '00:11:22:33:44:55', 'dev_LastIP': '192.168.1.121'},
|
# {'dev_MAC': '00:11:22:33:44:55', 'dev_LastIP': '192.168.1.121'},
|
||||||
# {'dev_MAC': '00:11:22:33:44:56', 'dev_LastIP': '192.168.1.9'},
|
# {'dev_MAC': '00:11:22:33:44:56', 'dev_LastIP': '192.168.1.9'},
|
||||||
@@ -181,6 +179,10 @@ def ensure_avahi_running():
|
|||||||
mylog('verbose', [f'[{pluginName}] ⚠ ERROR - Failed to start D-Bus: {e.output}'])
|
mylog('verbose', [f'[{pluginName}] ⚠ ERROR - Failed to start D-Bus: {e.output}'])
|
||||||
return
|
return
|
||||||
|
|
||||||
|
# Check status
|
||||||
|
status_output = subprocess.run(['rc-service', 'avahi-daemon', 'status'], capture_output=True, text=True)
|
||||||
|
mylog('verbose', [f'[{pluginName}] Avahi Daemon Status: {status_output.stdout.strip()}'])
|
||||||
|
|
||||||
# Start the Avahi daemon
|
# Start the Avahi daemon
|
||||||
try:
|
try:
|
||||||
subprocess.run(['rc-service', 'avahi-daemon', 'start'], check=True)
|
subprocess.run(['rc-service', 'avahi-daemon', 'start'], check=True)
|
||||||
@@ -188,10 +190,10 @@ def ensure_avahi_running():
|
|||||||
mylog('verbose', [f'[{pluginName}] ⚠ ERROR - Failed to start Avahi daemon: {e.output}'])
|
mylog('verbose', [f'[{pluginName}] ⚠ ERROR - Failed to start Avahi daemon: {e.output}'])
|
||||||
return
|
return
|
||||||
|
|
||||||
# Check status
|
|
||||||
status_output = subprocess.run(['rc-service', 'avahi-daemon', 'status'], capture_output=True, text=True)
|
|
||||||
mylog('verbose', [f'[{pluginName}] Avahi Daemon Status: {status_output.stdout.strip()}'])
|
|
||||||
|
|
||||||
|
# rc-update add avahi-daemon
|
||||||
|
# rc-service avahi-daemon status
|
||||||
|
# rc-service avahi-daemon start
|
||||||
|
|
||||||
if __name__ == '__main__':
|
if __name__ == '__main__':
|
||||||
main()
|
main()
|
||||||
|
|||||||
@@ -550,7 +550,7 @@ def update_devices_names (db):
|
|||||||
recordsToUpdate.append ([newName, device['dev_MAC']])
|
recordsToUpdate.append ([newName, device['dev_MAC']])
|
||||||
|
|
||||||
# Print log
|
# Print log
|
||||||
mylog('verbose', [f'[Update Device Name] Names Found (DiG/mDNS/NSLOOKUP/NBTSCAN/Pholus): {len(recordsToUpdate)} ({foundmDNSLookup}/{foundDig}/{foundNsLookup}/{foundNbtLookup}/{foundPholus})'] )
|
mylog('verbose', [f'[Update Device Name] Names Found (DiG/mDNS/NSLOOKUP/NBTSCAN/Pholus): {len(recordsToUpdate)} ({foundDig}/{foundmDNSLookup}/{foundNsLookup}/{foundNbtLookup}/{foundPholus})'] )
|
||||||
mylog('verbose', [f'[Update Device Name] Names Not Found : {notFound}'] )
|
mylog('verbose', [f'[Update Device Name] Names Not Found : {notFound}'] )
|
||||||
|
|
||||||
# update not found devices with (name not found)
|
# update not found devices with (name not found)
|
||||||
|
|||||||
@@ -441,7 +441,7 @@ def execute_plugin(db, all_plugins, plugin, pluginsState = plugins_state() ):
|
|||||||
|
|
||||||
# check if the subprocess / SQL query failed / there was no valid output
|
# check if the subprocess / SQL query failed / there was no valid output
|
||||||
if len(sqlParams) == 0:
|
if len(sqlParams) == 0:
|
||||||
mylog('none', ['[Plugins] No output received from the plugin ', plugin["unique_prefix"], ' - enable LOG_LEVEL=debug and check logs'])
|
mylog('none', [f'[Plugins] No output received from the plugin "{plugin["unique_prefix"]}"'])
|
||||||
return pluginsState
|
return pluginsState
|
||||||
else:
|
else:
|
||||||
mylog('verbose', ['[Plugins] SUCCESS, received ', len(sqlParams), ' entries'])
|
mylog('verbose', ['[Plugins] SUCCESS, received ', len(sqlParams), ' entries'])
|
||||||
|
|||||||
Reference in New Issue
Block a user