Pi.Alert icon indicating copy to clipboard operation
Pi.Alert copied to clipboard

[Bug] no more scans?

Open stanelie opened this issue 1 year ago • 6 comments

For the past 5 days, I haven't received any new devices or down notifications. A reboot did not fix the issue. The scan log contains the following :

Pi.Alert v2024-09-01
---------------------------------------------------------
Executing user: stanelie

Scan Devices
    Timestamp: 2024-09-12 17:35:00

Scanning...
    arp-scan Method...
    arp-scan: One interface
    Pi-hole 5 Method...
Traceback (most recent call last):
File "/home/stanelie/pialert/back/pialert.py", line 3609, in
    sys.exit(main())    
             ^^^^^^
File "/home/stanelie/pialert/back/pialert.py", line 96, in main
    res = scan_network()
         ^^^^^^^^^^^^^^
File "/home/stanelie/pialert/back/pialert.py", line 735, in scan_network
    copy_pihole_network()
File "/home/stanelie/pialert/back/pialert.py", line 913, in copy_pihole_network
    sql.execute ("DELETE FROM PiHole_Network")
sqlite3.OperationalError: attempt to write a readonly database

stanelie avatar Sep 12 '24 21:09 stanelie

I stopped the scan service with the web GUI, I deleted the -wal and -shm files, and I restarted the scan. I now works again.

What can be done to make this more reliable? Thanks

stanelie avatar Sep 12 '24 22:09 stanelie

I suspect that the accesses of the backend user and the frontend are getting in each other's way. I can implement an experimental function that also changes the permissions of the transaction files. I would then instruct you how to activate the code to see if the situation improves.

leiweibau avatar Sep 15 '24 13:09 leiweibau

Great, I will try!

stanelie avatar Sep 15 '24 13:09 stanelie

As announced, the current update contains experimental code. Please comment out these lines (# at the beginning of the line)

https://github.com/leiweibau/Pi.Alert/blob/cb5e43ed643e596ff789b9645db9bd749114e8c1/back/pialert.py#L133-L134

For these lines, remove the leading “# ” (including the space to the right of it) https://github.com/leiweibau/Pi.Alert/blob/cb5e43ed643e596ff789b9645db9bd749114e8c1/back/pialert.py#L137-L138

You will find the file “pialert.py” in the directory “pialert/back/”

leiweibau avatar Sep 17 '24 07:09 leiweibau

I've modified the required lines. Do I need to do anything else to "apply" this modification?

stanelie avatar Sep 17 '24 14:09 stanelie

Do I need to do anything else to "apply" this modification?

no

leiweibau avatar Sep 17 '24 15:09 leiweibau

So far, it's a lot better! I have not had to stop the scanning engine to be able to edit entries since I applied this test permissions modifications.

There was not a lot of new activity on the network though, but so far, so good!

Thanks again, this makes pi.alert a lot more useable for me!

stanelie avatar Sep 23 '24 12:09 stanelie

I spoke too fast, I just had to stop the scanning engine to be able to edit 3 devices. So, better, but not bulletproof.

stanelie avatar Sep 23 '24 13:09 stanelie

stop the scanning engine to be able to edit 3 devices

The experimental code was not intended to counteract this behavior and cannot work at all. According to the idea, the code should only help if transaction data of the www-data user is still open and the scan forces the user permissions on the user under which Pi.Alert is installed. The database gives the response “Database locked” of its own accord. Or to put it another way: The code should be used to test whether the error that you have to delete these two files for anything to work at all becomes less frequent, or even disappears.

The original Pi.Alert was not at all suitable for constant editing while scans should also be constantly running, nor is the version I have continued, which is simply due to the database technology.

leiweibau avatar Sep 23 '24 16:09 leiweibau

Then, I would say the errors are less frequent.

stanelie avatar Sep 23 '24 16:09 stanelie

After the update, you should reactivate the experimental function in script

leiweibau avatar Sep 28 '24 14:09 leiweibau

I commented out lines 137-138, and uncommented lines 141-142.

stanelie avatar Sep 30 '24 12:09 stanelie

With the next update, the function I added for testing will be active by default

leiweibau avatar Oct 20 '24 15:10 leiweibau

Update released with https://github.com/leiweibau/Pi.Alert/commit/4317ae53a4af619ce48b14248c85733684539201

leiweibau avatar Oct 20 '24 17:10 leiweibau