RELATEED CONSULTING
相关咨询
选择下列产品马上在线沟通
服务时间:8:30-17:00
你可能遇到了下面的问题
关闭右侧工具栏

新闻中心

这里有您想知道的互联网营销解决方案
python编写json脚本监控端口
#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

网站栏目:python编写json脚本监控端口
本文链接:http://scpingwu.com/article/ieghss.html