獲取磁盤目錄監控腳本
[root@k8s-master01 data]# cd /usr/local/zabbix/shell/
[root@k8s-master01 shell]# cat disk_file_discover.sh
#!/bin/bash
# Auto: hanye
# Time: 2020-01-14
##############################
DISK=($(df -h |grep -v "Filesystem"|awk '{print $6}'))
printf '{\n'
printf '\t"data":[\n'
for((i=0;i<${#DISK[@]};++i))
{
num=$(echo $((${#DISK[@]}-1)))
if [ "$i" != ${num} ];
then
printf "\t\t{ \n"
printf "\t\t\t\"{#DISK}\":\"${DISK[$i]}\"},\n"
else
printf "\t\t{ \n"
printf "\t\t\t\"{#DISK}\":\"${DISK[$num]}\"}]}\n"
fi
}
配置zabbix_agented.conf
[root@k8s-master01 shell]# cat /usr/local/zabbix/etc/zabbix_agentd.conf
新增
#磁盤目錄監控
UserParameter=disk.discover,/usr/local/zabbix/shell/disk_file_discover.sh
導入模板
模板文件: https://pan.baidu.com/s/17fPpo7zkCt5rlUDwtbvE7g
提取碼:1ok2