获取磁盘目录监控脚本

[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/1EkZDTod5SW5GoCk-5_X8nw 
提取码:ce0n 

3: Zabbix5.0自动发现磁盘目录监控

关联主机

3: Zabbix5.0自动发现磁盘目录监控
3: Zabbix5.0自动发现磁盘目录监控
3: Zabbix5.0自动发现磁盘目录监控