zabbix / community-templates

Zabbix Community Templates repository
https://share.zabbix.com
MIT License
1.25k stars 1.77k forks source link

template_zfs_on_linux, zfs.vdev.discovery not filtering "indirect" disks #325

Open leaskovski opened 5 months ago

leaskovski commented 5 months ago

With ZFS, if you remove a disk from a pool, and then add it back again, ZFS will create an "indirect" entries that then show up on discovery. See https://serverfault.com/questions/1102923/what-are-indirect-x-after-zpool-remove for more info on indirect entries.

The code in the conf file for the vdev discovery is currently...

# vdev discovery
UserParameter=zfs.vdev.discovery,/sbin/zpool list -Hv | grep '^[[:blank:]]' | egrep -v 'mirror|raidz' | awk '{print $1}' | sed -e '$ ! s/\(.*\)/{"{#VDEV}":"\1"},/' | sed -e '$  s/\(.*\)/{"{#VDEV}":"\1"}]}/' | sed -e '1  s/\(.*\)/{ \"data\":[\1/'

It should be...

# vdev discovery
UserParameter=zfs.vdev.discovery,/sbin/zpool list -Hv | grep '^[[:blank:]]' | egrep -v 'mirror|raidz|indirect' | awk '{print $1}' | sed -e '$ ! s/\(.*\)/{"{#VDEV}":"\1"},/' | sed -e '$  s/\(.*\)/{"{#VDEV}":"\1"}]}/' | sed -e '1  s/\(.*\)/{ \"data\":[\1/'