Zabbix Monitoring process Downtime
Business requirements Back-end process can be quickly pulled up in a short period of time, the business impact is small, but the development needs to see coredump, the needto monitor the PID changes, under the existing framework Zabbix can monitor and alarm;
of course Zabbix set alarm settings is no longer one by one
Set the path on each server /etc/zabbix/zabbix_agentd.conf : This example requires only piddiff.sh
userparameter=checkpid,sh/usr/local/script/piddiff.sh
userparameter=test,sh/usr/local/script/test.sh
userparameter=discovery.process,/usr/local/script/disprocess.sh
Userparameter=process.check[*],/usr/local/script/proc_check.sh $ $
/usr/local/script below to store scripts
Vim piddiff.sh
aapid for business monitoring ID
#/bin/sh
Onl_ok=1
Onl_cored=3
Dir=/usr/local/script
if [[!-F "$dir/old.txt"]];then
PS aux|grep aapid |grep-v grep|grep-v/bin/bash|awk ' {print $2,$11} ' > $dir/old.txt
Else
Fi
PS aux|grep aapid |grep-v grep|grep-v/bin/bash|awk ' {print $2,$11} ' > $dir/now.txt
if! Diff-q $dir/old.txt $dir/now.txt >/dev/null; Then
Echo $onl _cored
Diff-c $dir/old.txt $dir/now.txt > $dir/' Date ' +%y%m%d%h%m "' _diff.txt
Cat $dir/now.txt > $dir/old.txt
Else
Echo $onl _OK
Fi
A simple judgment script;
Zabbix30 seconds will crawl once, normal unchanged to 1, there is a change of 3, then the Zabbix crawl value of 3 indicates that the PID has changed, will issue an alarm;
Zabbix Settings:
The monitoring item template is added as follows:
Trigger: {Template OS Linux:checkpid.last ()}=3
Zabbix Monitor Business process changes