Compare commits

...

4 Commits

Author SHA1 Message Date
jokob-sk
ad32e76a55 Merge branch 'main' of https://github.com/jokob-sk/NetAlertX
Some checks are pending
docker / docker_dev (push) Waiting to run
2025-01-08 08:12:54 +11:00
jokob-sk
190ffd3237 missing start.sh in final image v0.2 2025-01-08 08:12:50 +11:00
jokob-sk
c8280184dc Merge pull request #940 from kpolszewski/mtscan-names-from-comments
Restore manual naming of static leases using comments for MKSCAN + cleanups
2025-01-08 07:01:52 +11:00
Kamil Olszewski
076d8bbcc2 Restore manual naming of static leases using comments for MKSCAN + cleanups 2025-01-07 18:23:53 +01:00
5 changed files with 14 additions and 31 deletions

View File

@@ -69,7 +69,7 @@ COPY --from=builder --chown=nginx:www-data ${INSTALL_DIR}/ ${INSTALL_DIR}/
COPY install/crontab /etc/crontabs/root
# Start all required services
RUN ${INSTALL_DIR}/dockerfiles/pre-setup.sh
RUN ${INSTALL_DIR}/dockerfiles/start.sh
HEALTHCHECK --interval=30s --timeout=5s --start-period=15s --retries=2 \
CMD curl -sf -o /dev/null ${LISTEN_ADDR}:${PORT}/php/server/query_json.php?file=app_state.json

View File

@@ -1,7 +1,7 @@
#!/usr/bin/with-contenv bash
echo "---------------------------------------------------------"
echo "[INSTALL] Run setup.sh"
echo "[INSTALL] Run init.sh"
echo "---------------------------------------------------------"
export INSTALL_DIR=/app # Specify the installation directory here

View File

@@ -19,7 +19,7 @@ echo "oneshot" > /etc/s6-overlay/s6-rc.d/SetupOneshot/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/setup.sh" > /etc/s6-overlay/s6-rc.d/SetupOneshot/up
echo -e "${INSTALL_DIR}/dockerfiles/init.sh" > /etc/s6-overlay/s6-rc.d/SetupOneshot/up
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
@@ -38,6 +38,5 @@ touch /etc/s6-overlay/s6-rc.d/user/contents.d/{SetupOneshot,php-fpm,nginx,$APP_N
touch /etc/s6-overlay/s6-rc.d/nginx/dependencies.d/php-fpm
touch /etc/s6-overlay/s6-rc.d/$APP_NAME/dependencies.d/nginx
rm -f $0
# this removes the current file
# rm -f $0

View File

@@ -2,7 +2,7 @@
"code_name": "mikrotik_scan",
"unique_prefix": "MTSCAN",
"plugin_type": "device_scanner",
"execution_order" : "Layer_4",
"execution_order" : "Layer_1",
"enabled": true,
"data_source": "script",
"mapped_to_table": "CurrentScan",
@@ -27,12 +27,6 @@
}
],
"params": [
{
"name": "ips",
"type": "sql",
"value": "SELECT devLastIP from DEVICES order by devMac",
"timeoutMultiplier": true
},
{
"name": "mt_host",
"type": "setting",

View File

@@ -1,27 +1,16 @@
#!/usr/bin/env python
import os
import pathlib
import argparse
import subprocess
import sys
import hashlib
import csv
import sqlite3
import re
from io import StringIO
from datetime import datetime
# Register NetAlertX directories
INSTALL_PATH="/app"
sys.path.extend([f"{INSTALL_PATH}/front/plugins", f"{INSTALL_PATH}/server"])
from plugin_helper import Plugin_Object, Plugin_Objects, decodeBase64
from logger import mylog, Logger, append_line_to_file
from helper import timeNowTZ, get_setting_value
from const import logPath, applicationPath, fullDbPath
from database import DB
from device import Device_obj
from plugin_helper import Plugin_Objects
from logger import mylog, Logger
from helper import get_setting_value
from const import logPath
import conf
from pytz import timezone
from librouteros import connect
@@ -81,6 +70,7 @@ def get_entries(plugin_objects: Plugin_Objects) -> Plugin_Objects:
comment = lease.get('comment')
last_seen = lease.get('last-seen')
status = lease.get('status')
device_name = comment or host_name or "(unknown)"
mylog('verbose', [f"ID: {lease_id}, Address: {address}, MAC Address: {mac_address}, Host Name: {host_name}, Comment: {comment}, Last Seen: {last_seen}, Status: {status}"])
@@ -89,9 +79,9 @@ def get_entries(plugin_objects: Plugin_Objects) -> Plugin_Objects:
primaryId = mac_address,
secondaryId = address,
watched1 = address,
watched2 = host_name,
watched3 = last_seen,
watched4 = '',
watched2 = device_name,
watched3 = host_name,
watched4 = last_seen,
extra = '',
helpVal1 = comment,
foreignKey = mac_address)