Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Same Pi.Alert Report mail on every scheduled nmap scan #199

Closed
AleksCee opened this issue Mar 18, 2023 · 9 comments
Closed

Same Pi.Alert Report mail on every scheduled nmap scan #199

AleksCee opened this issue Mar 18, 2023 · 9 comments
Labels
bug 🐛 Something isn't working next release/in dev image🚀 This is coming in the next release or was already released if the issue is Closed.

Comments

@AleksCee
Copy link

Describe the issue
I have configure a schedule scan with report mail for port changes and new devices. But the mail seams to report every night the same devices and port as new. Under the nmap device tap are also no oft this found ports, I think at this place a have to see the last result oft the schedule scan, right?

Paste last few lines from pialert.log

this is the log at the scheduled time for the first 4 devices. I promise the ports of my router and NAS are not changed every day buy reported at every scan


grep '2023-03-18 02' pialert.log
[2023-03-18 02:01:03] Process: Start
[2023-03-18 02:01:04] Scan: Nmap for max 150s (2.5min) per device
[2023-03-18 02:01:36] Scan: Nmap SUCCESS for 77.23.51.25 (1/55)
[2023-03-18 02:01:36] Scan: Ports found by NMAP: 4
[2023-03-18 02:01:36] Scan: Nmap new or changed ports: 4
[2023-03-18 02:01:36] Scan: Nmap old entries:          192
[2023-03-18 02:01:40] Scan: Nmap SUCCESS for 192.168.1.77 (2/55)
[2023-03-18 02:01:40] Scan: Ports found by NMAP: 62
[2023-03-18 02:01:40] Scan: Nmap new or changed ports: 62
[2023-03-18 02:01:40] Scan: Nmap old entries:          196
[2023-03-18 02:02:18] Scan: Nmap SUCCESS for 192.168.1.1 (3/55)
[2023-03-18 02:02:18] Scan: Ports found by NMAP: 12
[2023-03-18 02:02:18] Scan: Nmap new or changed ports: 12
[2023-03-18 02:02:18] Scan: Nmap old entries:          258
[2023-03-18 02:02:24] Scan: Nmap SUCCESS for 192.168.1.7 (4/55)

Paste your pialert.conf (remove personal info)

I hope the nmap config is ok? If more need please reply.


grep -i nmap pialert.conf
# Nmap
NMAP_ACTIVE=True
NMAP_TIMEOUT=150
NMAP_RUN='schedule'
NMAP_RUN_SCHD='0 2 * * *'
NMAP_ARGS='-p -10000'
# NMAPSRV
NMAPSRV_RUN='on_new_device'
NMAPSRV_CMD='SELECT  dv.dev_Name as Object_PrimaryID, cast({s-quote}http://{s-quote} || dv.dev_LastIP as VARCHAR(100)) || {s-quote}:{s-quote} || cast( SUBSTR(ns.Port ,0, INSTR(ns.Port , {s-quote}/{s-quote})) as VARCHAR(100)) as Object_SecondaryID,  datetime() as DateTime,  ns.Service as Watched_Value1,        ns.State as Watched_Value2,        {s-quote}null{s-quote} as Watched_Value3,        {s-quote}null{s-quote} as Watched_Value4,        ns.Extra as Extra, dv.dev_MAC as ForeignKey        FROM (SELECT * FROM Nmap_Scan) ns LEFT JOIN (SELECT dev_Name, dev_MAC, dev_LastIP FROM Devices) dv   ON ns.MAC = dv.dev_MAC'
NMAPSRV_RUN_SCHD='0 2 * * *'
NMAPSRV_WATCH=['Watched_Value1','Watched_Value2']
NMAPSRV_REPORT_ON=['new','watched-changed']

Paste your docker-compose.yml and .env (remove personal info)
No compose
docker-compose.yml


docker run -d --network=host --restart=unless-stopped \
  -v /volume1/docker/pialert/config:/home/pi/pialert/config \
  -v /volume1/docker/pialert/db:/home/pi/pialert/db \
  -e TZ=Europe/Berlin \
  -e PORT=20211 \
  -e HOST_USER_ID=1024 \
  -e HOST_USER_GID=100 \
  --name pialert \
  jokobsk/pi.alert:latest

.env


paste here

Screenshots
If applicable, add screenshots to help explain your problem.

@jokob-sk
Copy link
Owner

Hi @AleksCee !

Can you confirm the container is not restarting? E.g. check if pialert.log contains multiple startup sequences such as:

 Permissions check (All should be True)
------------------------------------------------
  /config/pialert.conf |  READ  | True
  /config/pialert.conf |  WRITE | True
  /db/pialert.db       |  READ  | True
  /db/pialert.db       |  WRITE | True
------------------------------------------------

Past notifications are only cleared if all notifications are successfully sent. If any of the notification services fail and the container restarts, the app will try to re-send past notifications again so no data is lost.

j

@jokob-sk jokob-sk added the Waiting for reply⏳ Waiting for the original poster to respond, or discussion in progress. label Mar 19, 2023
@AleksCee
Copy link
Author

Hello @jokob-sk

for me it‘s all as you have defined:
8 days up and permissions ok

admin@nas:~$ docker ps |grep pialert
7a6a42c02086   jokobsk/pi.alert:latest                         "tini -- /home/pi/pi…"   8 days ago      Up 8 days                                                                                                               pialert
admin@nas:~$ docker exec -it pialert /bin/bash
root@nas:/# cd /home/pi/pialert/front/log/
root@nas:/home/pi/pialert/front/log# grep -A 6 'Permissions check' pialert.log 
 Permissions check (All should be True)
------------------------------------------------
  /config/pialert.conf |  READ  | True
  /config/pialert.conf |  WRITE | True
  /db/pialert.db       |  READ  | True
  /db/pialert.db       |  WRITE | True
------------------------------------------------

jokob-sk added a commit that referenced this issue Mar 25, 2023
@jokob-sk jokob-sk added bug 🐛 Something isn't working and removed Waiting for reply⏳ Waiting for the original poster to respond, or discussion in progress. labels Mar 25, 2023
@jokob-sk
Copy link
Owner

Thanks for confirming!

I think I've found the bug. If you'd like you can try to test this dev build: docker pull jokobsk/pi.alert_dev:sha-d9a9246.

@jokob-sk jokob-sk added the next release/in dev image🚀 This is coming in the next release or was already released if the issue is Closed. label Mar 25, 2023
@AleksCee
Copy link
Author

AleksCee commented Mar 25, 2023

I have just pulled the image, at 2 am the nmap scan is performed, so I will watch it for two days and give you a feedback.
Ups, sorry I don#t want to close this issue. To late for comments. How can I undo this?

@AleksCee AleksCee reopened this Mar 25, 2023
@jokob-sk
Copy link
Owner

Thanks for testing the fix!

@AleksCee
Copy link
Author

If I leave a comment, I can only close, sorry so I have to reopen but I want to write down my first observation: the nmap history per device is now showing. No mail this night, but I will confirm this tomorrow because of the German timeshift this night.

@AleksCee
Copy link
Author

Great work! I have configure an new port on a scanned device and in the report mail is only the new port reported.
So I think this dev-image work fine!
Thanks, Alex

@jokob-sk
Copy link
Owner

Thanks for confirming!

@jokob-sk
Copy link
Owner

jokob-sk commented Apr 1, 2023

Fix in latest release > closing

@jokob-sk jokob-sk closed this as completed Apr 1, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug 🐛 Something isn't working next release/in dev image🚀 This is coming in the next release or was already released if the issue is Closed.
Projects
None yet
Development

No branches or pull requests

2 participants