From 8daa48b454d5d222cf8d45a5d3a111b349d567a4 Mon Sep 17 00:00:00 2001 From: Jo Hartmann Date: Sun, 21 Sep 2008 15:55:46 +0200 Subject: [PATCH] Initial version --- plugins/other/ddclient | 86 ++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 86 insertions(+) create mode 100755 plugins/other/ddclient diff --git a/plugins/other/ddclient b/plugins/other/ddclient new file mode 100755 index 00000000..f5494942 --- /dev/null +++ b/plugins/other/ddclient @@ -0,0 +1,86 @@ +#!/bin/sh +# +# +# 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 IP' + 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 periode + 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 periode + 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 ony + 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