監(jiān)控服務(wù)器網(wǎng)卡使用率在python怎么實現(xiàn)?
提問人:楊紫紅發(fā)布時間: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 "當前登錄用戶:",users[0].name
#時間
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 "當前登錄用戶:",users[0].name
#時間
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ù)查找其他問題的答案?
相關(guān)視頻回答
點擊加載更多評論>>