監(jiān)控服務(wù)器網(wǎng)卡使用率在python怎么實(shí)現(xiàn)?
提問(wèn)人:楊紫紅發(fā)布時(shí)間:2020-11-24
#網(wǎng)絡(luò)使用率
count = psutil.net_io_counters()
print "發(fā)送字節(jié)數(shù):\033[1;31;42m%s\033[0mbytes,接收字節(jié)數(shù):\033[1;31;42m%s\033[0mbytes,發(fā)送包數(shù):%s,接收包數(shù)%s"%(count.bytes_sent,count.bytes_recv,count.packets_sent,count.packets_recv)
users = psutil.users()
print "當(dāng)前登錄用戶:",users[0].name
#時(shí)間
count = psutil.net_io_counters()
print "發(fā)送字節(jié)數(shù):\033[1;31;42m%s\033[0mbytes,接收字節(jié)數(shù):\033[1;31;42m%s\033[0mbytes,發(fā)送包數(shù):%s,接收包數(shù)%s"%(count.bytes_sent,count.bytes_recv,count.packets_sent,count.packets_recv)
users = psutil.users()
print "當(dāng)前登錄用戶:",users[0].name
#時(shí)間
curent_time = psutil.boot_time()
curent_time_1 = time.strftime("%Y-%m-%d %H:%M:%S",time.localtime(curent_time))
print curent_time_1
繼續(xù)查找其他問(wèn)題的答案?
相關(guān)視頻回答
點(diǎn)擊加載更多評(píng)論>>