jokob-sk / NetAlertX

🖧🔍 WIFI / LAN intruder detector. Scans for devices connected to your network and alerts you if new and unknown devices are found.
GNU General Public License v3.0
3.09k stars 187 forks source link

[setup] Setup help #525

Closed jokob-sk closed 10 months ago

jokob-sk commented 10 months ago
          unfortunately i seem to be running in the same issue.

Please note that i a fairly new to this topic so it´s not of the table that i misconfigured something.

No need to rush, thanks for the help in advance :)

docker-compose.yml:

version: "3"
services:
  pialert:
    container_name: pialert
    image: "jokobsk/pi.alert:latest"
    network_mode: "host"
    restart: unless-stopped
    volumes:
      - /docker/pialert/config:/home/pi/pialert/config
      - /docker/pialert/db:/home/pi/pialert/db
      # (optional) useful for debugging if you have issues setting up the container
      - /docker/pialert/logs:/home/pi/pialert/front/log
    environment:
      - TZ=Europe/Berlin
      - HOST_USER_ID=1000
      - HOST_USER_GID=1000
      - PORT=20211

Here are some logs:

Portainer Log:

2024-01-02T23:24:20.974980130Z ;pi@pialert: ~pi@pialert:~$ 2024-01-02T23:24:21.551171400Z ---------------------------------------------------------
2024-01-02T23:24:21.551244825Z [INSTALL]                                    Run start.sh
2024-01-02T23:24:21.551263695Z ---------------------------------------------------------
2024-01-02T23:24:21.558781400Z [INSTALL] Run setup scripts
2024-01-02T23:24:21.564247473Z ---------------------------------------------------------
2024-01-02T23:24:21.564329675Z [INSTALL]                             Run user-mapping.sh
2024-01-02T23:24:21.564345656Z ---------------------------------------------------------
2024-01-02T23:24:21.568420253Z USER_ID  : 1000
2024-01-02T23:24:21.568494345Z USER_GID : 1000
2024-01-02T23:24:21.568510085Z USER_HOME: 
2024-01-02T23:24:21.568649231Z TZ       : Europe/Berlin
2024-01-02T23:24:21.580386326Z chown: missing operand after '1000:1000 '
2024-01-02T23:24:21.580647211Z Try 'chown --help' for more information.

PiAlert Log:

@raspberrypi:/docker/pialert/logs $ cat pialert.log
00:11:11 [MAIN] Setting up ...
00:11:11 [conf.tz] Setting up ...
00:11:11

00:11:11 The container restarted (started). If this is unexpected check https://bit.ly/PiAlertDebug for troubleshooting tips.
00:11:11

