root / plugins / network / ddclient @ 0a1524f2
Historique | Voir | Annoter | Télécharger (3,04 ko)
| 1 |
#!/bin/sh |
|---|---|
| 2 |
# |
| 3 |
# |
| 4 |
# Munin plugin to show changing the ip address by ddclient. |
| 5 |
# The base frame is copied from the proftp plugin |
| 6 |
# |
| 7 |
########################################################################################## |
| 8 |
# Folgende Eintraege in der Datei /etc/munin/plugin-conf.d/munin-node nicht vergessen ! # |
| 9 |
# Don't forget to add following lines to the file /etc/munin/plugin-conf.d/munin-node # |
| 10 |
# [quota] # |
| 11 |
# user root # |
| 12 |
########################################################################################## |
| 13 |
|
| 14 |
# Parameters understood: |
| 15 |
# |
| 16 |
# config (required) |
| 17 |
# autoconf (optional - used by munin-config) |
| 18 |
# |
| 19 |
# |
| 20 |
# Magic markers (optional - used by munin-config and installation |
| 21 |
# scripts): |
| 22 |
# |
| 23 |
#%# family=auto |
| 24 |
#%# capabilities=autoconf |
| 25 |
|
| 26 |
MAXLABEL=20 |
| 27 |
|
| 28 |
if [ "$1" = "autoconf" ]; then |
| 29 |
echo yes |
| 30 |
exit 0 |
| 31 |
fi |
| 32 |
|
| 33 |
if [ "$1" = "config" ]; then |
| 34 |
|
| 35 |
echo 'graph_title IP Wechsel' |
| 36 |
echo 'graph_args --base 1000 -l 0' |
| 37 |
echo 'graph_vlabel t?glicher IP Wechsel' |
| 38 |
echo 'graph_category IP' |
| 39 |
echo 'ip_change.label IP Wechsel' |
| 40 |
echo 'graph_info Jeder IP-Wechsel der von DDCLIENT festgestellt wird erzeugt einen Wert von 1' |
| 41 |
exit 0 |
| 42 |
fi |
| 43 |
|
| 44 |
################################################################################ |
| 45 |
# Beginn des modifizierten Skriptes - Beginning of the modified script # |
| 46 |
################################################################################ |
| 47 |
|
| 48 |
|
| 49 |
# Nur fuer Testzwecke kann das - For testing only you can |
| 50 |
# Zeitfenster vergroessert werden resize the reference periode |
| 51 |
if [ "${1//[^[:digit:]]}" != "" ]; then
|
| 52 |
factor=${1//[^[:digit:]]}
|
| 53 |
else |
| 54 |
factor=1 |
| 55 |
fi |
| 56 |
|
| 57 |
# Aktuelle Zeit in Sekunden (C-Format) - now in seconds (c-format) |
| 58 |
Timestamp=$(date +%s) |
| 59 |
|
| 60 |
# Zeitfenster in Sekunden - time slot in seconds |
| 61 |
let Timeslot=60*30*$factor |
| 62 |
|
| 63 |
# Referenzzeitpunkt berechnen - calculate the reference periode |
| 64 |
let Ref_Timestamp=Timestamp-Timeslot |
| 65 |
|
| 66 |
# Zeitstempel der letzten Aktualisierung - timestampe of the last update |
| 67 |
Last_update=$(grep -i 'last update' /var/cache/ddclient/ddclient.cache) |
| 68 |
Last_update=${Last_update##*\(}
|
| 69 |
Last_update=${Last_update%%\)}
|
| 70 |
|
| 71 |
# Ausgabe f?r Munin - output for munin |
| 72 |
if [ "$Last_update" -gt "$Ref_Timestamp" ]; then |
| 73 |
echo "ip_change.value 1" |
| 74 |
else |
| 75 |
echo "ip_change.value 0" |
| 76 |
fi |
| 77 |
|
| 78 |
# Nur zum Testen - for testing ony |
| 79 |
if [ "$factor" -gt 1 ]; then |
| 80 |
echo "======================== Nur fuer Testzwecke ======================" |
| 81 |
echo "Timestamp :" $Timestamp $(date -d "1970-01-01 UTC + $Timestamp seconds") |
| 82 |
echo "Ref_Timestamp:" $Ref_Timestamp $(date -d "1970-01-01 UTC + $Ref_Timestamp seconds") |
| 83 |
echo "Zeitfenster :" $((Timeslot/60)) Minuten |
| 84 |
echo "Last_update :" $Last_update $(date -d "1970-01-01 UTC + $Last_update seconds") |
| 85 |
echo "======================== for testing only ======================" |
| 86 |
fi |
