NRPE monitor Windows Clients connected to the Nagios Remote

Support forum for Nagios Core, Nagios Plugins, NCPA, NRPE, NSCA, NDOUtils and more. Engage with the community of users including those using the open source solutions.
ssax
Dreams In Code
Posts: 7682
Joined: Wed Feb 11, 2015 12:54 pm

Re: NRPE monitor Windows Clients connected to the Nagios Rem

Post by ssax »

Try this:

NagiosA:

Code: Select all

define service {
    use                    generic-service
    host_name              ClientPC1B
    service_description    Remote_CPU
    check_command          check_nrpe_ext!IPofPCClient1B!check_cpu!'-a show-all'!!!!!
    register               1
}

define command {
    command_name    check_nrpe_ext
    command_line    $USER1$/check_nrpe -t 90 -H IPofNagiosB -c check_nrpe_external -a $ARG1$ $ARG2$ $ARG3$
}

NagiosB:

Code: Select all

command[check_nrpe_external]=/usr/local/nagios/libexec/check_nrpe -t 90 -H $ARG1$ -n -c $ARG2$ $ARG3$
PCClient1B:

Whatever command you define in that top service (check_cpu in this example) needs to be defined in your nsclient.ini on the Windows server.
-- Note: This example is assuming you want to run a check through NRPE from NagiosB to PCClient1B, if you are just trying to check a port or something on PCClient1B by using check_http or something like that then you wouldn't need NagiosB to PCClient1B NRPE communication but they are achieving different goals, you may have a mix of them, it depends on how the plugin you are trying to use is meant to be run. Some are meant to be run from the Nagios server, some are meant to be run through NRPE or another agent on the remote machine's system.

----

Code: Select all

[root@TestNagiosB]# /usr/local/nagios/libexec/check_nrpe -t 90  -H IPofPCClient1B -n -c  check_cpu 'show-all'
OK: CPU load is ok.|'total 5m'=0%;80;90 'total 1m'=0%;80;90 'total 5s'=0%;80;90
You're searching for plugins on TestNagiosB when you should be looking for check_cpu and check_users in your Client1B nsclient.ini file, that check_cpu command is being run by ClientPC1B.

Code: Select all

[root@TestNagiosB]# /usr/local/nagios/libexec/check_nrpe -t 90  -H IPofClient1B -n -c  check_users
Unknown command(s): check_users
You likely don't have check_users defined in Client1B's nsclient.ini.
xinxolHH
Posts: 14
Joined: Mon Feb 18, 2019 4:47 am

Re: NRPE monitor Windows Clients connected to the Nagios Rem

Post by xinxolHH »

Hello ssax,

Thanks for the answer, and the explanation. Yes it as explained,some of the check are from NagiosB and others are run on the client PC locally.
I managed to execute the commands on the remote PCs at the location B, and get the data to Nagios A server. I have not managed to get the syntax of the define service

Code: Select all

define service {
    use                    generic-service
    host_name              ClientPC1B
    service_description    Remote_CPU
    check_command          check_nrpe_ext!IPofPCClient1B!check_cpu!'-a show-all'!!!!!
    register               1
}


Do we need the

Code: Select all

 !!!!! 
the 5 exclamation marks (empty arguments) at the end, if yes, why?

this is how may define service and commands looks like and it is working in this way:

Code: Select all


define host {
        use                                windows-server
        host_name                     LocationBLocalPCs
        alias                              Location B  PCs
       address                           IPofNagiosB
        max_check_attempts      3
        check_period                  workhours
        check_command              check-host-alive
        check_interval                  3
        notification_interval          60
        notification_period          workhours2
}


define service {
        use                                  generic-service
        host_name                       LocatioBLocalPCs
        service_description           Disks at Local PC1
        check_period                    workhours2
        check_command               check_nrpe_ext_remote_cpu_LocalBPC1
}

#############################################################################
# Definition of the check_nrpe_external in the Remote host is
# command[check_nrpe_external]=/usr/local/nagios/libexec/check_nrpe -t 90 -H $ARG1$ -n -c $ARG2$ $ARG3$
# with 3 Arguments and the -n option already given
##############################################################################
#
#
# Test Disk Status
define command {
  command_name check_nrpe_ext_remote_cpu_LocalBPC1
  command_line $USER1$/check_nrpe -t 90 -H IPofNagiosB -c check_nrpe_external -t 90 -a IPofClient1B alias_test
}


Could you please suggest me a better definition for the syntax to specify the commands for this example using alias_test.

May thanks in advanced
X.
ssax
Dreams In Code
Posts: 7682
Joined: Wed Feb 11, 2015 12:54 pm

