Due to project requirements: a need to monitor files in a directory has been created in the specified time period, so the next will show how to implement this requirement. Assume that the directory is: / home / monitor / test
File name:
ADAPTER_CP0006_GLP_INFO.20190701和ADAPTER_CP0006_GLP _INFO.20190701.ok
Specified time is: 7:00
Zabbix monitored side configuration:
1, in /usr/local/zabbix/etc/zabbix_agentd.conf.d/ directory operations:
vim file_status.conf
UserParameter=files.status,/usr/bin/sh/usr/local/zabbix/scripts/file_check.sh $1
2, in operation / usr / local / zabbix / scripts directory (due to the project requirements, so I get the number of files on the list):
l #!/bin/bash
l # Get the current date
l data=date -d "-1 day" +"%Y%m%d"
l # monitoring needs is to get the day before the day
l filestatus=`sudo ls /home/monitor/test | grep"$1[.]$data" | wc -l`
The number of statistical documents whether l # 2
l if [[ "$file_status" == 2 ]]; then
l echo "OK"
L presence
l echo "Failed"
l fi of the file you just created authorization:
chown zabbix: file_status.conf
chown zabbix: file_check.sh
chmod +x file_check.sh
3, restart zabbix_agentd:
service zabbix_agentd restart
4, add monitoring, production monitoring template items and triggers zabbix web interface:
Monitoring items are as follows:
Triggers are as follows:
5, see the latest data:
6, see the problem:
7. Note: Due to the flip-flop, flip-flop when the time exceeds the set time, the problem will be automatically restored, so time flip-flop to be set a little too big.