Using NRPE with Windows hosts

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.
neworderfac33
Posts: 329
Joined: Fri Jul 24, 2015 11:04 am

Re: Using NRPE with Windows hosts

Post by neworderfac33 »

Thanks for getting back to me - do you have any thoughts on how i could implement this into a define_service{}?
For instance, here's what I use with check_nt:

Code: Select all

define service{
       use                      generic-service,nagiosgraph
       host_name                MyServerID
       #hostgroup_name          MyHostGroup
       service_description      Drive Space - C
       #servicegroups           diskspace
       check_command            check_nt!USEDDISKSPACE!-l c -w 90 -c 95
       }
17:24 - hometime in the UK - yaay!

Have a good weekend, all! :-)

Pete
User avatar
tgriep
Madmin
Posts: 9177
Joined: Thu Oct 30, 2014 9:02 am

Re: Using NRPE with Windows hosts

Post by tgriep »

Service check example

Code: Select all

define service {
        host_name                       Windows
        service_description             Drive Space c:
        check_command                   check_nrpe!check_drivesize!-a 'drive=c:\'!!!!!!
        }
Command Definition

Code: Select all

define command {
       command_name                             check_nrpe
       command_line                             $USER1$/check_nrpe -H $HOSTADDRESS$ -c $ARG1$ $ARG2$
}
Be sure to check out our Knowledgebase for helpful articles and solutions!
neworderfac33
Posts: 329
Joined: Fri Jul 24, 2015 11:04 am

Re: Using NRPE with Windows hosts

Post by neworderfac33 »

Thanks for your reply - how do I amend this to set up warning and critical thresholds like I do with check_nt?
At the moment, I have the following:

Code: Select all

define service{
    use                  generic-service
    host_name            MN2GAM12099U
    check_command        NRPE DriveSpace C with Threshold
    service-description  check_nrpe!check_drivesize! -a drive=C: 'warning=free<5G' 'critical=free<2G' show-all 'perf-config=*(unit:G)' detail-syntax='{${drive_or_name} ${free} free / ${size}total}' top-syntax='${status}: ${problem_list}'
}
which throws up errors when I verify, because I obviously haven't specified the drive to be monitored correctly.
I LOVE this site http://sites.box293.com/nagios/guides/c ... ing-system, but do you know of anywhere that details the "define service{}" equivalents of the command lines?
Thanks
Pete
User avatar
tgriep
Madmin
Posts: 9177
Joined: Thu Oct 30, 2014 9:02 am

Re: Using NRPE with Windows hosts

Post by tgriep »

Your check_drivesize example from the post should work without any errors. I ran it on my system and it worked.
What error are you getting?
What do you mean about "but do you know of anywhere that details the "define service{}" equivalents of the command lines?"
If you are looking for more examples, take a look at NSClients site.
Be sure to check out our Knowledgebase for helpful articles and solutions!
neworderfac33
Posts: 329
Joined: Fri Jul 24, 2015 11:04 am

Re: Using NRPE with Windows hosts

Post by neworderfac33 »

Apologies for the late reply - I've been on leave for a couple of days.
When I attempt to verify with the service uncommented in my services.cfg file, I get:

Code: Select all

Nagios Core 4.2.4
Copyright (c) 2009-present Nagios Core Development Team and Community Contributors
Copyright (c) 1999-2009 Ethan Galstad
Last Modified: 12-07-2016
License: GPL

Website: https://www.nagios.org
Reading configuration data...
   Read main config file okay...
Error: Invalid service object directive 'service-description'.
Error: Could not add object property in file '/usr/local/nagios/etc/objects/services.cfg' on line 18.
Error: Invalid max_check_attempts value for host 'MYSERVER2'
Error: Could not register host (config file '/usr/local/nagios/etc/objects/associations.cfg', starting on line 77)
   Error processing object config files!
There's nothing wrong with the host definition ("MYSERVER2") that is flagged up, as when the service is commented out in services.cfg, I get no errors at validation, so it MUST be something wrong with the service.
In any case, the service is currently only pointing at one specific host "MYTESTSERVER" (the one that has the NRPE modifications to nsclient.ini), but this isn't the server that gets flagged up in the error message (although both are defined in associations.cfg) so I'm not sure why that's happening. The service doesn't seem to be restricting itself to MYTESTSERVER, but appears to be looking at all the hosts in associations.cfg as well.

Here it is again, just for reference:

Code: Select all