00:11:11 Permissions check (All should be True)
00:11:11 ------------------------------------------------
00:11:11   /config/pialert.conf |  READ  | True
00:11:11   /config/pialert.conf |  WRITE | True
00:11:11   /db/pialert.db       |  READ  | True
00:11:11   /db/pialert.db       |  WRITE | True
00:11:11 ------------------------------------------------
00:11:11 [Setup] Attempting to fix permissions.
00:11:11 [Setup] Attempting to fix permissions.
00:11:11 [Database] Opening DB
00:11:11 [upgradeDB] Adding dev_Network_Node_MAC_ADDR to the Devices table
00:11:11 [upgradeDB] Adding dev_Network_Node_port to the Devices table
00:11:11 [upgradeDB] Adding dev_Icon to the Devices table
00:11:11 [upgradeDB] Re-creating Settings table
00:11:11 [upgradeDB] Re-creating Pholus_Scan table
00:11:11 [upgradeDB] Re-creating Parameters table
00:11:11 [Config] reading config file
00:11:11 [Config] Plugins: Number of dynamically loaded plugins: 25
00:11:11 [Plugin utils] ---------------------------------------------
00:11:11 [Plugin utils] display_name: Internet-Check
00:11:11 [Plugin utils] description: A plugin to check your internet connectivity and IP.
00:11:11 [Plugin utils] ---------------------------------------------
00:11:11 [Plugin utils] display_name: Rogue DHCP
00:11:11 [Plugin utils] description: This plugin is to use NMAP to monitor for rogue DHCP servers.
00:11:11 [Plugin utils] ---------------------------------------------
00:11:11 [Plugin utils] display_name: NTFY publisher
00:11:11 [Plugin utils] description: A plugin to publish a notification via the NTFY gateway.
00:11:12 [Plugin utils] ---------------------------------------------
00:11:12 [Plugin utils] display_name: SNMP discovery
00:11:12 [Plugin utils] description: This plugin is used to discover devices via the arp table(s) of a RFC1213 compliant router or switch.
00:11:12 [Plugin utils] ---------------------------------------------
00:11:12 [Plugin utils] display_name: CSV backup
00:11:12 [Plugin utils] description: A plugin to auto-generate devices.csv backups.
00:11:12 [Plugin utils] ---------------------------------------------
00:11:12 [Plugin utils] display_name: DDNS update
00:11:12 [Plugin utils] description: A plugin update the DDNS record.
00:11:12 [Plugin utils] ---------------------------------------------
00:11:12 [Plugin utils] display_name: Pushsafer publisher
00:11:12 [Plugin utils] description: A plugin to publish a notification via the Pushsafer gateway.
00:11:12 [Plugin utils] ---------------------------------------------
00:11:12 [Plugin utils] display_name: New Devices
00:11:12 [Plugin utils] description: The template used for new devices.
00:11:12 [Plugin utils] ---------------------------------------------
00:11:12 [Plugin utils] display_name: MQTT publisher
00:11:12 [Plugin utils] description: A plugin to publish a notification via the Apprise gateway.
00:11:12 [Plugin utils] ---------------------------------------------
00:11:12 [Plugin utils] display_name: Email publisher (SMTP)
00:11:12 [Plugin utils] description: A plugin to publish a notification via Email (SMTP) gateway.
00:11:12 [Plugin utils] ---------------------------------------------
00:11:12 [Plugin utils] display_name: Set password
00:11:12 [Plugin utils] description: A simple plugin to set the web ui password on app start.
00:11:12 [Plugin utils] ---------------------------------------------
00:11:12 [Plugin utils] display_name: Arp-Scan (Network scan)
00:11:12 [Plugin utils] description: This plugin is to execute an arp-scan on the local network
00:11:12 [Plugin utils] ---------------------------------------------
00:11:12 [Plugin utils] display_name: Services & Ports (NMAP)
00:11:12 [Plugin utils] description: This plugin shows all services discovered by NMAP scans.
00:11:12 [Plugin utils] ---------------------------------------------
00:11:12 [Plugin utils] display_name: DHCP Leases (Device import)
00:11:12 [Plugin utils] description: This plugin is to import devices from dhcp.leases files.
00:11:12 [Plugin utils] ---------------------------------------------
00:11:12 [Plugin utils] display_name: Maintenance
00:11:12 [Plugin utils] description: A plugin for maintenance tasks.
00:11:12 [Plugin utils] ---------------------------------------------
00:11:12 [Plugin utils] display_name: Internet speedtest
00:11:12 [Plugin utils] description: A plugin to perform a scheduled internet speedtest.
00:11:12 [Plugin utils] ---------------------------------------------
00:11:12 [Plugin utils] display_name: Un-Discoverable Devices
00:11:12 [Plugin utils] description: This plugin is to import undiscoverable devices from a file.
00:11:12 [Plugin utils] ---------------------------------------------
00:11:12 [Plugin utils] display_name: Website monitor
00:11:12 [Plugin utils] description: This plugin is to monitor status changes of services or websites.
00:11:12 [Plugin utils] ---------------------------------------------
00:11:12 [Plugin utils] display_name: PiHole (Device sync)
00:11:12 [Plugin utils] description: This plugin syncs devices from the PiHole database
00:11:12 [Plugin utils] ---------------------------------------------
00:11:12 [Plugin utils] display_name: Vendor update
00:11:12 [Plugin utils] description: A plugin to schedule vendor database updates for mac based vendor resolution.
00:11:12 [Plugin utils] ---------------------------------------------
00:11:12 [Plugin utils] display_name: Pholus-Scan (Name discovery)
00:11:12 [Plugin utils] description: This plugin is to execute a Pholus-scan (name discovery) on the local network
00:11:12 [Plugin utils] ---------------------------------------------
00:11:12 [Plugin utils] display_name: Apprise publisher
00:11:12 [Plugin utils] description: A plugin to publish a notification via the Apprise gateway.
00:11:13 [Plugin utils] ---------------------------------------------
00:11:13 [Plugin utils] display_name: DB cleanup
00:11:13 [Plugin utils] description: A plugin to schedule database cleanup & upkeep tasks.
00:11:13 [Plugin utils] ---------------------------------------------
00:11:13 [Plugin utils] display_name: UniFi import
00:11:13 [Plugin utils] description: This plugin is used to import devices from an UNIFI controller.
00:11:13 [Plugin utils] ---------------------------------------------
00:11:13 [Plugin utils] display_name: Webhook publisher
00:11:13 [Plugin utils] description: A plugin to publish a notification via Webhooks.
00:11:13 [API] Updating table_settings.json file in /front/api
00:11:13 [Config] Imported new config
00:11:13 [API] Updating table_devices.json file in /front/api
00:11:13 [API] Updating table_events_pending_alert.json file in /front/api
00:11:13 [API] Updating table_plugins_events.json file in /front/api
00:11:13 [API] Updating table_plugins_history.json file in /front/api
00:11:13 [API] Updating table_plugins_objects.json file in /front/api
00:11:13 [API] Updating table_plugins_language_strings.json file in /front/api
00:11:13 [Database] - SQL ERROR: no such table: Notifications
00:11:13 [API] Updating table_notifications.json file in /front/api
00:11:13 [API] Updating table_custom_endpoint.json file in /front/api
00:11:13 [Notification] Check if something to report
00:11:13 [Notification] Open text Template
00:11:13 [Notification] Open html Template
00:11:13 [Notification] Using template/back/report_template.html
00:11:13 [Notification] included sections: ['internet', 'new_devices', 'down_devices', 'events']
00:11:13 [Notification] New Devices sections done.
00:11:13 [Notification] Down Devices sections done.
00:11:13 [Notification] Events sections done.
00:11:13 [Notification] Udating API files
00:11:13 [Send API] Updating notification_* files in /home/pi/pialert/front/api/
00:11:13 [Notification] No changes to report
00:11:13 [MAIN] Process: Wait
00:11:18 [API] Updating table_notifications.json file in /front/api
00:11:18 [MAIN] waiting to start next loop
00:11:23 [MAIN] waiting to start next loop
00:11:28 [MAIN] waiting to start next loop
00:11:34 [MAIN] waiting to start next loop
00:11:39 [MAIN] waiting to start next loop
00:11:44 [MAIN] waiting to start next loop
00:11:49 [MAIN] waiting to start next loop
00:11:54 [MAIN] waiting to start next loop
00:11:59 [MAIN] waiting to start next loop
00:12:04 [MAIN] waiting to start next loop
00:12:09 [MAIN] waiting to start next loop
00:12:14 [Notification] Check if something to report
00:12:14 [Notification] Open text Template
00:12:14 [Notification] Open html Template
00:12:14 [Notification] Using template/back/report_template.html
00:12:15 [Notification] included sections: ['internet', 'new_devices', 'down_devices', 'events']
00:12:15 [Notification] New Devices sections done.
00:12:15 [Notification] Down Devices sections done.
00:12:15 [Notification] Events sections done.
00:12:15 [Notification] Udating API files
00:12:15 [Send API] Updating notification_* files in /home/pi/pialert/front/api/
00:12:15 [Notification] No changes to report
00:12:15 [MAIN] Process: Wait
00:12:20 [MAIN] waiting to start next loop
00:12:25 [MAIN] waiting to start next loop
00:12:30 [MAIN] waiting to start next loop
00:12:35 [MAIN] waiting to start next loop
00:12:40 [MAIN] waiting to start next loop
00:12:45 [MAIN] waiting to start next loop
00:12:50 [MAIN] waiting to start next loop
00:12:55 [MAIN] waiting to start next loop
00:13:00 [MAIN] waiting to start next loop
00:13:05 [MAIN] waiting to start next loop
00:13:11 [MAIN] waiting to start next loop

