After using LibreNMS for years and it was giving me issues, I decided to give check_mk RAW a try. It works great.

I was able to find a way to have check_mk check for Domain Expiry. The original post is HERE, but the formatting wasn’t working so I reposted it.

nano /scripts/check-domain-expiry

After you have edited this file make sure to add it to a daily crontab. We don’t check the every check cycle since you’d probably get blocked due to high requests. Once a day should be more than enough to check.

#!/bin/bash

DOMAINS="domain1.com
domain2.com
domain3.com"

rm -rf /tmp/domain-expiry*

for i in $DOMAINS
do

### Pull TLD from Domain in i
t=$(echo $i | cut -d '.' -f3 | tr '[A-Z]' '[a-z]')
if [ "$t" == "" ];
then
t=$(echo $i | cut -d '.' -f2 | tr '[A-Z]' '[a-z]')
fi

### Whois Lookup done against whois server depending on TLD
if [ "$t" == "com" ];
then
w="whois.verisign-grs.com"
elif [ "$t" == "uk" ];
then
w="whois.nic.uk"
elif [ "$t" == "org" ];
then
w="whois.pir.org"
elif [ "$t" == "biz" ];
then
w="whois.biz"
elif [ "$t" == "org" ];
then
w="whois.pir.org"
elif [ "$t" == "info" ];
then
w="whois.afilias.info"
elif [ "$t" == "net" ];
then
w="whois.verisign-grs.com"
elif [ "$t" == "website" ];
then
w="whois.nic.website"
elif [ "$t" == "business" ];
then
w="whois.donuts.co"
elif [ "$t" == "community" ];
then
w="whois.donuts.co"
elif [ "$t" == "company" ];
then
w="whois.donuts.co"
elif [ "$t" == "enterprises" ];
then
w="whois.donuts.co"
elif [ "$t" == "gallery" ];
then
w="whois.donuts.co"
elif [ "$t" == "co" ];
then
w="whois.nic.co"
elif [ "$t" == "graphics" ];
then
w="whois.donuts.co"
elif [ "$t" == "guru" ];
then
w="whois.donuts.co"
elif [ "$t" == "media" ];
then
w="whois.donuts.co"
elif [ "$t" == "online" ];
then
w="whois.nic.online"
elif [ "$t" == "photography" ];
then
w="whois.donuts.co"
elif [ "$t" == "photo" ];
then
w="whois.uniregistry.net"
elif [ "$t" == "pictures" ];
then
w="whois.donuts.co"
elif [ "$t" == "solutions" ];
then
w="whois.donuts.co"
elif [ "$t" == "support" ];
then
w="whois.donuts.co"
elif [ "$t" == "technology" ];
then
w="whois.donuts.co"
elif [ "$t" == "tips" ];
then
w="whois.donuts.co"
elif [ "$t" == "eu" ];
then
w="whois.eu"
fi

d=$(whois -h $w $i | grep "Expir" | egrep -m 1 -o '[[:digit:]]{1,4}\-[[:digit:]]{1,2}\-[[:digit:]]{1,2}|[[:digit:]]{1,4}\-[[:alpha:]]{3}\-[[:digit:]]{1,2}|[[:alpha:]]{3} [[:alpha:]]{3} [[:digit:]]{2} [[:digit:]]{2}\:[[:digit:]]{2}\:[[:digit:]]{2} [[:alpha:]]{3} [[:digit:]]{4}')
e=$(date +"%Y%m%d")
f=$(date -d "$d" +"%Y%m%d")

g=$(( ( $(date -ud $f +'%s') - $(date -ud $e +'%s') )/60/60/24 ))

if [ "$g" -gt "30" ]; then
s=0
st="Domain $i has $g days left until Expiry (Expiry Date: $d)"
fi

if [ "$g" -lt "30" ]; then
s=1
st="Domain $i has only $g days left until Expiry (Expiry Date: $d)"
fi

if [ "$g" -lt "15" ]; then
s=2
st="Domain $i has only $g days left until Expiry."
fi

if [ "$g" -lt "0" ]; then
s=2
st="Domain $i has expired!"
fi

echo "$s Domain_$i count=$g;15;30;0; $st" >> /tmp/domain-expiry-$e.txt

done




chmod +x /scripts/check-domain-expiry




nano /usr/share/check-mk-agent/local/check-domain-check




nano /usr/lib/check_mk_agent/local/check-domain-check




chmod +x /usr/lib/check_mk_agent/local/check-domain-check

If you now re-inventory your host in check_mk it should pull through a local check for each of your domains.