1.zabbix_agentd.conf
UserParameter=custom.pathStrChkSum[*],/etc/zabbix/scripts/functions.sh $1 $2 $3 $4 $5 $6 $7 $8 $9
2.function.sh
function pathCmdChksum(){
case $1 in
str)
cmd=${@:2}
res=$(${@:2})
echo "$res"| md5sum | awk '{print $1}'
;;
esac
}
3.脚本执行结果
[root@x2 scripts]# ./functions.sh pcc str crontab -l
0580b09de901c361905977e4ba20ecda
4.agent执行结果
[root@x2 scripts]# zabbix_agentd -t custom.pathStrChkSum[pcc,str,crontab,-l]
custom.pathStrChkSum[pcc,str,crontab,-l] [t|0580b09de901c361905977e4ba20ecda]
5.server执行结果
bash-5.0# zabbix_get -s 192.168.68.168 -k custom.pathStrChkSum[pcc,str,crontab,-l]
68b329da9893e34099c7d8ad5cb9c940
UserParameter=custom.pathStrChkSum[*],/etc/zabbix/scripts/functions.sh $1 $2 $3 $4 $5 $6 $7 $8 $9
2.function.sh
function pathCmdChksum(){
case $1 in
str)
cmd=${@:2}
res=$(${@:2})
echo "$res"| md5sum | awk '{print $1}'
;;
esac
}
3.脚本执行结果
[root@x2 scripts]# ./functions.sh pcc str crontab -l
0580b09de901c361905977e4ba20ecda
4.agent执行结果
[root@x2 scripts]# zabbix_agentd -t custom.pathStrChkSum[pcc,str,crontab,-l]
custom.pathStrChkSum[pcc,str,crontab,-l] [t|0580b09de901c361905977e4ba20ecda]
5.server执行结果
bash-5.0# zabbix_get -s 192.168.68.168 -k custom.pathStrChkSum[pcc,str,crontab,-l]
68b329da9893e34099c7d8ad5cb9c940