#json脚本#!/usr/bin/env pythonimport osimport jsondata = []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 pythonimport osimport sysservice_name = sys.argv[1]process_command = "ps aux | grep %s | grep -v grep | awk '{print $2}' | wc -l" % service_nameos.system(process_command)

#!/usr/bin/env pythonimport osmongo_port=os.popen('netstat -tlnp | grep mongod').readlines()if mongo_port == []: print 1else: print 0