十年网站开发经验 + 多家企业客户 + 靠谱的建站团队
量身定制 + 运营维护+专业推广+无忧售后,网站问题一站解决
#json脚本
#!/usr/bin/env python
import os
import json
data = []
command="ps aux | grep bz-tw-and-s | awk '{print $11}' | awk -F'/' '{print $2}'| grep -v '^$'"
service = os.popen('%s' % command ,'r').readlines()
for service in service:
service_name = ''.join(service).strip()
data += [{'{#SITENAME}': service_name}]
print json.dumps({'data':data},sort_keys=True,indent=7,separators=(',',':'))
#监控端口
#!/usr/bin/env python
import os
import sys
service_name = sys.argv[1]
process_command = "ps aux | grep %s | grep -v grep | awk '{print $2}' | wc -l" % service_name
os.system(process_command)
#!/usr/bin/env python
import os
mongo_port=os.popen('netstat -tlnp | grep mongod').readlines()
if mongo_port == []:
print 1
else:
print 0