Skip to content

Commit

Permalink
modify influxdb
Browse files Browse the repository at this point in the history
  • Loading branch information
injetlee committed Jun 24, 2016
1 parent dab8715 commit 0ab705f
Showing 1 changed file with 3 additions and 19 deletions.
22 changes: 3 additions & 19 deletions CpuToInfluxdb.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,27 +7,13 @@
#获取当前运行的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 = [
{
Expand All @@ -44,9 +30,7 @@
}
]
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))
Expand Down

0 comments on commit 0ab705f

Please sign in to comment.