Originally posted by @lzsix in https://github.com/jokob-sk/Pi.Alert/issues/520#issuecomment-1874683683

jokob-sk commented 10 months ago

Hey @lzsix,

Can you please let me know what issue you are facing in more detail? I can't spot anything out of the ordinary in the log file. Please provide screenshots if they would help me to understand your issue.

Thanks, j

jokob-sk commented 10 months ago

It would be also useful to enable debug logging as described here: https://bit.ly/PiAlertDebug for a more detailed logging output.

lzsix commented 10 months ago

@jokob-sk thanks for the fast reply. image image image

i tried spinning up the container with the above mentioned docker compose file. I will try to change the config file and see if i can enable debug logging from there.

I cannot access the web interface. The container seems to be disconnecting from my network after a while. Also nmap doesn´t show any open ports.

It seems to me that it has an issue while first booting the container. I´ll update my post with screenshots as soon as im able to get more information out of the logs.

jokob-sk commented 10 months ago

Thanks 👍

I think the main thing to look out for then is the network config (screenshot of my Synology host):

image

Your compose file seems to be correct (host mode is enabled), but it's worth double-checking.

Also, if the container drops off after a while then it may restart, so please disable the restart behavior so we get an exception if there is one: https://github.com/jokob-sk/Pi.Alert/blob/main/docs/DEBUG_TIPS.md#4-disable-restart-behavior-

