mirror of https://github.com/injetlee/Python.git
modify influxdb
parent
dab871591b
commit
0ab705ffbf
|
@ -7,27 +7,13 @@ import time,math,random
|
|||
#获取当前运行的pid
|
||||
p1=psutil.Process(os.getpid())
|
||||
|
||||
#打印本机的内存信息
|
||||
#print ('直接打印内存占用: '+(str)(psutil.virtual_memory))
|
||||
|
||||
#打印内存的占用率
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
from influxdb import InfluxDBClient
|
||||
import time,math,random
|
||||
while True:
|
||||
# for i in range(360):
|
||||
|
||||
# sin = round(random.random()*1000,2)
|
||||
# print (sin)
|
||||
a = psutil.virtual_memory().percent
|
||||
a = psutil.virtual_memory().percent #内存占用率
|
||||
|
||||
#本机cpu的总占用率
|
||||
b = psutil.cpu_percent(interval=1.0)
|
||||
b = psutil.cpu_percent(interval=1.0) #cpu占用率
|
||||
|
||||
json_body = [
|
||||
{
|
||||
|
@ -44,9 +30,7 @@ while True:
|
|||
}
|
||||
]
|
||||
client = InfluxDBClient('localhost', 8086, 'root', 'root', 'xxyyxx')
|
||||
print('aaaaaa')
|
||||
#client.create_database('xxyyxx',if_not_exists=False)
|
||||
print('bbbbb')
|
||||
client.create_database('xxyyxx',if_not_exists=False)
|
||||
client.write_points(json_body)
|
||||
#result = client.query('select value from cpu_load_short;')
|
||||
#print("Result: {0}".format(result))
|
||||
|
|
Loading…
Reference in New Issue