Proper syntax for monitoring an IP in .conf files, Icinga2

I currently have the code

object Host "rqbhost" {
address = "xx.xx.xx.xx"
check_command = "hostalive"
}

object Service "ping4" {
host_name = "rqbhost"
check_command = "ping4"
}

object Service "http" {
host_name = "rqbhost"
check_command = "http"
}

This will not allow me to start the icinga service, and the error logs do not let me know of why they are incorrect. I have tried the documentation for icinga2 but it has been woefully unhelpful for such a simple task as mine.

the error logs here

:/etc/icinga2/conf.d/services.conf(25):  */
:/etc/icinga2/conf.d/services.conf(26): apply Service "ping4" {
:^^^^^^^^^^^^^^^^^^^^^
:/etc/icinga2/conf.d/services.conf(27):   import "generic-service"
:/etc/icinga2/conf.d/services.conf(28):
:[2016-07-08 13:59:24 +0000] critical/config: 1 error
:icinga2.service: control process exited, code=exited status=1

Answer

Ping4 is not a service I have installed. It was listed as an example on the icinga2 documentation page. The syntax to monitor if a host is alive (and nothing more) in Icinga2 is as follows.

object Host "NAME" { /*ID of the ip/location/host you want to monitor*/
address = "xxx.xxx.xxx.xxx" /*IP address of the host*/
check_command = "hostalive" /*checks if alive*/
}
object Service "http" { /*checks for service http and its status*/
host_name = "NAME" /*which host you want to see*/
check_command = "http"/*checks if http is up*/
}

If that is in your /etc/icinga2/conf.d/ you will save as FILENAME.conf

Restart with systemctl restart icinga2 and the new host will be available to monitor in the web interface.

Attribution
Source : Link , Question Author : spoon_man , Answer Author : spoon_man

Leave a Comment