diff --git a/README.md b/README.md index 482266ad..873d47b9 100755 --- a/README.md +++ b/README.md @@ -3,7 +3,7 @@ [![GitHub Release](https://img.shields.io/github/v/release/jokob-sk/NetAlertX?color=0aa8d2&logoColor=fff&logo=GitHub&style=for-the-badge)](https://github.com/jokob-sk/NetAlertX/releases) [![Discord](https://img.shields.io/discord/1274490466481602755?color=0aa8d2&logoColor=fff&logo=Discord&style=for-the-badge)](https://discord.gg/NczTUTWyRr) -# 🖧🔍 Network scanner & notification framework +# NetAlertX - Network scanner & notification framework Get visibility of what's going on on your WIFI/LAN network. Schedule scans for devices, port changes and get alerts if unknown devices or changes are found. Write your own [Plugins](https://github.com/jokob-sk/NetAlertX/tree/main/front/plugins#readme) with auto-generated UI and in-build notification system. Build out and easily maintain your network source of truth (NSoT). diff --git a/dockerfiles/README.md b/dockerfiles/README.md index bf360a0d..74870038 100755 --- a/dockerfiles/README.md +++ b/dockerfiles/README.md @@ -4,7 +4,7 @@ [![Discord](https://img.shields.io/discord/1274490466481602755?color=0aa8d2&logoColor=fff&logo=Discord&style=for-the-badge)](https://discord.gg/NczTUTWyRr) -# NetAlertX 🖧🔍 Network scanner & notification framework +# NetAlertX - Network scanner & notification framework | [📑 Docker guide](https://github.com/jokob-sk/NetAlertX/blob/main/dockerfiles/README.md) | [🚀 Releases](https://github.com/jokob-sk/NetAlertX/releases) | [📚 Docs](https://github.com/jokob-sk/NetAlertX/tree/main/docs) | [🔌 Plugins](https://github.com/jokob-sk/NetAlertX/blob/main/front/plugins/README.md) | [🤖 Ask AI](https://gurubase.io/g/netalertx) |----------------------| ----------------------| ----------------------| ----------------------| ----------------------| diff --git a/front/plugins/snmp_discovery/README.md b/front/plugins/snmp_discovery/README.md index 805da55e..69742770 100755 --- a/front/plugins/snmp_discovery/README.md +++ b/front/plugins/snmp_discovery/README.md @@ -34,6 +34,12 @@ Confirm SNMP enabled show snmp ```` +### Setup for (old) procurve switches + +``` +snmpwalk -v 2c -c XXXXXX -On -Ovq 192.168.45.58 .1.3.6.1.2.1.4.22.1.3.102 +``` + ### Notes - Only IPv4 supported. diff --git a/scripts/checkmk/README.md b/scripts/checkmk/README.md new file mode 100755 index 00000000..78f6a51c --- /dev/null +++ b/scripts/checkmk/README.md @@ -0,0 +1,24 @@ +# NetAlertX-New-Devices-Checkmk-Script + +This script retrieves the list of all devices from NetAlertX by reading the `/app/api/table_devices.json` file within the "NetAlertX" Docker container. It then checks if there are any new devices (`devIsNew == 1`). + +- If new devices are found, a warning state is reported. +- Otherwise, an OK state is returned. + +## Checkmk Local Check Format + +The script follows the Checkmk local check format: + +``` + +``` + +For more details, see the [Checkmk Local Checks Documentation](https://docs.checkmk.com/latest/en/localchecks.html). + +### Other info + +- Date : 08-Jan-2025 - version 1.0 +- Author: N/A + +> [!NOTE] +> This is a community supplied script and not maintained. \ No newline at end of file diff --git a/scripts/checkmk/script.py b/scripts/checkmk/script.py new file mode 100755 index 00000000..dfe43484 --- /dev/null +++ b/scripts/checkmk/script.py @@ -0,0 +1,74 @@ + +YABin + +#!/usr/bin/env python3 +# -*- coding: utf-8 -*- +""" +NetAlertX-New-Devices-Checkmk-Script + +Dieses Skript ruft die Liste aller Devices aus NetAlertX ab, indem es innerhalb +des Docker-Containers "NetAlertX" die Datei /app/api/table_devices.json ausliest. +Anschließend wird geprüft, ob neue Geräte vorhanden sind (devIsNew == 1). +Falls ja, wird ein Warning-Zustand gemeldet, sonst OK. + +Checkmk-Local-Check-Format: + +Siehe: https://docs.checkmk.com/latest/de/localchecks.html +""" + +import subprocess +import json + +def check_new_devices(): + try: + # Rufe die JSON-Datei aus dem Docker-Container ab + result = subprocess.run( + ['docker', 'exec', 'NetAlertX', 'cat', '/app/api/table_devices.json'], + capture_output=True, + text=True, + check=True + ) + data_str = result.stdout + except subprocess.CalledProcessError as e: + # Wenn der Docker-Command fehlschlägt -> UNKNOWN (3) + print(f"3 NetAlertX_New_Devices - UNKNOWN - Docker command failed: {e}") + return + except Exception as e: + # Allgemeiner Fehler -> UNKNOWN + print(f"3 NetAlertX_New_Devices - UNKNOWN - Error while running docker command: {e}") + return + + # JSON-Daten laden + try: + data = json.loads(data_str) + except json.JSONDecodeError as e: + # Wenn das JSON nicht gelesen werden kann -> UNKNOWN + print(f"3 NetAlertX_New_Devices - UNKNOWN - JSON decode error: {e}") + return + + # Prüfen, ob das 'data'-Attribut vorhanden ist + if "data" not in data: + print("3 NetAlertX_New_Devices - UNKNOWN - Unexpected JSON format (no 'data' key).") + return + + new_devices = [] + for device in data["data"]: + # Prüfen, ob das Attribut 'devIsNew' existiert und == 1 ist + if "devIsNew" in device and device["devIsNew"] == 1: + new_devices.append(device) + + # Wenn keine neuen Geräte gefunden + if len(new_devices) == 0: + # Status 0 = OK + print("0 NetAlertX_New_Devices - OK - No new devices found") + else: + # Status 1 = WARNING + device_list_str = ", ".join( + f"{dev.get('devName', 'UnknownName')}({dev.get('devMac', 'UnknownMAC')}) IP:{dev.get('devLastIP', 'UnknownIP')}" + for dev in new_devices + ) + print(f"1 NetAlertX_New_Devices - WARNING - Found {len(new_devices)} new device(s): {device_list_str}") + +if __name__ == "__main__": + check_new_devices() + diff --git a/scripts/db_cleanup/README.md b/scripts/db_cleanup/README.md index bcb622e2..8dd165b8 100755 --- a/scripts/db_cleanup/README.md +++ b/scripts/db_cleanup/README.md @@ -35,4 +35,8 @@ For each MAC or IP address provided, the script: ### Other info - Date : 23-Dec-2024 - version 1.0 -- Author: [laxduke](https://github.com/laxduke) \ No newline at end of file +- Author: [laxduke](https://github.com/laxduke) + + +> [!NOTE] +> This is a community supplied script and not maintained. \ No newline at end of file diff --git a/server/plugin_utils.py b/server/plugin_utils.py index ea63cd45..c24d6d1f 100755 --- a/server/plugin_utils.py +++ b/server/plugin_utils.py @@ -203,8 +203,13 @@ def get_plugins_configs(loadAll): plugJson = json.loads(get_file_content(config_path)) - # only load plugin if needed - if loadAll or plugJson["unique_prefix"] in conf.LOADED_PLUGINS: + # Only load plugin if needed + # Fetch the list of enabled plugins from the config, default to an empty list if not set + enabledPlugins = getattr(conf, "LOADED_PLUGINS", []) + + # Load all plugins if `loadAll` is True, the plugin is in the enabled list, + # or no specific plugins are enabled (enabledPlugins is empty) + if loadAll or plugJson["unique_prefix"] in enabledPlugins or enabledPlugins == []: # Load the contents of the config.json file as a JSON object and append it to pluginsList pluginsList.append(plugJson)