#!/bin/bash # # # Munin plugin to show changing the ip address by ddclient. # The base frame is copied from the proftp plugin # ########################################################################################## # Folgende Eintraege in der Datei /etc/munin/plugin-conf.d/munin-node nicht vergessen ! # # Don't forget to add following lines to the file /etc/munin/plugin-conf.d/munin-node # # [quota] # # user root # ########################################################################################## # Parameters understood: # # config (required) # autoconf (optional - used by munin-config) # # # Magic markers (optional - used by munin-config and installation # scripts): # #%# family=auto #%# capabilities=autoconf MAXLABEL=20 if [ "$1" = "autoconf" ]; then echo yes exit 0 fi if [ "$1" = "config" ]; then echo 'graph_title IP Wechsel' echo 'graph_args --base 1000 -l 0' echo 'graph_vlabel täglicher IP Wechsel' echo 'graph_category network' echo 'ip_change.label IP Wechsel' echo 'graph_info Jeder IP-Wechsel der von DDCLIENT festgestellt wird erzeugt einen Wert von 1' exit 0 fi ################################################################################ # Beginn des modifizierten Skriptes - Beginning of the modified script # ################################################################################ # Nur fuer Testzwecke kann das - For testing only you can # Zeitfenster vergroessert werden resize the reference period if [ "${1//[^[:digit:]]}" != "" ]; then factor=${1//[^[:digit:]]} else factor=1 fi # Aktuelle Zeit in Sekunden (C-Format) - now in seconds (c-format) Timestamp=$(date +%s) # Zeitfenster in Sekunden - time slot in seconds let Timeslot=60*30*$factor # Referenzzeitpunkt berechnen - calculate the reference period let Ref_Timestamp=Timestamp-Timeslot # Zeitstempel der letzten Aktualisierung - timestampe of the last update Last_update=$(grep -i 'last update' /var/cache/ddclient/ddclient.cache) Last_update=${Last_update##*\(} Last_update=${Last_update%%\)} # Ausgabe für Munin - output for munin if [ "$Last_update" -gt "$Ref_Timestamp" ]; then echo "ip_change.value 1" else echo "ip_change.value 0" fi # Nur zum Testen - for testing only if [ "$factor" -gt 1 ]; then echo "======================== Nur fuer Testzwecke ======================" echo "Timestamp :" $Timestamp $(date -d "1970-01-01 UTC + $Timestamp seconds") echo "Ref_Timestamp:" $Ref_Timestamp $(date -d "1970-01-01 UTC + $Ref_Timestamp seconds") echo "Zeitfenster :" $((Timeslot/60)) Minuten echo "Last_update :" $Last_update $(date -d "1970-01-01 UTC + $Last_update seconds") echo "======================== for testing only ======================" fi