AnalogJ / scrutiny

Hard Drive S.M.A.R.T Monitoring, Historical Trends & Real World Failure Thresholds
MIT License
5.33k stars 170 forks source link

[BUG] how to remove zombie data? #696

Open xinmans opened 1 month ago

xinmans commented 1 month ago

there is a zombie data wich not have any disk information, how to remove it from dashboard?

i use the delete device in “…” menu, but no response, how ? IMG_4142

kapsh commented 1 month ago

Can't say how that happened, but removing sounds like a lot of pain.

First you need to find scrutiny internal database. Assuming you running omnibus docker image it will be in ./config/scrutiny.db alongside docker-compose file. BACK IT UP right now, because everything below is my guesswork. Access db as sqlite3 --header scrutiny.db (install sqlite client if needed). Run query select * from devices; and find wrong device in output. Normal device_name values are sdb, sdc, etc, incorrect would be empty string or null. Run delete from devices where device_name is null or device_name = ''; to drop it. Check web interface again and if everything broke ­— restore that backup.

xinmans commented 1 month ago

not work sqlite> select * from devices where device_name is null or device_name = ''; sqlite>

Dashboard Drive health at a glance /DEV/ - Last Updated on May 01, 2024 - 08:00 STATUS Passed TEMPERATURE 39°C CAPACITY 0 B POWERED ON 2 years

xinmans commented 1 month ago

this no null device_name,but dashboard show /DEV/- column, what's wrong? What's the views sql of Dashboard?

sqlite> select host_id,device_name from devices; host_id|device_name truenas-d1581|sde truenas-d1581|sdg truenas-d1581|sdh truenas-d1581|sdf truenas-d1581|sdi truenas-d1581|sdc truenas-d1581|sdb truenas-d1581|sdd ubuntu-woniu|sda ubuntu-woniu|sdb ubuntu-woniu|sdc ubuntu-woniu|sdd pve-amd|nvme0 pve-synsea|sda pve-d1581|nvme1 ubuntu-woniu|sde pve-synsea|sdc pve-d1581|nvme0 pbs|sdd pbs|sdb pbs|sdc pbs|sde

kdruelle commented 5 days ago

I think something happened during the deletion it removed the entry in SQLite db but they are remaining data in influxdb for the device.

if it finds some data in influxdb that are not linked to a device in SQLite it create a zombie device in the frontend. See here : https://github.com/AnalogJ/scrutiny/blob/57dc5472659358db3bdf80844e20683c662a05a5/webapp/backend/pkg/database/scrutiny_repository.go#L409

xinmans commented 5 days ago

could you please fix this bug don't show the device data which not in SQLite db but in influxdb

kdruelle commented 1 day ago

I'm not the maintainer I don't know if there is valid reason to do so. But to deal with you issue you can delete data from influxDB for that device wwn with something like :

influx delete --bucket metrics --start 2014-11-19T10:14:57.843274736+01:00 --stop 2024-11-19T10:15:01.028711314+01:00 --predicate device_wwn=$YOUR_DEVICE_WWM --org scrutiny -t YOUR_TOKEN

influx delete --bucket metrics_weekly --start 2014-11-19T10:14:57.843274736+01:00 --stop 2024-11-19T10:15:01.028711314+01:00 --predicate device_wwn=$YOUR_DEVICE_WWM --org scrutiny -t YOUR_TOKEN

influx delete --bucket metrics_monthly --start 2014-11-19T10:14:57.843274736+01:00 --stop 2024-11-19T10:15:01.028711314+01:00 --predicate device_wwn=$YOUR_DEVICE_WWM --org scrutiny -t YOUR_TOKEN

influx delete --bucket metrics_yearly --start 2014-11-19T10:14:57.843274736+01:00 --stop 2024-11-19T10:15:01.028711314+01:00 --predicate device_wwn=$YOUR_DEVICE_WWM --org scrutiny -t YOUR_TOKEN

It worked for me