監(jiān)控服務(wù)器cpu使用率在python怎么實(shí)現(xiàn)?
提問人:楊紫紅發(fā)布時(shí)間:2020-11-24
def cpu():
while True:
time.sleep(1)
cpu_liyonglv = psutil.cpu_percent()
print "當(dāng)前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 "當(dāng)前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ù)查找其他問題的答案?
相關(guān)視頻回答
點(diǎn)擊加載更多評(píng)論>>