Compare commits

..

9 Commits

Author SHA1 Message Date
jokob-sk
e9539962c9 cron s6 rollback #945
Some checks are pending
docker / docker_dev (push) Waiting to run
2025-01-09 09:23:29 +11:00
jokob-sk
87d18a9067 Merge branch 'main' of https://github.com/jokob-sk/NetAlertX 2025-01-09 08:35:14 +11:00
jokob-sk
2302cd9a31 s6 setup improvements #945 2025-01-09 08:35:09 +11:00
jokob-sk
babe0eab53 Merge pull request #944 from kpolszewski/mtscan-readme-update
better readme for the MikroTik plugin
2025-01-09 08:16:22 +11:00
kpolszewski
7c878690ef better readme for the MikroTik plugin 2025-01-08 19:15:32 +01:00
jokob-sk
b29dcbfa98 CHECKMK script
Some checks failed
docker / docker_dev (push) Waiting to run
🤖Automation - Update Sponsors Table / update-table (push) Has been cancelled
2025-01-08 23:32:14 +11:00
jokob-sk
8d9c48166b Merge branch 'main' of https://github.com/jokob-sk/NetAlertX 2025-01-08 23:00:07 +11:00
jokob-sk
540f8e850b DUMMY as new device source plugin 2025-01-08 23:00:03 +11:00
github-actions[bot]
8316d8e741 [🤖Automation] Update README with sponsors information 2025-01-08 11:53:43 +00:00
12 changed files with 154 additions and 19 deletions

View File

@@ -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).

View File

@@ -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)
|----------------------| ----------------------| ----------------------| ----------------------| ----------------------|

View File

@@ -13,13 +13,14 @@ sed -i "/^user/c\user = nginx" /etc/php83/php-fpm.d/www.conf
sed -i "/^group/c\group = www-data" /etc/php83/php-fpm.d/www.conf
# s6 overlay setup
mkdir -p /etc/s6-overlay/s6-rc.d/{SetupOneshot,php-fpm/dependencies.d,nginx/dependencies.d}
mkdir -p /etc/s6-overlay/s6-rc.d/{SetupOneshot,php-fpm/dependencies.d,nginx/dependencies.d,$APP_NAME/dependencies.d}
mkdir -p /etc/s6-overlay/s6-rc.d/{SetupOneshot,crond/dependencies.d,php-fpm/dependencies.d,nginx/dependencies.d,$APP_NAME/dependencies.d}
echo "oneshot" > /etc/s6-overlay/s6-rc.d/SetupOneshot/type
echo "longrun" > /etc/s6-overlay/s6-rc.d/crond/type
echo "longrun" > /etc/s6-overlay/s6-rc.d/php-fpm/type
echo "longrun" > /etc/s6-overlay/s6-rc.d/nginx/type
echo "longrun" > /etc/s6-overlay/s6-rc.d/$APP_NAME/type
echo -e "${INSTALL_DIR}/dockerfiles/init.sh" > /etc/s6-overlay/s6-rc.d/SetupOneshot/up
echo -e "#!/bin/execlineb -P\n/usr/sbin/crond -f -d 8" > /etc/s6-overlay/s6-rc.d/crond/run
echo -e "#!/bin/execlineb -P\n/usr/sbin/php-fpm83 -F" > /etc/s6-overlay/s6-rc.d/php-fpm/run
echo -e '#!/bin/execlineb -P\nnginx -g "daemon off;"' > /etc/s6-overlay/s6-rc.d/nginx/run
echo -e '#!/bin/execlineb -P
@@ -33,8 +34,7 @@ echo -e '#!/bin/execlineb -P
" }' > /etc/s6-overlay/s6-rc.d/$APP_NAME/run
echo -e "python ${INSTALL_DIR}/server" >> /etc/s6-overlay/s6-rc.d/$APP_NAME/run
touch /etc/s6-overlay/s6-rc.d/user/contents.d/{SetupOneshot,php-fpm,nginx} /etc/s6-overlay/s6-rc.d/{php-fpm,nginx}/dependencies.d/SetupOneshot
touch /etc/s6-overlay/s6-rc.d/user/contents.d/{SetupOneshot,php-fpm,nginx,$APP_NAME} /etc/s6-overlay/s6-rc.d/{php-fpm,nginx,$APP_NAME}/dependencies.d/SetupOneshot
touch /etc/s6-overlay/s6-rc.d/user/contents.d/{SetupOneshot,crond,php-fpm,nginx,$APP_NAME} /etc/s6-overlay/s6-rc.d/{crond,php-fpm,nginx,$APP_NAME}/dependencies.d/SetupOneshot
touch /etc/s6-overlay/s6-rc.d/nginx/dependencies.d/php-fpm
touch /etc/s6-overlay/s6-rc.d/$APP_NAME/dependencies.d/nginx

