forked from bendikwa/igrill
-
Notifications
You must be signed in to change notification settings - Fork 0
/
igrill_check.py
31 lines (23 loc) · 902 Bytes
/
igrill_check.py
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
import json
from checks import AgentCheck
DATA_FILE = '/tmp/igrill.json'
CONFIG_PATH = '/home/pi/.datadog-agent/conf.d/igrill.yaml'
class IGrillCheck(AgentCheck):
def read_sensor_data(self):
with open(DATA_FILE, 'r') as f:
data = json.loads(f.read())
return data
def check(self, instance):
data = self.read_sensor_data()
for probe_num in range(1, 5):
self.gauge(
'igrill.sensor.temperature',
data['temperature'][str(probe_num)],
tags=['igrill', 'probe:{}'.format(probe_num)])
self.gauge('igrill.battery', data['battery'], tags=['igrill'])
if __name__ == '__main__':
check, instances = IGrillCheck.from_yaml(CONFIG_PATH)
for instances in instances:
print '\nRunning check'
check.check(instance)
print 'Metrics: {}'.format(check.get_metrics())