Hello,
If have been trying to get low level discovery rule script working for ZFS Pools discovery.
Files located in:
zfs-discovery.sh
Example of results(JSON format) when running script standalone (./zfs-discovery.sh):
zfs.conf
Problems when restarting zabbix agent:
When I change:
to
The script is running nice standalone but when restarting zabbix agent there are problems:
I'm not and expert with bash. Do not know how to proceed, advice is welcome!
If have been trying to get low level discovery rule script working for ZFS Pools discovery.
Files located in:
Code:
sideswipe: zabbix2_agentd.conf.d # pwd /usr/local/etc/zabbix2/zabbix2_agentd.conf.d sideswipe: zabbix2_agentd.conf.d # ll total 8 -rwxr-xr-x 1 root wheel 1463 Aug 20 19:23 zfs-discovery.sh* -rw-r--r-- 1 root wheel 304 Aug 20 19:04 zfs.conf
Code:
#!/bin/bash
#################################################################################################
# Script aimed for zabbix agent(s) of low level discovery rule script for ZFS Pools discovery #
# #
# Author: Neptunus from zabbix forum #
# #
#################################################################################################
################################################
# PARAMETERS THAT CAN BE MODIFIED BY THE USER
################################################
################################################
# Path to used utilities
################################################
BIN_ZPOOL="/sbin/zpool"
################################################
declare -a pools
#pools=(a b c)
n=0
#for i in $(/sbin/zpool list -H -o name) ; do
for i in $($BIN_ZPOOL list -H -o name) ; do
pools[$n]="$i"
#echo "Pool: $n = $i" #to confirm the entry
let "n= $n + 1"
done
# Get length of an array
length=${#pools[@]}
echo "{"
echo -e "\t\"data\":[\n"
for (( i=0; i<${length}; i++ ))
do
if [ $i == $length ]; then
echo -e "\t{ \"{#ZFSPOOL}\":\"${pools[$i]}\" }"
else
echo -e "\t{ \"{#ZFSPOOL}\":\"${pools[$i]}\" },"
fi
done
echo -e "\n\t]\n"
echo "}"
Code:
{
"data":[
{ "{#ZFSPOOL}":"zssddata" },
{ "{#ZFSPOOL}":"zstore" },
]
}
Code:
# ZFS checks # zpool(1M) status, parameters: zpool-name,property # parameters eg.: rpool,health # see zpool list -o for available properties UserParameter=zpool.status[*],zpool list -H -o $2 $1|sed -e 's/%//' UserParameter=zpool.discovery, /usr/local/etc/zabbix2/zabbix2_agentd.conf.d/zfs-discovery.sh
Code:
sideswipe: zabbix2_agentd.conf.d # /usr/local/etc/rc.d/zabbix_agentd restart zabbix_agentd not running? Starting zabbix_agentd. zabbix_agentd [29353]: unknown parameter [BIN_ZPOOL] in config file [/usr/local/etc/zabbix2/zabbix2_agentd.conf.d/zfs-discovery.sh], line 17 /usr/local/etc/rc.d/zabbix_agentd: WARNING: failed to start zabbix_agentd
Code:
BIN_ZPOOL="/sbin/zpool" #for i in $(/sbin/zpool list -H -o name) ; do for i in $($BIN_ZPOOL list -H -o name) ; do
Code:
#BIN_ZPOOL="/sbin/zpool" for i in $(/sbin/zpool list -H -o name) ; do #for i in $($BIN_ZPOOL list -H -o name) ; do
Code:
sideswipe: zabbix2_agentd.conf.d # /usr/local/etc/rc.d/zabbix_agentd restart zabbix_agentd not running? Starting zabbix_agentd. zabbix_agentd [29374]: invalid entry [declare -a pools] (not following "parameter=value" notation) in config file [/usr/local/etc/zabbix2/zabbix2_agentd.conf.d/zfs-discovery.sh], line 21 /usr/local/etc/rc.d/zabbix_agentd: WARNING: failed to start zabbix_agentd
Comment