Python 监控nginx服务是否正常
#!/usr/bin/env python import os, sys, time from time import strftime while True: try: ret = os.popen('ps -C nginx -o pid,cmd').readlines() if len(ret) <2: os.system("service nginx start") sys.exit(0) except Exception,ex: print strftime("%Y-%m-%r %H:%M") sys.exit(0)
作者: 东邪西毒
本文版权归作者和博客园共有,欢迎转载,但未经作者同意必须保留此段声明,且在文章页面明显位置给出原文链接,负责保留追究法律责任的权利。