mirror of
https://github.com/jokob-sk/NetAlertX.git
synced 2025-12-07 09:36:05 -08:00
@@ -233,7 +233,6 @@ class sensor_config:
|
||||
Store the sensor configuration in the global plugin_objects, which tracks sensors based on a unique combination
|
||||
of attributes including deviceId, sensorName, hash, and MAC.
|
||||
"""
|
||||
global plugin_objects
|
||||
|
||||
# Add the sensor to the global plugin_objects
|
||||
plugin_objects.add_object(
|
||||
@@ -318,7 +317,6 @@ def create_generic_device(mqtt_client, deviceId, deviceName):
|
||||
# ------------------------------------------------------------------------------
|
||||
# Register sensor config on the broker
|
||||
def create_sensor(mqtt_client, deviceId, deviceName, sensorType, sensorName, icon, mac=""):
|
||||
global mqtt_sensors
|
||||
|
||||
# check previous configs
|
||||
sensorConfig = sensor_config(deviceId, deviceName, sensorType, sensorName, icon, mac)
|
||||
@@ -429,7 +427,7 @@ def mqtt_create_client():
|
||||
# -----------------------------------------------------------------------------
|
||||
def mqtt_start(db):
|
||||
|
||||
global mqtt_client, mqtt_connected_to_broker
|
||||
global mqtt_client
|
||||
|
||||
if not mqtt_connected_to_broker:
|
||||
mqtt_client = mqtt_create_client()
|
||||
|
||||
@@ -1,4 +1,3 @@
|
||||
|
||||
#!/usr/bin/env python
|
||||
|
||||
import json
|
||||
|
||||
@@ -1,6 +1,4 @@
|
||||
|
||||
#!/usr/bin/env python
|
||||
|
||||
import json
|
||||
import os
|
||||
import sys
|
||||
@@ -99,7 +97,7 @@ def send(text):
|
||||
"ut" : 'Open NetAlertX',
|
||||
"k" : token,
|
||||
}
|
||||
response = requests.post(url, data=post_fields)
|
||||
response = requests.post(url, data=post_fields, timeout=get_setting_value("PUSHSAFER_RUN_TIMEOUT"))
|
||||
response_status_code = response.status_code
|
||||
|
||||
# Check if the request was successful (status code 200)
|
||||
|
||||
@@ -22,6 +22,7 @@ from logger import mylog, Logger # noqa: E402 [flake8 lint suppression]
|
||||
from const import logPath # noqa: E402 [flake8 lint suppression]
|
||||
from helper import get_setting_value # noqa: E402 [flake8 lint suppression]
|
||||
import conf # noqa: E402 [flake8 lint suppression]
|
||||
from utils.datetime_utils import timeNowDB # noqa: E402 [flake8 lint suppression]
|
||||
|
||||
# Make sure the TIMEZONE for logging is correct
|
||||
conf.tz = timezone(get_setting_value("TIMEZONE"))
|
||||
@@ -150,7 +151,7 @@ def main():
|
||||
watched1=freebox["name"],
|
||||
watched2=freebox["operator"],
|
||||
watched3="Gateway",
|
||||
watched4=datetime.now,
|
||||
watched4=timeNowDB(),
|
||||
extra="",
|
||||
foreignKey=freebox["mac"],
|
||||
)
|
||||
|
||||
@@ -268,7 +268,7 @@ def main():
|
||||
|
||||
if is_mac(entry['mac']):
|
||||
# Map to Plugin_Objects fields
|
||||
mylog('verbose', [f'[{pluginName}] found: {entry['name']}|{entry['mac']}|{entry['ip']}'])
|
||||
mylog('verbose', [f"[{pluginName}] found: {entry['name']}|{entry['mac']}|{entry['ip']}"])
|
||||
|
||||
plugin_objects.add_object(
|
||||
primaryId=str(entry['mac']),
|
||||
@@ -281,7 +281,7 @@ def main():
|
||||
foreignKey=str(entry['mac'])
|
||||
)
|
||||
else:
|
||||
mylog('verbose', [f'[{pluginName}] Skipping invalid MAC: {entry['name']}|{entry['mac']}|{entry['ip']}'])
|
||||
mylog('verbose', [f"[{pluginName}] Skipping invalid MAC: {entry['name']}|{entry['mac']}|{entry['ip']}"])
|
||||
|
||||
# Write result file for NetAlertX to ingest
|
||||
plugin_objects.write_result_file()
|
||||
|
||||
Reference in New Issue
Block a user