Révision 02451d8f
[whois] Allow to specificy whois server per domain
Also, clean up some old code that pre-dates multi-domain handling
Signed-off-by: Olivier Mehani <shtrom@ssji.net>
| plugins/network/whois | ||
|---|---|---|
| 13 | 13 |
|
| 14 | 14 |
=head1 CONFIGURATION |
| 15 | 15 |
|
| 16 |
First, create a section in your munin-node configuration files. The domain envvar |
|
| 17 |
is mandatory, others are optional. |
|
| 16 |
First, create a section in your munin-node configuration files. The domain |
|
| 17 |
envvar is mandatory, others are optional. Optionally, a specific WHOIS server |
|
| 18 |
to query for a given domain can be specified with the @WHOIS_SERVER suffix |
|
| 18 | 19 |
|
| 19 | 20 |
[whois] |
| 20 |
env.domains example.com example.org |
|
| 21 |
env.domains example.com example.org@whois.example.net
|
|
| 21 | 22 |
env.extract_re s/PATTERN/REPL/ |
| 22 | 23 |
env.warning_days <default: 7 days> |
| 23 | 24 |
env.critical_days <default: 3 days> |
| ... | ... | |
| 41 | 42 |
|
| 42 | 43 |
Olivier Mehani |
| 43 | 44 |
|
| 44 |
Copyright (C) 2020 Olivier Mehani <shtrom+munin@ssji.net> |
|
| 45 |
Copyright (C) 2020,2021 Olivier Mehani <shtrom+munin@ssji.net>
|
|
| 45 | 46 |
|
| 46 | 47 |
=head1 LICENSE |
| 47 | 48 |
|
| ... | ... | |
| 74 | 75 |
graph_title Domain registration expiry |
| 75 | 76 |
graph_category network |
| 76 | 77 |
graph_vlabel days |
| 78 |
graph_args --units-exponent 0 |
|
| 77 | 79 |
EOF |
| 78 | 80 |
} |
| 79 | 81 |
|
| ... | ... | |
| 84 | 86 |
local FIELDNAME |
| 85 | 87 |
for NAME in $DOMAINS |
| 86 | 88 |
do |
| 89 |
NAME="$(echo "${NAME}" | cut -d @ -f 1)"
|
|
| 90 |
|
|
| 87 | 91 |
FIELDNAME="$(clean_fieldname "${NAME}")"
|
| 88 | 92 |
|
| 89 | 93 |
cat << EOF |
| ... | ... | |
| 98 | 102 |
# Args: domain name |
| 99 | 103 |
fetch() {
|
| 100 | 104 |
local NAME |
| 105 |
local SERVER |
|
| 101 | 106 |
local FIELDNAME |
| 102 | 107 |
local CACHEFILE |
| 103 | 108 |
|
| 104 | 109 |
for NAME in $DOMAINS |
| 105 | 110 |
do |
| 111 |
SERVER='' |
|
| 112 |
if echo "${NAME}" | grep -q '@'; then
|
|
| 113 |
SERVER="$(echo "${NAME}" | cut -d @ -f 2)"
|
|
| 114 |
NAME="$(echo "${NAME}" | cut -d @ -f 1)"
|
|
| 115 |
fi |
|
| 116 |
|
|
| 106 | 117 |
FIELDNAME="$(clean_fieldname "${NAME}")"
|
| 107 | 118 |
|
| 108 | 119 |
CACHEFILE="${MUNIN_PLUGSTATE}/$(basename "${0}").${FIELDNAME}.cache"
|
| 109 | 120 |
|
| 110 | 121 |
if [ -z "$(find "${CACHEFILE}" -mmin -"${CACHE_EXPIRY}" 2>/dev/null)" ]; then
|
| 111 |
EXPIRY="$(whois "${NAME}" 2>/dev/null | sed -n "${EXTRACT_RE}p;T;q")" # T;q exits after printing the first match
|
|
| 122 |
EXPIRY="$(whois "${NAME}" "${SERVER:+-h${SERVER}}" 2>/dev/null | sed -n "${EXTRACT_RE}p;T;q")" # T;q exits after printing the first match
|
|
| 112 | 123 |
DELTA_TS=U |
| 113 | 124 |
if [ -n "${EXPIRY}" ]; then
|
| 114 | 125 |
EXPIRY_TS="$(date +%s -d "${EXPIRY}")"
|
| ... | ... | |
| 126 | 137 |
|
| 127 | 138 |
main() {
|
| 128 | 139 |
local MODE="${1:-}"
|
| 129 |
local NAME |
|
| 130 |
|
|
| 131 |
NAME="$(echo "${0}" | sed 's/.*_//')"
|
|
| 132 | 140 |
|
| 133 | 141 |
case "${MODE}" in
|
| 134 | 142 |
'config') |
| 135 |
graph_config "${NAME}"
|
|
| 136 |
config "${NAME}"
|
|
| 143 |
graph_config |
|
| 144 |
config |
|
| 137 | 145 |
;; |
| 138 | 146 |
*) |
| 139 |
fetch "${NAME}"
|
|
| 147 |
fetch |
|
| 140 | 148 |
;; |
| 141 | 149 |
esac |
| 142 | 150 |
} |
Formats disponibles : Unified diff