Zabbix DirSize folder size monitoring
LEGACY CONTENT! See actual Ansible repository!
Discovery rule reads the list of configured folders on the client (/etc/zabbix/dirsize-list).
Data item (get) triggers the calculation and value sending to the trapper.
Template: [template_linux_dirsize] FIXFILE template_linux_dirsize.zip
Folder list discovery period: 1 hour.
Value polling period: 20 minutes.
Add to the agent configuration
# remote commands must be allowed
EnableRemoteCommands=1
# Active Server is required
ServerActive=zabbix.domain.my
#
UserParameter=dirsize.getlist,/etc/zabbix/scripts/dirsize-getlist.sh
/etc/zabbix/dirsize-list
(must end with a newline)
/etc/zabbix/scripts/dirsize-getlist.sh
#!/bin/bash
echo '{ "data":[ '
echo '{"HEADER":"DOLL" }'
while read LINE
do
echo ',{"{#DIRPATH}":"'$LINE'"}'
done < /etc/zabbix/dirsize-list
echo '] }'
Add to /etc/sudoers:
# CentOS 6.8
zabbix<>ALL=(ALL) NOPASSWD: /usr/bin/du
# Debian 8 (jessie)
zabbix ALL=(ALL:ALL) /usr/bin/du
/etc/zabbix/scripts/dirsize-get.sh
#!/bin/bash
DIRLIST='/etc/zabbix/dirsize-list'
send2zabbix() {
KEY=$1
VALUE=$2
/usr/bin/zabbix_sender -c /etc/zabbix/zabbix_agentd.conf -k $KEY -o $VALUE >/dev/null 2>&1
}
while read DIR
do
if [ -d $DIR ]
then
send2zabbix dirsize.get[$DIR] `sudo du -B1 --max-depth 0 $DIR | awk '{print $1}'` &
fi
done < $DIRLIST
wait