Seb35
0b10e8d563
If the env var XDG_CACHE_HOME is set, the cache directory is "$XDG_CACHE_HOME/ianardap", else if HOME is set, it is "$HOME/.ianardapcaches", else no cache is used but a loud warning is displayed at the end of the result to encourage users to set a cache directory. Adapted pytest tests, no change needed on test_exe_matrix. They are obviously slower with no cache. NB: two tests now fail independently of this change. Issue: #4 |
||
---|---|---|
.gitignore | ||
check_expire | ||
ianardap.py | ||
LICENSE | ||
README.md | ||
test_ianardap.py | ||
tests.yaml |
check_expire
A Nagios (and compatible) plugin to check the impending expiration of a domain name. It relies on RDAP exclusively (no whois) and works with every top-level domain with RDAP (which includes all the ICANN ones).
Usage
check_expire follows the usual Nagios rules. The options are:
- -H: domain name to monitor
- -c: critical threshold in days
- -w: warning threshold in days
- -v: verbose details in output
- -u: unixtime output
- -t: timeout for RDAP requetss (in seconds)
Installation
You need Python 3 and Requests. You can install Requests, for instance, with pip pip3 install requests
.
Then, copy the script check_expire
and the file ianardap.py
to the directory of local plugins.
The use of a cache directory is not mandatory, but highly recommended. It can be either $XDG_CACHE_HOME/ianardap
or $HOME/.ianardapcaches
depending on the environment variables set.
Icinga configuration
If you use Icinga, here is a possible definition of the command:
object CheckCommand "expiration" {
command = [ PluginContribDir + "/check_expire" ]
arguments = {
"-H" = "$address$",
"-c" = "$expiration_critical$",
"-w" = "$expiration_warning$",
"-t" = "$expiration_timeout$",
"-v" = { set_if = "$expiration_verbose$" }
}
env.XDG_CACHE_HOME = "/var/cache/nagios"
}
apply Service "expiration" {
import "generic-service"
check_command = "expiration"
assign where host.address && host.vars.monitor_expiration
}
And a possible use:
object Host "bortzmeyer-org" {
...
address = "bortzmeyer.org"
vars.monitor_expiration = true
vars.expiration_verbose = true
}
If needed, create the cache directory accordingly:
mkdir /var/cache/nagios
chown nagios: /var/cache/nagios
Zabbix configuration
For monitoring systems that do not rely on exit codes but on calculation mechanism based on the metric they receive you can use the -u
option that will only return the expiration date in unixtime format.
For instance, you can use the following in zabbix 5.4:
- item:
check_expire["-H","{HOST.CONN}","-u"]
- trigger (30 days before expiration):
last(/check_expire["-H","{HOST.CONN}","-u"])-now()<2592000
Where 2592000
is the number of seconds in 30 days.
License
GPL. See LICENSE.
Authors
Stéphane Bortzmeyer stephane+chapril@bortzmeyer.org.
Reference site
https://forge.chapril.org/bortzmeyer/check_expire Use the Gitea issue tracker to report bugs or wishes.