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
439 stars 31 forks source link

[Bug] cannot view some devices #358

Closed stanelie closed 2 months ago

stanelie commented 2 months ago

Hello. I have this issue where some of my devices cannot be seen on their respective details pages, there is a "Quering device info..." message at the top and no fields get populated in the "Details" page. I also have the beachball cursor over the webgui. (sidenote : I think it should be Querying, not quering)

All the devices that exhibit this issue are Mikrotik SwOS devices (switches), and they have a dash in their hostnames. Also, their hostnames are not correct in the Devices list page, I see weird numbers instead. These numbers do not appear in the Details page.

Screen Shot 2024-08-19 at 9 30 48 PM Screen Shot 2024-08-19 at 9 36 20 PM Screen Shot 2024-08-19 at 9 38 09 PM

Environment

Debian GNU/Linux 12 (bookworm), Raspberry Pi 3

Anything else?

No response

leiweibau commented 2 months ago

Unfortunately, I can't help much at this point, as I have to rely on pull requests for the "microtik import". I do not own these devices myself. The only way I can currently see to possibly gain some insight into the problem would be to take a look at your database. Because it may not necessarily have to end up on GitHub, I offer to send it to leiweibau@gmail.com if you like. However, I can't promise you whether I'll be able to find and fix the problem.

stanelie commented 2 months ago

Hello.

I sent you the database. I hope you can find the problem.

Thanks!

On Tue, Aug 20, 2024, 00:31 leiweibau @.***> wrote:

Unfortunately, I can't help much at this point, as I have to rely on pull requests for the "microtik import". I do not own these devices myself. The only way I can currently see to possibly gain some insight into the problem would be to take a look at your database. Because it may not necessarily have to end up on GitHub, I offer to send it to @.*** if you like. However, I can't promise you whether I'll be able to find and fix the problem.

— Reply to this email directly, view it on GitHub https://github.com/leiweibau/Pi.Alert/issues/358#issuecomment-2297943932, or unsubscribe https://github.com/notifications/unsubscribe-auth/AAWMR5O3KJOHXAQX2DCEV5LZSLBCLAVCNFSM6AAAAABMY4SMUOVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZDEOJXHE2DGOJTGI . You are receiving this because you authored the thread.Message ID: @.***>

leiweibau commented 2 months ago

The database has arrived. I will take a look at it and test it.

stanelie commented 2 months ago

I did a test : I removed the dash from the hostname of one of my Mikrotik switches and I deleted it from the pi.alert database, so it was added back the next scan. I am now able to edit this device. So, it appears pi.alert does not like dashes in the hostname of devices.

Sidenote : I can now see and edit this device in pi.alert. However, the hostname field defaults to (unknown) instead of the published hostname after the device is first discovered.

leiweibau commented 2 months ago

I have now found some time to look at this problem.

In your case, for some reason unknown to me, numbers have been entered as the host name. The database has no problem with this, but the JavaScript, which loads the data into the fields when the page is loaded, does. My current fix is in the backend, which checks whether the hostname is a number or a floating point number. If this is the case, the addition “(Invalid Hostname)” is appended, which, funnily enough, makes it a valid hostname again. The backend now returns each value of the host name as a string. This should eliminate the error.

I haven't found a fix in the frontend yet, but I'll have another look later.

I can now see and edit this device in pi.alert. However, the hostname field defaults to (unknown) instead of the published hostname after the device is first discovered.

I don't really understand that. The attempt to determine a host name is actually only made for the host name “(unknown)”. I have no explanation here as to why a changed host name is set to “(unknown)” again.

stanelie commented 2 months ago

Shouldn't the hostname field be a string field and never be a number or float, regardless of what the content is?

On Fri, Aug 23, 2024, 04:29 leiweibau @.***> wrote:

I have now found some time to look at this problem.

In your case, for some reason unknown to me, numbers have been entered as the host name. The database has no problem with this, but the JavaScript, which loads the data into the fields when the page is loaded, does. My current fix is in the backend, which checks whether the hostname is a number or a floating point number. If this is the case, the addition “(Invalid Hostname)” is appended, which, funnily enough, makes it a valid hostname again.

I haven't found a fix in the frontend yet, but I'll have another look later.

I can now see and edit this device in pi.alert. However, the hostname field defaults to (unknown) instead of the published hostname after the device is first discovered.

I don't really understand that. The attempt to determine a host name is actually only made for the host name “(unknown)”. I have no explanation here as to why a changed host name is set to “(unknown)” again.

— Reply to this email directly, view it on GitHub https://github.com/leiweibau/Pi.Alert/issues/358#issuecomment-2306575913, or unsubscribe https://github.com/notifications/unsubscribe-auth/AAWMR5PXSR7APSUPHTPNRLDZS3XHDAVCNFSM6AAAAABMY4SMUOVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZDGMBWGU3TKOJRGM . You are receiving this because you authored the thread.Message ID: @.***>

leiweibau commented 2 months ago

That is correct. So far, nobody has had the problem that only numbers have been entered in the hostname field. It is also saved as a string in the database. When the data is read out, it is written to an array and converted into JSON, which is then transferred to the frontend. When reading out or converting to JSON, the host name became an INT or FLOAT if no letter was present because it was a mixed var. With the fix, it is now already determined when reading from the database that it is a string and not a mixed var.

stanelie commented 2 months ago

Ah! I understand. Thanks!

On Fri, Aug 23, 2024, 08:04 leiweibau @.***> wrote:

That is correct. So far, nobody has had the problem that only numbers have been entered in the hostname field. It is also saved as a string in the database. When the data is read out, it is written to an array and converted into JSON, which is then transferred to the frontend. When reading out or converting to JSON, the host name became an INT or FLOAT if no letter was present because it was a mixed var. With the fix, it is now already determined when reading from the database that it is a string and not a mixed var.

— Reply to this email directly, view it on GitHub https://github.com/leiweibau/Pi.Alert/issues/358#issuecomment-2306951871, or unsubscribe https://github.com/notifications/unsubscribe-auth/AAWMR5KOW4FSGYJ24ZYJFFTZS4QM7AVCNFSM6AAAAABMY4SMUOVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZDGMBWHE2TCOBXGE . You are receiving this because you authored the thread.Message ID: @.***>

leiweibau commented 2 months ago

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