define service{
    use                  generic-service
    host_name            MYTESTSERVER
    check_command        NRPE DriveSpace C with Threshold
    service-description  check_nrpe!check_drivesize! -a drive=C: 'warning=free<5G' 'critical=free<2G' show-all 'perf-config=*(unit:G)' detail-syntax='{${drive_or_name} ${free} free / ${size}total}' top-syntax='${status}: ${problem_list}'
}
By the way, line 18, which is referenced in the error message is the "service-description" line within the "define service{}, if that helps.

Incidentally, I CAN run this successfully from the command prompt and it gives me the following:

Code: Select all

OK: {C: 23.173GB free / 39.656GB total}|'C: free'=23.17316G;10;5;0;39.65624 'C: free %'=58%;25;12;0;100
I'm assuming that the "10;5" refers to my warning and critical thresholds, but can't figure out what the 0;39.65624 is there for and how i can eliminate it.
Similarly, i don't understand the "25;12;0;100" at the end of the string, and how I can eliminate THAT - any offers, please?

Cheers
Pete
User avatar
tgriep
Madmin
Posts: 9177
Joined: Thu Oct 30, 2014 9:02 am

Re: Using NRPE with Windows hosts

Post by tgriep »

Your service you have defined for that check has a typo and also the options are reversed.
To fix it, edit the services.cfg file and change the following from

Code: Select all

check_command        NRPE DriveSpace C with Threshold
service-description  check_nrpe!check_drivesize! -a drive=C: 'warning=free<5G' 'critical=free<2G' show-all 'perf-config=*(unit:G)' detail-syntax='{${drive_or_name} ${free} free / ${size}total}' top-syntax='${status}: ${problem_list}'
to

Code: Select all

service_description        NRPE DriveSpace C with Threshold
check_command  check_nrpe!check_drivesize! -a drive=C: 'warning=free<5G' 'critical=free<2G' show-all 'perf-config=*(unit:G)' detail-syntax='{${drive_or_name} ${free} free / ${size}total}' top-syntax='${status}: ${problem_list}'
That should fix that error.

Then you will have to edit the associations.cfg file and add the max_check_attempts value for host 'MYSERVER2' and that should fix that error.
Take a look and an existing host and duplicate it's settings.

In the output of the check, everything on the right side of the | character is the performance data.
What that shows it the percent free, the threshold levels and the total free space as actual values and as percentages.
For more details, you can look at this link.
https://nagios-plugins.org/doc/guidelines.html#AEN200

If you do not want the performance data to be printed, you would have to edit NSClient++ ini file and disable it there.
This link describes how to do that.
https://docs.nsclient.org/reference/cli ... mance-data
Be sure to check out our Knowledgebase for helpful articles and solutions!
neworderfac33
Posts: 329
Joined: Fri Jul 24, 2015 11:04 am

Re: Using NRPE with Windows hosts

Post by neworderfac33 »

Nightmare - I copied in your redefined service and Nagios verified like magic - thank you! :-)

It must have been late when I did that one!

My output in the browser looks like this:

Code: Select all

OK {C: 23.172GB free / 39.656GB total}$ 
Any idea how I can get rid of the trailing "$" character?

Cheers

Pete
User avatar
tgriep
Madmin
Posts: 9177
Joined: Thu Oct 30, 2014 9:02 am

Re: Using NRPE with Windows hosts

Post by tgriep »

The $ come from the show-all option in the command. You need the show-all to display the drive details so you can't get rid of it.
You mat want to go to the NSClient++ web site and see if there is a way to get rid of it.
Be sure to check out our Knowledgebase for helpful articles and solutions!
User avatar
tgriep
Madmin
Posts: 9177
Joined: Thu Oct 30, 2014 9:02 am

Re: Using NRPE with Windows hosts

Post by tgriep »

Actually, I changed the command and it was not the show-all part of the command, it was from the perf-config section of the command.
If you don't need the performance data, remove the following and the $ will not show up in the GUI.

Code: Select all

 'perf-config=*(unit:G)' detail-syntax='{${drive_or_name} ${free} free / ${size}total}' top-syntax='${status}: ${problem_list}'
Be sure to check out our Knowledgebase for helpful articles and solutions!
neworderfac33
Posts: 329
Joined: Fri Jul 24, 2015 11:04 am

Re: Using NRPE with Windows hosts

Post by neworderfac33 »

Yep - that got it - thank you VERY much! I can see much potential for check_nrpe across our estate, but it's a good job I have a Powershell script to copy over a new NSClient++.ini and restart the service, otherwise it could become VERY time consuming to adopt.

You can close this thread now.

Regards

Pete
Locked