Nagios CentOS Remote 2 – Configuring The Nagios Server

Nagios CentOS Remote 2 – Configuring The Nagios Server

The next part in the installation is to configure the nagios server to monitor the remote host.  To configure the nagios server to monitor the remote server perform the following sections.

Confirming Communiction With The Client

The first step in the nagios server configuration is to confirm that it is able to communicate with the remote host.  To confirm communications with the remote host perform the following steps :-

  • In the command prompt on the nagios server execute the following command :-

/usr/lib64/nagios/plugins/check_nrpe -H {Remote Host IP}

E.G. – /usr/lib64/nagios/plugins/check_nrpe -H 10.20.30.40

  • The command will execute and if it is able to communicate with the client machine return something along the lines shown below :-

NRPE v2.12
N.B. The version number shown may be different if a newer version of nrpe has been installed on the remote host

Defining The Host

The next part of the configuration is to define the host to nagios.  To define the host to nagios perform the following steps :-

  • On the nagios server create a new file under/etc/nagios/objects named linux-servers.cfg
  • Edit the newly created file /etc/nagios/objects/linux-servers.cfg and add the text below :-

define host {
 use linux-server
 host_name {Remote Server FQDN Hostname}
 alias {Friendly Remote Server Name}
 address {Remote Server IP Address}
 }

  • Next add in the following text below to create a basic Ping check of the server :-

define service {
 use local-service
 host_name {Remote Server FQDN Hostname}
 service_description check_ping!100.0,20%!500.0,60%
 }

  • Save and Exit the file

Adding The Config File To The Nagios Config File

In order for nagios to utilise the newly created linux-servers.cfg created in the section above it needs adding to the nagios.cfg on the nagios server.  To add the linux-servers.cfg file to the nagios.cfg file perform the following steps: –

  • On the nagios server edit the file under /etc/nagios/nagios.cfg
  •  Locate the line cfg_file=/etc/nagios/objects/localhost.cfg and then add the text below as a new line :-

cfg_file=/etc/nagios/objects/linux-servers.cfg

  • Save and  Exit the file

Adding The Check_nrpe Command

In order to run commands on the remote host the check_nrpe command needs to be defined on the nagios server.  To define the check_nrpe command on the nagios server perform the following steps :-

  • On the nagios server edit the file/etc/nagios/objects/commands.cfg
  • At the bottom of the file add the section of text below :-

define command {

 command_name check_nrpe

 command_line $USER1$/check_nrpe -H $HOSTADDRESS$ -c $ARG1$

 }

  • Save and Exit the file

Verify The Configuration And Restart Nagios

The next step is to verify that the changes in the previous sections have been made correctly on the server.  To verify the nagios configuration changes perform the following steps :-

  • In the command line of the remote host execute the command below :-

nagios -v /etc/nagios/nagios.cfg

  • The command should return the lines below if the files have been written correctly :-

Total Warnings: 0

Total Errors:   0

Things look okay – No serious problems were detected during the pre-flight check

  • Finally Restart nagios on the server by executing the command below :-

service nagios restart