代码语言:javascript复制
[root@bogon ~]# 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")
[root@bogon ~]# python monitor.py
running
[root@bogon ~]#
反思:返回值可以设置成1 或者0 然后结合zabbix做监控