How to monitor website vhosts 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.Go to icinga2 conf.d directory and backup original config.

#cd /etc/icinga2/conf.d

#mv hosts.conf host.conf.orig

#mv services.conf services.conf.orig

3.Now we create our host config, copy paste config below then save and exit

#vi hosts.conf
object Host "Website Availability" {
 import "generic-host"
 address = "127.0.0.1" 
 
 vars.http_vhosts["richard.anacion.info"] = {
 http_uri = "https://richard.anacion.info"
 }
 
 vars.http_vhosts["secure.anacion.info"] = {
 http_uri = "https://secure.anacion.info"
 }
 
 vars.http_vhosts["www.google.com"] = {
 http_uri = "https://www.google.com"
 }


/* Define notification mail attributes for notification apply rules in `notifications.conf`. */
 vars.notification["mail"] = {
 /* The UserGroup `icingaadmins` is defined in `users.conf`. */
 groups = [ "icingaadmins" ]
 }
}

4.Next is we create our sevices config, copy paste config below then save and exit

#vi services.conf

apply Service for (http_vhost => config in host.vars.http_vhosts) {
 import "generic-service"

 check_command = "http"

 vars += config
}

5.Restart icinga2

#service icinga2 restart

6.Done, you have now website monitoring.

Leave a Reply

Your email address will not be published.