Révision f06ee36a
Use an environment variable for CACHE_EXPIRY (#1169)
Use an environment variable for CACHE_EXPIRY in whois plugin.
| plugins/network/whois_ | ||
|---|---|---|
| 26 | 26 |
env.extract_re s/PATTERN/REPL/ |
| 27 | 27 |
env.warning_days <default: 7 days> |
| 28 | 28 |
env.critical_days <default: 3 days> |
| 29 |
env.cache_expiry_mins <default: 60 minutes> |
|
| 29 | 30 |
|
| 30 | 31 |
The C<extract_re> will be used in C<sed> to extract the relevant expiry date. It |
| 31 | 32 |
default to C<s/^.*[Ee]xpir.*: //>. Only lines for which a replacement has |
| ... | ... | |
| 62 | 63 |
EXTRACT_RE=${extract_re:-'s/^.*[Ee]xpir.*: //'}
|
| 63 | 64 |
WARNING=${warning_days:-7}
|
| 64 | 65 |
CRITICAL=${critical_days:-3}
|
| 65 |
CACHE_EXPIRY=60 # minutes
|
|
| 66 |
CACHE_EXPIRY=${cache_expiry_mins:-60}
|
|
| 66 | 67 |
|
| 67 | 68 |
# Args: domain name (optional, for title) |
| 68 | 69 |
graph_config() {
|
| ... | ... | |
| 100 | 101 |
|
| 101 | 102 |
CACHEFILE="${MUNIN_PLUGSTATE}/$(basename "${0}").${FIELDNAME}.cache"
|
| 102 | 103 |
|
| 103 |
if [ -z "$(find "${CACHEFILE}" -mmin -${CACHE_EXPIRY} 2>/dev/null)" ]; then
|
|
| 104 |
if [ -z "$(find "${CACHEFILE}" -mmin -"${CACHE_EXPIRY}" 2>/dev/null)" ]; then
|
|
| 104 | 105 |
EXPIRY="$(whois "${NAME}" 2>/dev/null | sed -n "${EXTRACT_RE}p;T;q")" # T;q exits after printing the first match
|
| 105 | 106 |
DELTA_TS=U |
| 106 | 107 |
if [ -n "${EXPIRY}" ]; then
|
Formats disponibles : Unified diff