重庆分公司,新征程启航
为企业提供网站建设、域名注册、服务器等服务
#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