root / plugins / network / ddclient @ 17f78427
Historique | Voir | Annoter | Télécharger (3,04 ko)
| 1 | 614b043a | Stig Sandbeck Mathisen | #!/bin/bash |
|---|---|---|---|
| 2 | 8daa48b4 | Jo Hartmann | # |
| 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 | 17f78427 | Lars Kruse | # Folgende Eintraege in der Datei /etc/munin/plugin-conf.d/munin-node nicht vergessen ! # |
| 9 | 8daa48b4 | Jo Hartmann | # 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 | e3899a30 | Gabriele Pohl | echo 'graph_vlabel täglicher IP Wechsel' |
| 38 | echo 'graph_category network' |
||
| 39 | 8daa48b4 | Jo Hartmann | 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 | 17f78427 | Lars Kruse | else |
| 54 | 8daa48b4 | Jo Hartmann | 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 | e3899a30 | Gabriele Pohl | # Ausgabe für Munin - output for munin |
| 72 | 8daa48b4 | Jo Hartmann | 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 | 17f78427 | Lars Kruse | echo "======================== Nur fuer Testzwecke ======================" |
| 81 | 8daa48b4 | Jo Hartmann | 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 | 17f78427 | Lars Kruse | echo "Zeitfenster :" $((Timeslot/60)) Minuten |
| 84 | 8daa48b4 | Jo Hartmann | echo "Last_update :" $Last_update $(date -d "1970-01-01 UTC + $Last_update seconds") |
| 85 | 17f78427 | Lars Kruse | echo "======================== for testing only ======================" |
| 86 | 8daa48b4 | Jo Hartmann | fi |
