- [[email protected] ~]# cat monitor.py # ! /usr/bin / env python import os process = "/tmp/sshd.lock"os.system("ps -ef|grep sshd|grep -v grep>%s" % process) if not(os.path.getsize(process)) : print("no running")
- else: print("running")[[email protected] ~]# python monitor.py running[[email protected] ~]#
反思:返回值可以设置成 1 或者 0 然后结合 zabbix 做监控
来源: http://www.bubuko.com/infodetail-2231498.html