View File

@@ -273,7 +273,8 @@ function setDeviceData() {
devFirstConnection,
devLastIP,
devGUID,
devCustomProps
devCustomProps,
devSourcePlugin
) VALUES (
'$mac',
'$name',
@@ -300,7 +301,8 @@ function setDeviceData() {
'$devFirstConnection',
'$ip',
'$devNewGuid',
'$devCustomProps'
'$devCustomProps',
'DUMMY'
)";
}

View File

@@ -28,10 +28,10 @@
<!-- To the right -->
<div class="pull-right no-hidden-xs">
| <a href="https://gurubase.io/g/netalertx" target="_blank" title="Ask AI"><i class="fa-regular fa-comment-dots fa-flip-horizontal"></i></a>
| <a href="https://github.com/jokob-sk/NetAlertX/tree/main/docs#documentation-overview" target="_blank" title="Documentation"><i class="fa fa-book"></i></a>
| <a href="https://github.com/jokob-sk/NetAlertX/issues" target="_blank"><i class="fa-solid fa-bug" title="Report a bug"></i></a>
| <a href="https://discord.com/invite/NczTUTWyRr" target="_blank"><i class="fa-brands fa-discord" title="Join Discord"></i></a>
| <a href="https://gurubase.io/g/netalertx" class="pointer" target="_blank" title="Ask AI"><i class="fa-regular fa-comment-dots fa-flip-horizontal"></i></a>
| <a href="https://github.com/jokob-sk/NetAlertX/tree/main/docs#documentation-overview" class="pointer" target="_blank" title="Documentation"><i class="fa fa-book"></i></a>
| <a href="https://github.com/jokob-sk/NetAlertX/issues" class="pointer" target="_blank"><i class="fa-solid fa-bug" title="Report a bug"></i></a>
| <a href="https://discord.com/invite/NczTUTWyRr" class="pointer" target="_blank"><i class="fa-brands fa-discord" title="Join Discord"></i></a>
| <?= lang('Maintenance_built_on');?>: <?php include 'php/templates/build.php'; ?>
| Version: <?php include 'php/templates/version.php'; ?>
|

View File

@@ -185,13 +185,13 @@
</li>
<!-- Clear cache & Reload -->
<li>
<a id="reload-button" href='#' role="button" span class='fa fa-repeat' onclick='clearCache()'></a>
<a id="reload-button" href='#' role="button" span onclick='clearCache()'>🔃</a>
</li>
<!-- Full Screen -->
<li>
<a id="fullscreen-button" href='#' role="button" span class='fa fa-arrows-alt' onclick='toggleFullscreen()'></a>
</li>
<!-- Full Screen -->
<!-- Notifications -->
<li>
<a id="notifications-button" href='userNotifications.php' role="button" span class='fa-solid fa-bell'></a>
<span id="unread-notifications-bell-count" title="" class="badge bg-red unread-notifications-bell" >0</span>

View File

@@ -1,7 +1,27 @@
## Overview
Plugin for device name discovery via the Mikrotik dhcp-server leases
The plugin uses the MikroTik API to discover devices by retrieving DHCP lease information.
### Prerequisites
- API must be enabled in `API > Interfaces` on your MikroTik router.
- A user must be created in `System > Users` on your MikroTik router. Read-only permissions are recommended for security.
### Usage
- Check the Settings page for details.
It is recommended to use this plugin in scheduled mode for continuous device discovery and monitoring.
In the Settings section of NetAlertX, provide the following parameters:
- **MTSCAN_MT_HOST**: IP address of the MikroTik router (default: `192.168.88.1`).
- **MTSCAN_MT_PORT**: Port for the MikroTik API (default: `8728`).
- **MTSCAN_MT_USER**: Username for the MikroTik router.
- **MTSCAN_MT_PASS**: Password for the MikroTik router.
### Device name resolution order
To assign a meaningful device name, the plugin resolves it in the following order:
- **Comment**: The `comment` field in the MikroTik router's DHCP lease configuration. This is useful for naming static leases of known devies.
- **Hostname**: The hostname provided by the device during DHCP negotiation.
- **"(unknown)"**: as the fallback name, allowing other plugins to resolve the device name later.

View File

@@ -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.

24
scripts/checkmk/README.md Executable file
View File

@@ -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:
```
<status> <service_name> <perfdata> <message>
```
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.

74
scripts/checkmk/script.py Executable file
View File

@@ -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:
<status> <service_name> <perfdata> <message>
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()

View File

@@ -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)
- Author: [laxduke](https://github.com/laxduke)
> [!NOTE]
> This is a community supplied script and not maintained.

View File

@@ -203,8 +203,13 @@ def get_plugins_configs(loadAll):
plugJson = json.loads(get_file_content(config_path))
# only laod 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)