監(jiān)控服務器cpu使用率在python怎么實現(xiàn)?
提問人:楊紫紅發(fā)布時間: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()
繼續(xù)查找其他問題的答案?
相關視頻回答
點擊加載更多評論>>