# this method is used for monitoring
import time
import subprocess
import locale
import codecs
mylist = []
ps = subprocess.Popen('netstat -a', stdin=subprocess.PIPE, stdout=subprocess.PIPE, shell=True)
while True:
data = ps.stdout.readline()
if data == b'':
if ps.poll() is not None:
break
else:
mylist.append(data.decode(codecs.lookup(locale.getpreferredencoding()).name))
newlist = []
for i in mylist:
if i.find('192.168') > 0:
newlist.append(i)
newlist.sort()
print('Sum of requests from LAN:', len(newlist))
# this method is used for monitoring
import time
import subprocess
import locale
import codecs
def getstdout(p):
mylist = []
while True:
data = p.stdout.readline()
if data == b'':
if p.poll() is not None:
break
else:
mylist.append(data.decode(codecs.lookup(locale.getpreferredencoding()).name))
return mylist
while True:
ps = subprocess.Popen('netstat -an | findstr "8080"', stdin=subprocess.PIPE, stdout=subprocess.PIPE, shell=True)
resultlist = getstdout(ps)
if len(resultlist) >= 1:
pass
else:
print(time.strftime("%Y-%m-%d %H:%M:%S"))
subprocess.Popen('taskkill.exe /f /im node.exe', shell=False) # 防止动作过快,把新建的程序整死了
time.sleep(3)
subprocess.Popen('start node D:\\app.js', shell=True)
time.sleep(10)
# this method is used for monitoring
import time
import subprocess
import locale
import codecs
def getstdout(p):
mylist = []
while True:
data = p.stdout.readline()
if data == b'':
if p.poll() is not None:
break
else:
mylist.append(data.decode(codecs.lookup(locale.getpreferredencoding()).name))
return mylist
while True:
ps = subprocess.Popen('netstat -an | findstr "8080"', stdin=subprocess.PIPE, stdout=subprocess.PIPE, shell=True)
resultlist = getstdout(ps)
if len(resultlist) >= 1:
pass
else:
print(time.strftime("%Y-%m-%d %H:%M:%S"))
subprocess.Popen('taskkill.exe /f /im node.exe', shell=False)
time.sleep(3)
pss = subprocess.Popen('start cmd.exe /k node app.js', stdin=subprocess.PIPE,
stdout=subprocess.PIPE, shell=True)
alist = getstdout(pss)
newlist = []
for i in alist:
if i.find('192.168') > 0:
newlist.append(i)
newlist.sort()
print('Sum of requests from LAN:', len(newlist))
time.sleep(10)
# this method is used for monitoring
import time
import subprocess
import locale
import codecs
import threading
alist = []
def getstdout(p, asy):
if asy:
alist.clear()
mylist = []
while True:
data = p.stdout.readline()
if data == b'':
if p.poll() is not None:
break
else:
if asy:
alist.append(data.decode(codecs.lookup(locale.getpreferredencoding()).name))
else:
mylist.append(data.decode(codecs.lookup(locale.getpreferredencoding()).name))
return mylist
while True:
ps = subprocess.Popen('netstat -an | findstr ""', stdin=subprocess.PIPE, stdout=subprocess.PIPE, shell=True)
resultlist = getstdout(ps, False)
if len(resultlist) >= :
newlist = []
for i in alist:
if i.find('.') > :
newlist.append(i)
newlist.sort()
print('Sum of requests from LAN:', len(newlist))
else:
print(time.strftime("%Y-%m-%d %H:%M:%S"))
subprocess.Popen('taskkill.exe /f /im node.exe', shell=False)
time.sleep()
pss = subprocess.Popen('start cmd.exe /k node app.js', stdin=subprocess.PIPE,
stdout=subprocess.PIPE, shell=True)
th = threading.Thread(target=getstdout, args=[pss, True])
th.start()
time.sleep()
机械节能产品生产企业官网模板...
大气智能家居家具装修装饰类企业通用网站模板...
礼品公司网站模板
宽屏简约大气婚纱摄影影楼模板...
蓝白WAP手机综合医院类整站源码(独立后台)...苏ICP备2024110244号-2 苏公网安备32050702011978号 增值电信业务经营许可证编号:苏B2-20251499 | Copyright 2018 - 2025 源码网商城 (www.ymwmall.com) 版权所有