zfs_exporter
zfs_exporter copied to clipboard
improving command error message info
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"
Please also apply these changes to the zfs execution https://github.com/pdf/zfs_exporter/blob/30f2d5a069cfff3021f498e8bf4bf2cf82097af0/zfs/zfs.go#L78
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()
ping @pdf, Could you give some suggestions or merge this
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 wrongAnd the error I encountered
libzfs.so.4: cannot open shared object file
will be catched atcmd.Wait()
notcmd.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
I see, just done it @pdf