leiweibau / Pi.Alert

Scan the devices connected to your WIFI / LAN and alert you the connection of unknown devices. It also warns if a "always connected" device disconnects. In addition, it is possible to check web services for availability. For this purpose HTTP status codes and the response time of the service are evaluated.
https://leiweibau.net
GNU General Public License v3.0
428 stars 31 forks source link

[Bug] Error message during upgrade #395

Closed hspindel closed 3 days ago

hspindel commented 6 days ago

Is there an existing issue for this?

Current Behavior

Just upgraded to today's release (9/28/24). Got this error message during the upgrade. Just reporting it as it things seem to be working fine so it's apparently not a big issue.

Ping Hosts...
    Online Host(s)  : 14
    Offline Host(s) : 0
Save scan results...

Traceback (most recent call last): File "/root/pialert/back/pialert.py", line 3817, in sys.exit(main()) ^^^^^^ File "/root/pialert/back/pialert.py", line 100, in main res = scan_network() ^^^^^^^^^^^^^^ File "/root/pialert/back/pialert.py", line 825, in scan_network icmp_monitoring() File "/root/pialert/back/pialert.py", line 2884, in icmp_monitoring icmp_save_scandata(icmp_scan_results) File "/root/pialert/back/pialert.py", line 2900, in icmp_save_scandata set_icmphost_current_scan(host_ip, scan_data['scantime'], scan_data['icmp_sta cmp_rtt']) File "/root/pialert/back/pialert.py", line 2963, in set_icmphost_current_scan sql.execute(sqlite_insert, table_data) sqlite3.IntegrityError: UNIQUE constraint failed: ICMP_Mon_CurrentScan.cur_ip

Environment

No response

Anything else?

No response

leiweibau commented 4 days ago

Hello,

If I understand you correctly, the error only occurred during the update, but no longer during the "normal" scans?

If this is the case, it could be related to the fact that I only kill the "arp-scan" process at the beginning of the update, as this usually takes the longest. However, I see that you have entered "many" hosts for ICMP monitoring. If you have only entered a few hosts here, the scan is usually finished if it was already running when you started the update. In your case, it could be that there was an overlap and that is why this error message appeared.

However, it also makes no sense to terminate the "ping" process, as this is called twice for each host. Killing the scan that may be running by terminating the Python script is too dangerous for possible database errors.

At this point, my only recommendation is to pause Pi.Alert in the settings and start the update process after the scan has finished (as shown in the status box). Of course, this overlap can also happen with a "normal" scan after the update. I could avoid this if I did not start a test scan after the update. 🤔

hspindel commented 4 days ago

You understand me correctly.

I will try pausing Pi.Alert next time I do an update.

Thank you!