监控服务器cpu使用率在python怎么实现?
提问人:杨紫红发布时间:2020-11-24
def cpu():
while True:
time.sleep(1)
cpu_liyonglv = psutil.cpu_percent()
print "当前cpu利用率:\033[1;31;42m%s%%\033[0m"%cpu_liyonglv
if cpu_liyonglv >15.0:
baojing()
def baojing():
i = 0
while i < 10 :
i += 1
time.sleep(0.5)
winsound.PlaySound("ALARM8",winsound.SND_ALIAS)
cpu()
while True:
time.sleep(1)
cpu_liyonglv = psutil.cpu_percent()
print "当前cpu利用率:\033[1;31;42m%s%%\033[0m"%cpu_liyonglv
if cpu_liyonglv >15.0:
baojing()
def baojing():
i = 0
while i < 10 :
i += 1
time.sleep(0.5)
winsound.PlaySound("ALARM8",winsound.SND_ALIAS)
cpu()
继续查找其他问题的答案?
相关视频回答
回复(0)
点击加载更多评论>>