1

I am new to the programing and I am using already created scripts, I am trying to update my RRD database in python. I have manage to create below code which don’t come back to me with any errors but when I am trying to generate a graph it don’t contain any data.

#!/usr/bin/python

#modules
import sys

import os

import time

import rrdtool

import Adafruit_DHT as dht

#assign data
h,t = dht.read_retry(dht.DHT22, 22)

#display data
print 'Temp={0:0.1f}*C'.format(t, h)
print 'Humidity={1:0.1f}%'.format(t,h)

#update database
data = "N:h:t"
ret = rrdtool.update("%s/humidity.rrd" % (os.path.dirname(os.path.abspath(__file__))),data)

if ret:
 print rrdtool.error()
 time.sleep(300)

Below my data base specification:

#! /bin/bash
rrdtool create humidity.rrd \
--start "01/01/2015" \
--step 300 \
 DS:th_dht22:GAUGE:1200:-40:100 \
 DS:hm_dht22:GAUGE:1200:-40:100 \
 RRA:AVERAGE:0.5:1:288 \
 RRA:AVERAGE:0.5:6:336 \
 RRA:AVERAGE:0.5:24:372 \
 RRA:AVERAGE:0.5:144:732 \
 RRA:MIN:0.5:1:288 \
 RRA:MIN:0.5:6:336 \
 RRA:MIN:0.5:24:372 \
 RRA:MIN:0.5:144:732 \
 RRA:MAX:0.5:1:288 \
 RRA:MAX:0.5:6:336 \
 RRA:MAX:0.5:24:372 \
 RRA:MAX:0.5:144:732 \
Avihoo Mamka
  • 4,656
  • 3
  • 31
  • 44
Obel
  • 11
  • 3

1 Answers1

0

rrdtool will silently ignore updates that are either too far apart or lie outside the predefined input range. I would add a logging feature to your code to see what you are trying to feed to rrdtool.

Tobi Oetiker
  • 5,167
  • 2
  • 17
  • 23