本文整理匯總了Python中lib.ParamikoClass.check_cmd方法的典型用法代碼示例。如果您正苦於以下問題:Python ParamikoClass.check_cmd方法的具體用法?Python ParamikoClass.check_cmd怎麽用?Python ParamikoClass.check_cmd使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類lib.ParamikoClass
的用法示例。
在下文中一共展示了ParamikoClass.check_cmd方法的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。
示例1: checkmoduleinfo
# 需要導入模塊: from lib import ParamikoClass [as 別名]
# 或者: from lib.ParamikoClass import check_cmd [as 別名]
def checkmoduleinfo(moduleinfo):
host = moduleinfo[0]
moduleport = moduleinfo[1]
path = moduleinfo[2]
modulerunname = path.split('/')[-1]
p = ParamikoClass(host,port,user,passwd)
ps = "ps -ef|grep %s.jar|grep -v supervise|grep -v grep > /dev/null && echo '1' || echo '0'" %(modulerunname)
result_ps = p.check_cmd(ps).strip()
##add netstat
portnumber = len(moduleport.split(";"))
if portnumber == 2:
count = 0
for i in moduleport.split(";"):
cmd_netstat = "netstat -an|grep LISTEN|grep tcp|grep -w '%s'|wc -l" %(i)
result_netstat_count = int(p.check_cmd(cmd_netstat).strip())
count = count + result_netstat_count
if count == portnumber and result_ps == '1':
print "%s %s \033[1;32;40mstart OK\033[0m" %(host,modulerunname)
else:
print "%s %s \033[1;31;40mnot start\033[0m" %(host,modulerunname)
elif portnumber == 1:
cmd_netstat = "netstat -an|grep LISTEN|grep tcp|grep -w '%s' > /dev/null && echo '1' || echo '0'" %(moduleport)
result_netstat = p.check_cmd(cmd_netstat).strip()
if result_netstat == '1' and result_ps == '1':
print "%s %s \033[1;32;40mstart OK\033[0m" %(host,modulerunname)
else:
print "%s %s \033[1;31;40mnot start\033[0m" %(host,modulerunname)
示例2: checkmoduleinfo
# 需要導入模塊: from lib import ParamikoClass [as 別名]
# 或者: from lib.ParamikoClass import check_cmd [as 別名]
def checkmoduleinfo(moduleinfo):
host = moduleinfo[0]
publicname = moduleinfo[1]
startcmd = moduleinfo[2]
moduleport = moduleinfo[3]
startcmd4word = startcmd.split('/')[3]
p = ParamikoClass(host,port,user,passwd)
ps = "ps -ef|grep -w %s|grep -v supervise|grep -v grep > /dev/null && echo '1' || echo '0'" %(startcmd4word)
result_ps = p.check_cmd(ps).strip()
##add netstat
portnumber = len(moduleport.split(';'))
if publicname == 'pub_message_server' or 'message_redis':
if result_ps == '1':
print "%s %s \033[1;32;40mstart OK\033[0m" %(host,publicname)
else:
print "%s %s \033[1;31;40mnot start\033[0m" %(host,publicname)
else:
cmd_netstat = "netstat -an|grep LISTEN|grep tcp|grep -w '%s'|wc -l" %(moduleport)
result_netstat_count = int(p.check_cmd(cmd_netstat).strip())
if result_netstat_count == 1 and result_ps == '1':
print "%s %s \033[1;32;40mstart OK\033[0m" %(host,publicname)
else:
print "%s %s \033[1;31;40mnot start\033[0m" %(host,publicname)