modify influxdb

pull/6/head
injetlee 2016-06-24 09:36:57 +08:00
parent dab871591b
commit 0ab705ffbf
1 changed files with 3 additions and 19 deletions

View File

@ -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):
a = psutil.virtual_memory().percent #内存占用率
# sin = round(random.random()*1000,2)
# print (sin)
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))