mirror of
https://github.com/munin-monitoring/contrib.git
synced 2025-07-21 18:41:03 +00:00
[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>
This commit is contained in:
parent
ca8ce74367
commit
02451d8f6e
1 changed files with 19 additions and 11 deletions
|
@ -13,11 +13,12 @@ only query the WHOIS database C<cache_expiry_mins> minutes.
|
||||||
|
|
||||||
=head1 CONFIGURATION
|
=head1 CONFIGURATION
|
||||||
|
|
||||||
First, create a section in your munin-node configuration files. The domain envvar
|
First, create a section in your munin-node configuration files. The domain
|
||||||
is mandatory, others are optional.
|
envvar is mandatory, others are optional. Optionally, a specific WHOIS server
|
||||||
|
to query for a given domain can be specified with the @WHOIS_SERVER suffix
|
||||||
|
|
||||||
[whois]
|
[whois]
|
||||||
env.domains example.com example.org
|
env.domains example.com example.org@whois.example.net
|
||||||
env.extract_re s/PATTERN/REPL/
|
env.extract_re s/PATTERN/REPL/
|
||||||
env.warning_days <default: 7 days>
|
env.warning_days <default: 7 days>
|
||||||
env.critical_days <default: 3 days>
|
env.critical_days <default: 3 days>
|
||||||
|
@ -41,7 +42,7 @@ Then create a symlink to enable this plugin:
|
||||||
|
|
||||||
Olivier Mehani
|
Olivier Mehani
|
||||||
|
|
||||||
Copyright (C) 2020 Olivier Mehani <shtrom+munin@ssji.net>
|
Copyright (C) 2020,2021 Olivier Mehani <shtrom+munin@ssji.net>
|
||||||
|
|
||||||
=head1 LICENSE
|
=head1 LICENSE
|
||||||
|
|
||||||
|
@ -74,6 +75,7 @@ graph_config() {
|
||||||
graph_title Domain registration expiry
|
graph_title Domain registration expiry
|
||||||
graph_category network
|
graph_category network
|
||||||
graph_vlabel days
|
graph_vlabel days
|
||||||
|
graph_args --units-exponent 0
|
||||||
EOF
|
EOF
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -84,6 +86,8 @@ config() {
|
||||||
local FIELDNAME
|
local FIELDNAME
|
||||||
for NAME in $DOMAINS
|
for NAME in $DOMAINS
|
||||||
do
|
do
|
||||||
|
NAME="$(echo "${NAME}" | cut -d @ -f 1)"
|
||||||
|
|
||||||
FIELDNAME="$(clean_fieldname "${NAME}")"
|
FIELDNAME="$(clean_fieldname "${NAME}")"
|
||||||
|
|
||||||
cat << EOF
|
cat << EOF
|
||||||
|
@ -98,17 +102,24 @@ EOF
|
||||||
# Args: domain name
|
# Args: domain name
|
||||||
fetch() {
|
fetch() {
|
||||||
local NAME
|
local NAME
|
||||||
|
local SERVER
|
||||||
local FIELDNAME
|
local FIELDNAME
|
||||||
local CACHEFILE
|
local CACHEFILE
|
||||||
|
|
||||||
for NAME in $DOMAINS
|
for NAME in $DOMAINS
|
||||||
do
|
do
|
||||||
|
SERVER=''
|
||||||
|
if echo "${NAME}" | grep -q '@'; then
|
||||||
|
SERVER="$(echo "${NAME}" | cut -d @ -f 2)"
|
||||||
|
NAME="$(echo "${NAME}" | cut -d @ -f 1)"
|
||||||
|
fi
|
||||||
|
|
||||||
FIELDNAME="$(clean_fieldname "${NAME}")"
|
FIELDNAME="$(clean_fieldname "${NAME}")"
|
||||||
|
|
||||||
CACHEFILE="${MUNIN_PLUGSTATE}/$(basename "${0}").${FIELDNAME}.cache"
|
CACHEFILE="${MUNIN_PLUGSTATE}/$(basename "${0}").${FIELDNAME}.cache"
|
||||||
|
|
||||||
if [ -z "$(find "${CACHEFILE}" -mmin -"${CACHE_EXPIRY}" 2>/dev/null)" ]; then
|
if [ -z "$(find "${CACHEFILE}" -mmin -"${CACHE_EXPIRY}" 2>/dev/null)" ]; then
|
||||||
EXPIRY="$(whois "${NAME}" 2>/dev/null | sed -n "${EXTRACT_RE}p;T;q")" # T;q exits after printing the first match
|
EXPIRY="$(whois "${NAME}" "${SERVER:+-h${SERVER}}" 2>/dev/null | sed -n "${EXTRACT_RE}p;T;q")" # T;q exits after printing the first match
|
||||||
DELTA_TS=U
|
DELTA_TS=U
|
||||||
if [ -n "${EXPIRY}" ]; then
|
if [ -n "${EXPIRY}" ]; then
|
||||||
EXPIRY_TS="$(date +%s -d "${EXPIRY}")"
|
EXPIRY_TS="$(date +%s -d "${EXPIRY}")"
|
||||||
|
@ -126,17 +137,14 @@ fetch() {
|
||||||
|
|
||||||
main() {
|
main() {
|
||||||
local MODE="${1:-}"
|
local MODE="${1:-}"
|
||||||
local NAME
|
|
||||||
|
|
||||||
NAME="$(echo "${0}" | sed 's/.*_//')"
|
|
||||||
|
|
||||||
case "${MODE}" in
|
case "${MODE}" in
|
||||||
'config')
|
'config')
|
||||||
graph_config "${NAME}"
|
graph_config
|
||||||
config "${NAME}"
|
config
|
||||||
;;
|
;;
|
||||||
*)
|
*)
|
||||||
fetch "${NAME}"
|
fetch
|
||||||
;;
|
;;
|
||||||
esac
|
esac
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue