mikaku / Monitorix

Monitorix is a free, open source, lightweight system monitoring tool.
https://www.monitorix.org
GNU General Public License v2.0
1.12k stars 167 forks source link

fs I/O activity graph not working for (hotplugged) USB drives #418

Closed H-Sachse closed 2 years ago

H-Sachse commented 2 years ago

I have an issue with the fs I/O activity graph not logging data when the drive is not there when monitorix starts.

Here's the log:

Sat Mar 26 08:33:38 2022 - Starting Monitorix version 3.14.0 (pid 574).
Sat Mar 26 08:33:38 2022 - Loaded main configuration file '/etc/monitorix/monitorix.conf'.
Sat Mar 26 08:33:38 2022 - Loading extra configuration file '/etc/monitorix/conf.d/00-debian.conf'.
Sat Mar 26 08:33:38 2022 - Loading extra configuration file '/etc/monitorix/conf.d/10-avconvpi.conf'.
Sat Mar 26 08:33:38 2022 - Initializing graphs.
Sat Mar 26 08:33:38 2022 - disk::disk_init: ERROR: invalid or inexistent device name '/dev/disk/by-id/usb-WDC_WD20_EARX-00MMMB0_152D00539000-0:0'.
Sat Mar 26 08:33:38 2022 - disk::disk_init: ERROR: invalid or inexistent device name '/dev/disk/by-id/usb-WDC_WD20_EARX-00PASB0_152D00539000-0:1'.
Sat Mar 26 08:33:38 2022 - disk::disk_init: ERROR: invalid or inexistent device name '/dev/disk/by-id/usb-WDC_WD30_PURX-64P6ZY0_152D00539000-0:2'.
df: /mnt/WD20EARX-2TB-SN11: No such file or directory
Sat Mar 26 08:33:38 2022 - fs::fs_init: Unable to detect the device name of '/mnt/WD20EARX-2TB-SN11', I/O stats won't be shown in graph. If this is really a mount point then consider using <devmap> to map it manually to a device name.
df: /mnt/WD20EARX-2TB-SN91: No such file or directory
Sat Mar 26 08:33:38 2022 - fs::fs_init: Unable to detect the device name of '/mnt/WD20EARX-2TB-SN91', I/O stats won't be shown in graph. If this is really a mount point then consider using <devmap> to map it manually to a device name.
df: /mnt/WD30PURX-3TB-SNC3: No such file or directory
Sat Mar 26 08:33:39 2022 - fs::fs_init: Unable to detect the device name of '/mnt/WD30PURX-3TB-SNC3', I/O stats won't be shown in graph. If this is really a mount point then consider using <devmap> to map it manually to a device name.
Sat Mar 26 08:33:39 2022 - Generating the 'index.html' file.
Sat Mar 26 08:33:39 2022 - WARNING: the HTTP built-in server has authentication disabled.
HTTPServer: You can connect to your server at http://localhost:8080/
Sat Mar 26 08:33:39 2022 - Started HTTP built-in server (pid 593).
Sat Mar 26 08:33:39 2022 - Ok, ready.

and here's the graph: grafik

The fs usage graph has no issue: grafik

here's my config from conf.d:

<fs>
    <list>
        0 = /, /boot, /mnt/WD20EARX-2TB-SN11, /mnt/WD20EARX-2TB-SN91, /mnt/WD30PURX-3TB-SNC3
    </list>
    <desc>
    </desc>
    <devmap>
        / = mmcblk0p2   
    </devmap>
    rigid = 2, 0, 2, 0
    limit = 100, 1000, 100, 1000
        use_nan_for_missing_data = y
        gap_on_all_nan = y
    <alerts>
    </alerts>
</fs>

The drives with problems are in an external 4-bay hot-swap USB enclosure and are mounted via udev rule so they may not yet be mounted when monitorix starts. I did reboot the affected computer at the time where the gap is visible in the graph. To fix the issue, a restart of monitorix is necessary. I did another reboot later and the problem was there again and was fixed with a restart of monitorix. It would be nice if the fs script would determine the device name when a mount comes online, not only on startup.

mikaku commented 2 years ago

Please, check the latest version of fs.pm, and let me know if it works as expected.

Don't forget to add the new option has_removable_devices in your <fs> section:

<fs>
...
        has_removable_devices = y
...
</fs>

This option will force a device name recalculation on every new update.

H-Sachse commented 2 years ago

Sorry for the late response. Seems to work OK. Thanks for the fix.