Page 1 of 1

Can't get correctly information about service

Posted: Wed May 03, 2017 7:12 am
by matisse
Hello,
I tried get information with help default plugin "check_procs" on local server. But in web interface i can see UNKNOWN Status.
There are my settings:
In server.cfg

Code: Select all

define service{
        use                             local-service         ; Name of service template to use
        notification_interval		0
        hostgroup_name                  Servers
        service_description             Total Processes
	check_command			check_procs
}
In nrpe.cfg

Code: Select all

command[check_procs]=/usr/local/nagios/libexec/check_procs -w 150 -c 200
In command.cfg

Code: Select all

define command{
        command_name    check_procs
        command_line    $USER1$/check_procs -H $HOSTADDRESS$ -w 500 -c 300
        }
What the problem? If i runing command - ./libexec/check_nrpe -H localhost -c check_procs, it work correctly.
Thanks!

Re: Can't get correctly information about service

Posted: Wed May 03, 2017 12:44 pm
by tgriep
The check_procs command only runs on the local system and the -H $HOSTADDRESS$ option is not needed in the command definition and that is causing the error.
Edit your check_procs command and change the command_line from

Code: Select all

command_line    $USER1$/check_procs -H $HOSTADDRESS$ -w 500 -c 300
to

Code: Select all

command_line    $USER1$/check_procs -w 500 -c 300
Save the settings and restart nagios and that should fix it for you.

Re: Can't get correctly information about service

Posted: Wed May 03, 2017 3:15 pm
by matisse
Thanks, it is works. But if i need to check other servers with this plugin i must edit nrpe.cfg for it?

Re: Can't get correctly information about service

Posted: Wed May 03, 2017 3:22 pm
by ssax
By default it should be in your /usr/local/nagios/etc/nrpe/common.cfg on the remote server:

Code: Select all

command[check_procs]=/usr/local/nagios/libexec/check_procs $ARG1$
If you do not have that file on the remote server you can just define it in your nrpe.cfg file (if it isn't already).

Then to test, just run this from the XI server:
- Change X.X.X.X to the remote address

Code: Select all

/usr/local/nagios/libexec/check_nrpe -H X.X.X.X -c check_procs -a '-w 500 -c 300'
Thank you

Re: Can't get correctly information about service

Posted: Wed May 03, 2017 3:30 pm
by tgriep
As long as the check_procs command is defined in the nrpe.cfg file like your example below and the plugin is installed on the remote server, you should be alright.

Code: Select all

command[check_procs]=/usr/local/nagios/libexec/check_procs -w 150 -c 200
Now this service definition

Code: Select all

define service{
        use                             local-service         ; Name of service template to use
        notification_interval      0
        hostgroup_name                  Servers
        service_description             Total Processes
   check_command         check_procs
}
With this command

Code: Select all

define command{
        command_name    check_procs
        command_line    $USER1$/check_procs -w 500 -c 300
}
Will only run the check_procs plugin on the local nagios server.

To get it to run on a remote server using NRPE you would define a check_nrpe command like the example below

Code: Select all

define command {
       command_name                             check_nrpe
       command_line                             $USER1$/check_nrpe -H $HOSTADDRESS$ -c $ARG1$ $ARG2$
}
And the service check would look like this for example

Code: Select all

define service {
        host_name                       192.168.1.1
        service_description             Total Processes   
        use                             generic-service
        check_command                   check_nrpe!check_procs
}
That service check uses the check_nrpe command to run the check_procs command on the remote host 192.168.1.1 returning the number of processes running.

Re: Can't get correctly information about service

Posted: Fri May 05, 2017 7:19 am
by matisse
Thanks for help! It's works.

Re: Can't get correctly information about service

Posted: Fri May 05, 2017 9:30 am
by tgriep
Your welcome. If you don't have any other questions, shall I close and lock the post as solved?

Re: Can't get correctly information about service

Posted: Fri May 26, 2017 9:30 am
by matisse
Yes :)