Tomado de aquí:
http://sebastianhemel.blogspot.com/2016/01/raspberry-pi-monitoring-mit-mrtg-und.html
Antes de instalar cualquier cosa hay que activar el sistema de 1wire en la Raspberry. Para lograr esto hay que editar el archivo
nano /boot/config.txt
Agregar
dtoverlay=w1-gpio
Esto hace que se active el gpio4, es decir el pin número 7 en el header
apt-get install mrtg mrtg-rrd rrdtool snmp snmpd
Make /etc/mrtg.cfg owned by and readable only by root? ⇒ NO ↵
cd /var/
mkdir www
cd /var/www
mkdir mrtg
mkdir -p /var/www/cgi-bin
ln -s /usr/lib/cgi-bin/mrtg-rrd.cgi /var/www/cgi-bin/mrtg-rrd.cgi
chown -R www-data:www-data /var/www/*
sed -i ‘s|import Socket6;|Socket6->import(qw(inet_pton getaddrinfo));|’ /usr/share/perl5/SNMP_Session.pm
mv /etc/mrtg.cfg /etc/mrtg.cfg.bak
cd /home/pi
su pi
mkdir ~/graph
cd /home/pi/graph
nano temp-mrtg-update.sh
#!/bin/sh
# Temperatur von Sensor auslesen
# (c) Sebastian Hemelsensor=”/sys/bus/w1/devices/28-00000511590a/w1_slave”
if [ -f $sensor ]
then
sensorraw=`cat $sensor`
crc=`echo $sensorraw | cut -f2 -d= | cut -c4-6`
if [ “$crc” = “YES” ]
then
tempraw=`echo $sensorraw | cut -f3 -d=`
temp=`echo “scale=3; $tempraw / 1000” | bc`
#temp=`echo “scale=2; $tempraw / 1000” | bc`# Update database
#echo $temp
printf “%04.2f” $temp
echo 0
echo 0
echo temperature
fi
fi
chmod 750 /home/pi/graph/temp-mrtg-update.sh
sudo cfgmaker –global “Options[_]: growright” –global “IconDir: /mrtg” –global “WriteExpires: Yes” –global “Language: german” –global “RunAsDaemon: yes” –global “EnableIPv6: no” –global “LogFormat: rrdtool” –global “Interval: 1” ‘–if-filter=$if_admin && $default_iftype’ –output /etc/mrtg.cfg public@localhost
editar mrtg.cfg
Global Config Options
# for UNIX
# WorkDir: /home/http/mrtg# for Debian
HtmlDir: /var/www/mrtg
WorkDir: /var/www/mrtg
Imagedir: /var/www/mrtg# or for NT
# WorkDir: c:\mrtgdata### Global Defaults
# to get bits instead of bytes and graphs growing to the right
# Options[_]: growright, bitsEnableIPv6: no
Options[_]: growright
IconDir: /mrtg
WriteExpires: Yes
Language: german
RunAsDaemon: yes
EnableIPv6: no
LogFormat: rrdtool
Interval: 1#####################################################################
# System: DS18S20 Temperatur Sensor
# Contact: root
# Location: attached to Raspberry Pi
#####################################################################
### DS18S20 Temperatur SensorIngolstadt
TimeStrPos[temp_ingolstadt]: RU
Target[temp_ingolstadt]: `/home/pi/graph/temp-mrtg-update.sh`
Options[temp_ingolstadt]: gauge,growright,nopercent,expscale,transparent
Title[temp_ingolstadt]: Temperatur Ingolstadt
PageTop[temp_ingolstadt]: <h1>Temperatur Ingolstadt</h1>
MaxBytes[temp_ingolstadt]: 60
#Unscaled[temp_ingolstadt]: ymwd
Step[temp_ingolstadt]: 60
Legend1[temp_ingolstadt]: Gemessene Temperatur in Ingolstadt
LegendI[temp_ingolstadt]: Aussentemperatur
LegendO[temp_ingolstadt]:
YLegend[temp_ingolstadt]: Grad Celsius
ShortLegend[temp_ingolstadt]: Grad °C
sudo cp /usr/share/mrtg/* /var/www/mrtg/
sudo env LANG=C /usr/bin/mrtg /etc/mrtg.cfg