zfs_exporter icon indicating copy to clipboard operation
zfs_exporter copied to clipboard

improving command error message info

Open zhangzhiqiangcs opened this issue 1 year ago • 5 comments

When zfs_exporter is used in containers, more error message will help uesr know the container is missing common shared library like zfsutils-linux.

currently, the error message like

ts=2024-01-13T02:59:35.655Z caller=zfs.go:219 level=error msg="Executing collector" status=error collector=dataset-filesystem durationSeconds=0 err="exit status 127"
ts=2024-01-13T02:59:35.655Z caller=zfs.go:219 level=error msg="Executing collector" status=error collector=dataset-snapshot durationSeconds=0 err="exit status 127"
ts=2024-01-13T02:59:35.655Z caller=zfs.go:219 level=error msg="Executing collector" status=error collector=dataset-volume durationSeconds=0 err="exit status 127"
ts=2024-01-13T02:59:35.655Z caller=zfs.go:219 level=error msg="Executing collector" status=error collector=pool durationSeconds=0 err="exit status 127"

after this pr, the error message is like

ts=2024-01-13T02:59:04.950Z caller=zfs.go:219 level=error msg="Executing collector" status=error collector=pool durationSeconds=0 err="Failed to wait command /usr/sbin/zpool list -Ho name, err output: \"zpool: error while loading shared libraries: libzfs.so.4: cannot open shared object file: No such file or directory\n\": exit status 127"
ts=2024-01-13T02:59:04.950Z caller=zfs.go:219 level=error msg="Executing collector" status=error collector=dataset-filesystem durationSeconds=0 err="Failed to wait command /usr/sbin/zpool list -Ho name, err output: \"zpool: error while loading shared libraries: libzfs.so.4: cannot open shared object file: No such file or directory\n\": exit status 127"
ts=2024-01-13T02:59:04.951Z caller=zfs.go:219 level=error msg="Executing collector" status=error collector=dataset-snapshot durationSeconds=0 err="Failed to wait command /usr/sbin/zpool list -Ho name, err output: \"zpool: error while loading shared libraries: libzfs.so.4: cannot open shared object file: No such file or directory\n\": exit status 127"

zhangzhiqiangcs avatar Jan 13 '24 03:01 zhangzhiqiangcs

Please also apply these changes to the zfs execution https://github.com/pdf/zfs_exporter/blob/30f2d5a069cfff3021f498e8bf4bf2cf82097af0/zfs/zfs.go#L78

pdf avatar Jan 23 '24 13:01 pdf

Please also apply these changes to the zfs execution

https://github.com/pdf/zfs_exporter/blob/30f2d5a069cfff3021f498e8bf4bf2cf82097af0/zfs/zfs.go#L78

@pdf As far as I know, if c.Start() fails,usually means fork/exec error, we can not get the stderr of the command. Please check and let me know If I was wrong

And the error I encountered libzfs.so.4: cannot open shared object file will be catched at cmd.Wait() not cmd.Start()

zhangzhiqiangcs avatar Jan 24 '24 01:01 zhangzhiqiangcs

ping @pdf, Could you give some suggestions or merge this

zhangzhiqiangcs avatar Feb 22 '24 11:02 zhangzhiqiangcs

Sorry for the delay, I've been travelling for work.

Please also apply these changes to the zfs execution https://github.com/pdf/zfs_exporter/blob/30f2d5a069cfff3021f498e8bf4bf2cf82097af0/zfs/zfs.go#L78

@pdf As far as I know, if c.Start() fails,usually means fork/exec error, we can not get the stderr of the command. Please check and let me know If I was wrong

And the error I encountered libzfs.so.4: cannot open shared object file will be catched at cmd.Wait() not cmd.Start()

What I meant was, please apply this logic to the call to zfs in that file as you have for the call to zpool in zpool.go

pdf avatar Feb 24 '24 21:02 pdf

I see, just done it @pdf

zhangzhiqiangcs avatar Feb 26 '24 08:02 zhangzhiqiangcs