Quantcast
Channel: chr.istoph, der Blog » rrd
Viewing all articles
Browse latest Browse all 3

Pool Temperatursennsor Teil 2

$
0
0

Da die Hardware nun Funktionierte wollte ich natürlich auch schöne RRD Graphen erstellen. Alles was man dafür braucht das Debian Weezey Image für den PI und Installiertes RRD:
apt-get install rrdtool

Dazu müssen die folgenden Module geladen sein:
modprobe wire
modprobe w1_gpio
modprobe w1_therm

Dieses Script such nun automatisch alle 1-Wire Sensoren ab und erstelle für sie ein RRD Graph.

#!/bin/bash

rrddata=/usr/local/rrd
rrdimg=/var/www/img

if [ ! -d "/sys/bus/w1/devices/w1_bus_master1/" ]; then
	echo "dir not exist: /sys/bus/w1/devices/w1_bus_master1/ kernel module laden?"
	echo "  modprobe wire; modprobe w1_gpio; modprobe w1_therm"
	exit 1
fi
if [ ! -e "/usr/bin/rrdtool" ]; then
	echo "rrdtool not installd"
	exit 1
fi

for dev in $(ls /sys/bus/w1/devices/w1_bus_master1/ | grep ^10 ); do 
	echo $dev
	if [ ! -e "$rrddata/$dev.rrd" ]; then
		echo "create: $rrddata/$dev.rrd"
		if [ ! -d "$rrddata" ]; then
			mkdir -pv "$rrddata"
		fi
		rrdtool create "$rrddata/$dev.rrd" --step 60 \
                        DS:celsius:GAUGE:600:U:U \
                        RRA:AVERAGE:0.5:1:2880 \
                        RRA:AVERAGE:0.5:60:700 \
			RRA:AVERAGE:0.5:240:720 \
			RRA:AVERAGE:0.5:1440:730 || exit 1
	fi

	temperatur=$(grep 't=' /sys/bus/w1/devices/w1_bus_master1/$dev/w1_slave | awk -F '=' '{print $2}')
	echo "$temperatur"
	/usr/bin/rrdupdate "$rrddata/$dev.rrd" N:$temperatur

	if [ ! -d $rrdimg ]; then
		mkdir -p "$rrdimg"
	fi
	/usr/bin/rrdtool graph $rrdimg/$dev.png -a PNG -w 1000 -h 300 -M -s -129600 -v "Grad Celsius" \
                "DEF:c=$rrddata/$dev.rrd:celsius:AVERAGE" \
                "CDEF:gc=c,1024,/" \
                "AREA:gc#00FF00:Grad Celsius" \
                "GPRINT:gc:LAST:Last \:    %3.2lf °C" \
                "GPRINT:gc:AVERAGE:Average \: %3.2lf °C" \
                "GPRINT:gc:MIN:Min \: %3.2lf °C" \
                "GPRINT:gc:MAX:Max \: %3.2lf °C"
done

exit 0

Das Script habe ich dann in crontab -e eingetragen, so das es Jede Minute ausgeführt wird. Damit meine CF Karte dabei nicht kaputt geschrieben wird habe ich für das erstelle Image eine tmpfs angelegt. Für mein Beispiel habe ich in der /etc/fstab
tmpfs /var/www/img tmpfs defaults,size=2M 0

10-0008028994f4


Viewing all articles
Browse latest Browse all 3

Latest Images

Pangarap Quotes

Pangarap Quotes

Vimeo 10.7.0 by Vimeo.com, Inc.

Vimeo 10.7.0 by Vimeo.com, Inc.

HANGAD

HANGAD

MAKAKAALAM

MAKAKAALAM

Doodle Jump 3.11.30 by Lima Sky LLC

Doodle Jump 3.11.30 by Lima Sky LLC

Trending Articles


Imágenes de Robin Hood para colorear


Dino Rey para colorear


Libros para colorear


Mandalas de flores para colorear


Dibujos para colorear de perros


Toro para colorear


People Walk Away Quotes, Inspire Quotes


Inspirational Tagalog quotes and Motivational English Quotes


Love Quotes Tagalog


RE: Mutton Pies (mely)


Pokemon para colorear


Winx Club para colorear


Girasoles para colorear


Sapos para colorear


Renos para colorear


Dromedario para colorear


Tagalog Quotes and More Love Quotes in Tagalog


Long Distance Relationship Tagalog Love Quotes


Tamis Ng tagumpay


Mga Tala sa “Unang Siglo ng Nobela sa Filipinas” (2009) ni Virgilio S. Almario





Latest Images

Pangarap Quotes

Pangarap Quotes

Vimeo 10.7.0 by Vimeo.com, Inc.

Vimeo 10.7.0 by Vimeo.com, Inc.

HANGAD

HANGAD

MAKAKAALAM

MAKAKAALAM

Doodle Jump 3.11.30 by Lima Sky LLC

Doodle Jump 3.11.30 by Lima Sky LLC