working version of UnDIS plugin

This commit is contained in:
Data-Monkey
2023-05-17 22:25:33 +10:00
parent 07e8395536
commit a0501d88ec
3 changed files with 144 additions and 81 deletions

View File

@@ -1,35 +1,39 @@
#!/usr/bin/env python
# Based on the work of https://github.com/leiweibau/Pi.Alert
# test script by running python script.py devices=test,dummy
# python3 /home/pi/pialert/front/plugins/website_monitor/script.py urls=http://google.com,http://bing.com
import sys
import os
import pathlib
import argparse
from plugin_helper import Plugin_Objects
sys.dont_write_bytecode = True
curPath = str(pathlib.Path(__file__).parent.resolve())
log_file = curPath + '/script.log'
result_file = curPath + '/last_result.log'
log_file = os.path.join(curPath , 'script.log')
result_file = os.path.join(curPath , 'last_result.log')
FAKE_DEVICES = ["routerXX","hubZZ"]
def main():
print("Hello")
devices = Plugin_Objects( result_file )
parser = argparse.ArgumentParser(description='Import devices from dhcp.leases files')
parser.add_argument('devices', action="store", help="absolute dhcp.leases file paths to check separated by ','")
values = parser.parse_args()
undis_devices = Plugin_Objects( result_file )
if values.devices:
for fake_dev in values.devices.split('=')[1].split(','):
undis_devices.add_object(
primaryId=fake_dev, # MAC
secondaryId="0.0.0.0", # IP Address
watched1=fake_dev, # Device Name
watched2="",
watched3="",
watched4="UNDIS", # used as ScanMethod
extra="1", # used as dummy ScanCycle
foreignKey="")
for fake_dev in FAKE_DEVICES:
devices.add_object(fake_dev, fake_dev, fake_dev, fake_dev, "", "", "", "")
#for obj in devices.objects:
# print(obj.write())
devices.write_result_file()
undis_devices.write_result_file()
return 0