-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtemp.py
More file actions
36 lines (27 loc) · 806 Bytes
/
Copy pathtemp.py
File metadata and controls
36 lines (27 loc) · 806 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
from w1thermsensor import W1ThermSensor
from influxdb import InfluxDBClient
#Define Sensor
sensor = W1ThermSensor()
#Grag Current Temp in F
temp = sensor.get_temperature(W1ThermSensor.DEGREES_F)
#Define influxdb stuff
host='192.168.99.118'
port='8086'
dbname = 'cacti2'
query = 'select value from cpu_load_short;'
client = InfluxDBClient(host=host, port=port, database=dbname)
json_body = [
{
"tags": {
"host": "pi_probe",
},
"measurement": "server_room_temp",
"fields": {
"Float_value": temp,
}
}
]
print("Write points: {0}".format(json_body))
client.write_points(json_body)
print("Queying data: " + query)
result = client.query(query)