How to monitor Domain Expiry using icinga2

1.Login into your server using SSH, if you dont have yet icinga2 and icingaweb2 read previous post how to install HERE

2.Install whois

#apt-get install whois

3.Go to icinga2 script directory and create new file “check_domain.php” and copy paste php script from HERE

#cd /etc/icinga2/scripts
#vi check_domain.php

4.After copy paste script, change file permission

#chmod 755 check_domain.php

5.Test the script manually,Example my domain

#./check_domain.php -d anacion.info

6.Now we integrate check domain on icingaweb2 by adding config on conf.d directory

#cd /etc/icinga2/conf.d

7.Copy config below for commands.conf and add on the bottom of config,save and exit.

#vi commands.conf
object CheckCommand "check_domain.php" {
 import "plugin-check-command"
 command = [ "/etc/icinga2/scripts/check_domain.php" ]
 timeout = 120
 arguments = {
 "-d" = "$service.display_name$"
 "-w" = "30"
 "-c" = "10"
 "-s" = "$service.notes$"
 }
 }

8.Copy config below for commands.conf and add to the config,save and exit.

#vi services.conf
apply Service "My Domain Expiry anacion.info"{
 import "generic-service"
 display_name = "anacion.info"
 check_command = "check_domain.php"
 assign where host.name == "My Domain Expiry"
}

9.Copy config below for host.conf and to the config,save and exit.

#vi host.conf
object Host "My Domain Expiry" {
 import "generic-host"
 check_command = "hostalive"
 address ="127.0.0.1"
 vars.notification["mail"] = {
 groups = [ "icingaadmins" ]
 }
}

10.Restart icinga2 and check on icingaweb2 interface.

# service icinga2 restart

 

Leave a Reply

Your email address will not be published.