python監控進程
[[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://wsxxsl.blog.51cto.com/9085838/1951513
python監控進程