friendica (DFRN) - Link zum Originalbeitrag

Daten der Wetterstation in Zabbix einbinden


Ich habe eine Ecowitt-Wetterstation und möchte die Daten in Zabbix integrieren. Dazu besorgt man sich erst einmal zwei Keys über die Ecowitt-Webseite --> Dein Konto --> User Profile. Den Application-Key und den Api-Key. Das geht in Sekunden. Jetzt benötigt man noch die MAC-Adresse der Wetterstation. Die MAC-Adresse findet man z.B. bei seinem DHCP-Server als vergebene Adresse.

Nun kann man mit einem Script die Daten der Wetterstation in Zabbix einbinden. Um die Daten abzuholen nutzt man diesen Befehl:
curl 'https://api.ecowitt.net/api/v3/device/real_time?application_key=DEIN_KEY&api_key=DEINE_API&mac=DEINE_MAC&temp_unitid=1&pressure_unitid=3&rainfall_unitid=12&wind_speed_unitid=7&call_back=all'

Diese Daten bereite ich auf und schicke sie in eine Datenbank (Script):

DBHOST="IP_DES_DB_SERVERS"
DBUSER="DB_USER"
PASS="DB_PASS"
DB="DBNAME"

DATEN=$(curl 'https://api.ecowitt.net/api/v3/device/real_time?application_key=DEIN_KEY&api_key=DEINE_API&mac=DEINE_MAC&temp_unitid=1&pressure_unitid=3&rainfall_unitid=12&wind_speed_unitid=7&call_back=all')

DATE=`date +%Y-%m-%d`
TIME=`date +%H:%M`
TIMESTAMP=$( echo $DATEN | cut -d ":" -f8 | cut -d'"' -f2)
ITEMP=$( echo $DATEN | cut -d ":" -f31 | cut -d'"' -f2 )
IHUM=$( echo $DATEN | cut -d ":" -f35 | cut -d'"' -f2 )
ATEMP=$( echo $DATEN | cut -d ":" -f10 | cut -d'"' -f2 )
AHUM=$( echo $DATEN | cut -d ":" -f26 | cut -d'"' -f2 )
QNH=$( echo $DATEN | cut -d ":" -f91 | cut -d'"' -f2 )
WINDSPEED=$( echo $DATEN | cut -d ":" -f78 | cut -d'"' -f2 )
WINDDIR=$( echo  $DATEN | cut -d ":" -f86 | cut -d'"' -f2 )
CHILLTEMP=$( echo $DATEN | cut -d ":" -f14 | cut -d'"' -f2 )
RAIN=$( echo $DATEN | cut -d ":" -f53 | cut -d'"' -f2 )
RAIN_H=$( echo $DATEN | cut -d ":" -f61 | cut -d'"' -f2 )
RAIN_W=$( echo $DATEN | cut -d ":" -f65 | cut -d'"' -f2 )
RAIN_M=$( echo $DATEN | cut -d ":" -f69 | cut -d'"' -f2 )
RAIN_Y=$( echo $DATEN | cut -d ":" -f73 | cut -d'"' -f2 )
DEWPOINT=$( echo $DATEN | cut -d ":" -f22 | cut -d'"' -f2 )
SOLAR=$( echo $DATEN | cut -d ":" -f40 | cut -d'"' -f2 )
UVI=$( echo $DATEN | cut -d ":" -f44 | cut -d'"' -f2 )

SQL="INSERT INTO wetter VALUES (0,'$DATE','$TIME','$TIMESTAMP','$ITEMP','$IHUM','$ATEMP','$AHUM','$QNH','$WINDSPEED','$WINDDIR','$CHILLTEMP','$RAIN','$DEWPOINT','$SOLAR','$UVI','$RAIN_M','$RAIN_Y','$RAIN_H','$RAIN_W')"

mysql --host="$DBHOST" -u "$DBUSER" -p"$PASS" -D "$DB" <<EOF
        $SQL;
EOF

exit 0


Auf dem Zabbix-Server ist eine ODBC-Connection eingerichtet:

[wetter]
Description = Auslesen der Wetterdaten
Driver      = MariaDB Unicode
Server      = DE_SERVER
User        = DB_USER
Password    = DB_PASS
Port        = 3306
Database    = DBNAME

Nun wird ein Item in Zabbix (auf dem Zabbix-Server) konfiguriert:


Weitere Items für Innentemperatur, Luftfeuchtigkeit, Sonne usw. werden wie oben gezeigt sinngemäß erstellt.

Damit kann man nun weiter arbeiten und z.B eine Map erstellen:

Andreas vom Zwenkauer See hat dies geteilt.