Alternatively, try starting the container via the terminal and wait until it crashes: https://github.com/jokob-sk/Pi.Alert/blob/main/docs/DEBUG_TIPS.md#2-surfacing-errors-when-container-restarts-

Thanks, j

lzsix commented 10 months ago

I rechecked all the settings. (i am using docker on a raspi 4 with 8GB RAM) I have setup my own network inside of portainer to have the container in my hostnetwork. See attached screenshot for the network: image

I disabled automatic restarts. so far the container is running since around 15minutes. my specified address answers to ping, however no ports are open.

I am starting to suspect that the container is running fine but the webserver has a problem. is there a way i can check/alter the webserver configs.

if there is no way to look into the webserver and check if it is running into some issues i don´t want to take up any more of your valuable time as it seems to be a misconfiguration on my end. Feel free to close the issue after your reply. I very much appreciate your help and the fast replys :)

jokob-sk commented 10 months ago

I think we are getting closer. IN my Portainer instance, this is how the network looks on my end:

image

image

Are you getting anything when accessing HTTP://<your rpi IP>/20211?

You can always ssh into the container and have a look if nginx is running, but even if it isn't I assume you should be able to access HTTP://<your rpi IP>/20211.

Here is the top output inside of the running container:

image

jokob-sk commented 10 months ago

Another thing, try running the pi.alert_dev container. It contains a little bit more of NGINX related logging during the startup:

pialert  | [INSTALL] Setup NGINX
pialert  | Removing existing PiAlert web-UI
pialert  | Removing existing PiAlert NGINX config
pialert  | Setting webserver to user-supplied port (20211)
pialert  | [INSTALL] Run the hardware vendors update
pialert  | The file ieee-oui.txt exists. Skipping update_vendors.sh...
pialert  | [INSTALL] Fixing file permissions
pialert  | [INSTALL] Fixing WEB_UI_DIR: /var/www/html/pialert
pialert  | [INSTALL] Fixing INSTALL_DIR: /home/pi
pialert  | [INSTALL] Copy starter pialert.db and pialert.conf if they don't exist
pialert  | [INSTALL] Fixing permissions after copied starter config & DB
pialert  | Starting nginx: nginx.
lzsix commented 10 months ago

@jokob-sk i am getting connection denied error when i try to access it via the webpage. I assume it is due to no open ports. will try with the dev image later. also i will try to test a bit with the network settings.

A while back i got it running easily. Had to reinstall my raspi because i had a weird 32/64bit system.

will report back after my testing. Thanks again :)

lzsix commented 10 months ago

@jokob-sk ok final update on the issue.

on the port question: it had it´s own ip address in my network so nothin really was running on that ip other than pialert.

the top page was just the right tip. i checked and nginx wasn´t running. when i startet it port 80 opened with the default page.

I then deleted all traces of pialert and kinda got it working now with the dev image.

I very much appreciate your help on the issue, thanks 🥇

jokob-sk commented 10 months ago

Thanks for the update @lzsix - glad it's working now. Weird setup issue though, hope it was only a blip. Will close this :)