Dies ist eine alte Version des Dokuments!
RaspberryPi verschickt Jabber-Nachricht
Diese Anleitung bezieht sich auf den RaspberryPi,
ist aber in der Form auch auf anderen debianbasierten Systemen umsetzbar.
Mit dem Tool sendxmpp können Nachrichten an einen Jabber-Account geschickt werden.
===== Installation =====
Die Installation erfolgt mit root-Rechten:
<code text>
pi@raspberrypi ~ $ sudo bash
root@raspberrypi:/home/pi# apt-get install sendxmpp
</code>
===== Konfiguration =====
sendxmpp benötigt eine Konfigurationsdatei, in der Benutzername und Passwort steht.
Die Datei befindet sich im Home-Verzeichnis des Benutzers unter dem Name .sendxmpprc
<code>
# Konfigurationsdatei fuer sendxmpp
# Pfad /home/pi
benutzer@jabber.de passwort123456
</code>
===== Beispielskript =====
Dieses Beispielskript fragt verschiedene Parameter ab und versendet diese anschließend über sendsmpp an einen Jabber-Account.
<code>
#!/bin/bash
echo '*' > status.txt
echo 'Raspberry Pi Statusmeldung' » status.txt
echo '*' » status.txt
echo 'Zeitstempel:' » status.txt
date » status.txt
echo 'CPU Temperatur:' » status.txt
vcgencmd measure_temp » status.txt
echo 'Uptime:' » status.txt
uptime measure_temp » status.txt
echo 'Die IP-Adresse lautet momentan:' » status.txt
wget http://www.wieistmeineip.de -U „“ -qO - | egrep -o 'digit{1,3}\.digit{1,3}\.digit{1,3}\.digit{1,3}' | uniq » status.txt
echo '*' » status.txt
cat status.txt | sendxmpp -t empfänger@jabber.de
</code>
Das Skript kann auch beispielsweise per Cron-Job aufgerufen werden.
<code>
pi@raspberrypi ~ $ sudo bash
root@raspberrypi:/home/pi# crontab -l
# Edit this file to introduce tasks to be run by cron.
#
# Each task to run has to be defined through a single line
# indicating with different fields when the task will be run
# and what command to run for the task
#
# To define the time you can provide concrete values for
# minute (m), hour (h), day of month (dom), month (mon),
# and day of week (dow) or use '*' in these fields (for 'any').#
# Notice that tasks will be started based on the cron's system
# daemon's notion of time and timezones.
#
# Output of the crontab jobs (including errors) is sent through
# email to the user the crontab file belongs to (unless redirected).
#
# For example, you can run a backup of all your user accounts
# at 5 a.m every week with:
# 0 5 * * 1 tar -zcf /var/backups/home.tgz /home/
#
# For more information see the manual pages of crontab(5) and cron(8)
#
# m h dom mon dow command
0 * * * 0-6 /home/pi/scripts/statusmeldung.sh
5 * * * 0-6 /home/pi/scripts/statusmeldung.sh
10 * * * 0-6 /home/pi/scripts/statusmeldung.sh
15 * * * 0-6 /home/pi/scripts/statusmeldung.sh
20 * * * 0-6 /home/pi/scripts/statusmeldung.sh
25 * * * 0-6 /home/pi/scripts/statusmeldung.sh
30 * * * 0-6 /home/pi/scripts/statusmeldung.sh
35 * * * 0-6 /home/pi/scripts/statusmeldung.sh
40 * * * 0-6 /home/pi/scripts/statusmeldung.sh
45 * * * 0-6 /home/pi/scripts/statusmeldung.sh
50 * * * 0-6 /home/pi/scripts/statusmeldung.sh
55 * * * 0-6 /home/pi/scripts/statusmeldung.sh
</code>
===== Passende Clients für Android-Geräte =====
Zum Empfang bzw. zum Versenden von Jabbernachrichen mit einem Android-Gerät broucht man einen Client.
Hier gibt es einiges, wenn man im Google Play Store stöbert.
Getestet wurden z.B.:
Xabber (kostenlos)
Conversations (kostenpflichtig !)