Re: NRPE monitor Windows Clients connected to the Nagios Rem

Post by ssax »

You don't need the trailing exclamation points (!), they are only used to separate arguments.

Is this on SERVERA?

Code: Select all

define service {
    use                    generic-service
    host_name              ClientPC1B
    service_description    Remote_CPU
    check_command          check_nrpe_ext!IPofPCClient1B!check_cpu!'-a show-all'!!!!!
    register               1
}
Is this on SERVERB?

Code: Select all

    define host {
            use                                windows-server
            host_name                     LocationBLocalPCs
            alias                              Location B  PCs
           address                           IPofNagiosB
            max_check_attempts      3
            check_period                  workhours
            check_command              check-host-alive
            check_interval                  3
            notification_interval          60
            notification_period          workhours2
    }


    define service {
            use                                  generic-service
            host_name                       LocatioBLocalPCs
            service_description           Disks at Local PC1
            check_period                    workhours2
            check_command               check_nrpe_ext_remote_cpu_LocalBPC1
    }

    #############################################################################
    # Definition of the check_nrpe_external in the Remote host is
    # command[check_nrpe_external]=/usr/local/nagios/libexec/check_nrpe -t 90 -H $ARG1$ -n -c $ARG2$ $ARG3$
    # with 3 Arguments and the -n option already given
    ##############################################################################
    #
    #
    # Test Disk Status
    define command {
      command_name check_nrpe_ext_remote_cpu_LocalBPC1
      command_line $USER1$/check_nrpe -t 90 -H IPofNagiosB -c check_nrpe_external -t 90 -a IPofClient1B alias_test
    }

Or are all those on SERVERA?
xinxolHH
Posts: 14
Joined: Mon Feb 18, 2019 4:47 am

Re: NRPE monitor Windows Clients connected to the Nagios Rem

Post by xinxolHH »

Hello ssax

All those configuration files are on Server A.

I am pinging SERVERB, as defined host, a Linux server, from SERVERA
and executing the remote commands in SERVERB for checking the PC clients at Location B, or locally the commands which are in the nsclient.ini file on the Local PC clients located on the location B.

Is there anything missconfigured, or not understood at my side?

thanks
X.
ssax
Dreams In Code
Posts: 7682
Joined: Wed Feb 11, 2015 12:54 pm

Re: NRPE monitor Windows Clients connected to the Nagios Rem

Post by ssax »

Assume This:

Code: Select all

SERVERA = 192.168.0.1
SERVERB = 192.168.0.2
PC1A = 10.0.0.1
PC1B = 10.0.0.2
Configs:

SERVERA:

Code: Select all

define command {
    command_name    check_nrpe_ext
    command_line    $USER1$/check_nrpe -t 90 -H $ARG1$ -c check_nrpe_external -a $HOSTADDRESS$ $ARG2$ $ARG3$
}

define hostgroup {
    hostgroup_name    LOCATION_B_PC
    alias             Location B PC
    members           PC1A,PC1B
}

define host {
    host_name                PC1A
    use                      windows-server
    address                  10.0.0.1
    check_command            check-host-alive
    max_check_attempts       3
    check_interval           3
    check_period             workhours
    notification_interval    60
    notification_period      workhours
}

define host {
    host_name                PC1B
    use                      windows-server
    address                  10.0.0.2
    check_command            check-host-alive
    max_check_attempts       3
    check_interval           3
    check_period             workhours
    notification_interval    60
    notification_period      workhours
}

define service {
    use                    generic-service
    hostgroup_name         LOCATION_B_PC
    service_description    CPU Load
    check_period           workhours
    check_command          check_nrpe_ext!192.168.0.2!check_cpu!'-a show-all'
}

define service {
    use                    generic-service
    hostgroup_name         LOCATION_B_PC
    service_description    Disk Usage
    check_period           workhours
    check_command          check_nrpe_ext!192.168.0.2!check_drivesize!'-a drive=*'
}
SERVERB's nrpe.cfg:

Code: Select all

command[check_nrpe_external]=/usr/local/nagios/libexec/check_nrpe -n -t 90 -H $ARG1$ -c $ARG2$ $ARG3$
That should work.
xinxolHH
Posts: 14
Joined: Mon Feb 18, 2019 4:47 am

Re: NRPE monitor Windows Clients connected to the Nagios Rem

Post by xinxolHH »

Hello ssax,

Yes, it does work. thanks for explanation and the example. I was a bit "worried" about the question in defining other commands in ServerB.
I am considering this post a nice learning experience for NRPE, and now it works, with the proper syntax and the understanding.
thanks for the help. if there is no more other remarks for this topic we may close this question and set-up as resolved.

Many thanks,
X.
Locked