summaryrefslogtreecommitdiff
path: root/envmon/rrdlog.py
blob: 4dd47081fb2a2412e2c06e35a8ba1616fd960c02 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
import rrdtool
import os

class TempLog(object):
	def __init__(self, name):
		self.name = name
		if not os.path.exists(self.name):
			rrdtool.create(self.name, 'DS:temperature:GAUGE:600:U:U',
				'RRA:AVERAGE:0.5:1:17280', # Keep 5min snapshots for the last two months
				'RRA:AVERAGE:0.5:12:87660', # Keep 1h averages for 10 years (as if...)
			)
	def update(self, temperature):
		rrdtool.update(self.name, 'N:%f' % temperature)