[Howto] Low Level Discovery (LLD) of disks with Zabbix and FreeBSD

posted in: computer | 0

you have to create a user parameter, which starts a “disk-search”-script on the host. This script searches for the disks and outputs a list (in json notification).

 

#discovery-disks.sh
#!/bin/sh
disks=`ls -l /dev/*da* | awk '{print $NF}' | awk -F "/" '{print $NF}'`
first="1"

echo "{"
echo "  \"data\":["

for disk in $disks
do
  if [ "$first" -eq "0" ]
  then
  printf ",\n"
  fi

  first="0"
  printf "    {\"{#DEVICE}\":\"$disk\"}"
done

printf "\n  ] \n}"

 

 

#zabbix_agentd.conf
UserParameter = discovery.disks, discovery-disks.sh

 

Now restart the zabbix-agentd and test the script output interactively:

shell> zabbix_get -s 192.168.0.100 -k "discovery.disks"

{
 "data":[
 {"{#DEVICE}":"ada0"},
 {"{#DEVICE}":"ada1"},
 {"{#DEVICE}":"da0"},
 {"{#DEVICE}":"da1"}
 ]
}

 

If everything is in order, you can now use this user-parameter (key=discovery.disks) in an discovery-rule in zabbix. The substitution name for the devices is “{#DEVICE}”