Overview
This guide will show you how to install NSClient++ on Microsoft Windows to send NSCA check results to a server running NSCA.
Download NSClient++
All downloads should be obtained from:
http://www.nsclient.org/download/
You should download the .msi installer file.
Install NSClient++
IF you already have NSClient++ installed on this computer then you can skip this step, as you can enable the modules as described in the steps further on.
Run the installer you previously downloaded
The welcome page appears
Click Next
Tick the box I accept the terms in the License Agreement
Click Next
Click Custom
Accept the default ini file location
Click Next
Tick the box Install sample configuration
Tick the box Allow users to write config file
Click Next
Allowed hosts
Leave this blank as it's not required for NSCA
NSClient Password
Leave this blank as it's not required for NSCA
Modules to load (tick the following):
Enable common check plugins
Enable NSCA client
Click Next
Click Install
Wait for NSClient++ to install
When installer has completed click Finish
Configure NSClient++
There are a couple of final settings to change in the config file.
Open a command prompt
Type:
cd "\Program Files\NSClient++\"
Type:
nscp settings --activate-module NSCAClient --add-defaults
This may prompt you for permission.
The last command adds default settings to the config file.
Type:
notepad "C:\Program Files\NSClient++\nsclient.ini"
This opens the config file in Notepad and the options are explained in more detail next.
When you are looking at the config file you'll see lots of options and sections. However the bare minimum required to make NSCA work is as follows (NOTE: if a setting or section does not exist in your file, simply add it):
This section enables all the modules required to make NSCA work.
[/modules]
CheckSystem = enabled
NSCAClient = enabled
Scheduler = enabled
In this section, the only thing worth mentioning here is that if you want to change the actual hostname that is reported to the NSCA server, you and define it here instead of using auto (this will use the windows computers name).
[/settings/NSCA/client]
channel = NSCA
hostname = auto
This is where you define the destination NSCA server and the required parameters. The encryption and password must be the same on the NSCA server.
[/settings/NSCA/client/targets/default]
address = 10.25.5.2
encryption = 1
password = Passw0rd
This is where you define how often you want NSClient++ to run the checks and then submit the check results to the NSCA server.
[/settings/scheduler/schedules/default]
interval = 1m
Here are the actual checks being performed and the results for each of these checks will be submitted to the NSCA server.
[/settings/scheduler/schedules]
CPU Load = checkCPU warn=80 crit=90 time=5m time=1m time=30s
Memory Usage = checkMem MaxWarn=80% MaxCrit=90% ShowAll=long type=physical type=virtual type=paged type=page
Once you've made any required changes, Save and Close the nsc.ini file
To make it clear, the NSCA server will receive two service check results.
-
The first one will be for the service named CPU Load
- NSClient++ uses checks build into it's CheckSystem module, specfically checkCPU
-
The second one will be for the service named Memory Usage
-
NSClient++ uses checks build into it's CheckSystem module, specfically checkMem
-
Start NSClient++ Service
Open the Run dialog (Windows Key + R)
Type:
services.msc
This opens the Services management console.
Find NSClient++ service
Right click it and select Start
Wait for the service to start
Close the services management console when service is started
Observe Nagios Log
Now that NSClient++ is configured and running, it will be submitting check results to NSCA at every interval defined in nsc.ini. To watch them arrive:
SSH to your Nagios NSCA server.
Type:
tail -f /usr/local/nagios/var/nagios.log
You should see data like:
[1419048801] EXTERNAL COMMAND: PROCESS_SERVICE_CHECK_RESULT;DC01;CPU Load;0;OK CPU Load ok.|'5m'=0%;80;90 '1m'=1%;80;90 '30s'=2%;80;90
[1419048801] Warning: Passive check result was received for service 'CPU Load' on host 'DC01', but the host could not be found!
[1419048801] Error: External command failed -> PROCESS_SERVICE_CHECK_RESULT;DC01;CPU Load;0;OK CPU Load ok.|'5m'=0%;80;90 '1m'=1%;80;90 '30s'=2%;80;90
[1419048801] External command error: Command failed
[1419048806] EXTERNAL COMMAND: PROCESS_SERVICE_CHECK_RESULT;DC01;Memory Usage;0;OK: physical memory: Total: 2G - Used: 675M (32%) - Free: 1.34G (68%), virtual memory: Total: 8T - Used: 212M (0%) - Free: 8T (100%), paged bytes: Total: 4G - Used: 693M (16%) - Free: 3.32G (84%), page file: Total: 4G - Used: 693M (16%) - Free: 3.32G (84%)|'physical memory %'=32%;80;90 'physical memory'=675.266M;1638.044;1842.799;0;2047.555 'virtual memory %'=0%;80;90 'virtual memory'=211.672M;6710886.3;7549747.087;0;8388607.875 'paged bytes %'=16%;80;90 'paged bytes'=692.559M;3276.087;3685.598;0;4095.109
[1419048806] Warning: Passive check result was received for service 'Memory Usage' on host 'DC01', but the host could not be found!
[1419048806] Error: External command failed -> PROCESS_SERVICE_CHECK_RESULT;DC01;Memory Usage;0;OK: physical memory: Total: 2G - Used: 675M (32%) - Free: 1.34G (68%), virtual memory: Total: 8T - Used: 212M (0%) - Free: 8T (100%), paged bytes: Total: 4G - Used: 693M (16%) - Free: 3.32G (84%), page file: Total: 4G - Used: 693M (16%) - Free: 3.32G (84%)|'physical memory %'=32%;80;90 'physical memory'=675.266M;1638.044;1842.799;0;2047.555 'virtual memory %'=0%;80;90 'virtual memory'=211.672M;6710886.3;7549747.087;0;8388607.875 'paged bytes %'=16%;80;90 'paged bytes'=692.559M;3276.087;3685.598;0;4095.109
[1419048806] External command error: Command failed
This confirms that NSClient++ is working.
The errors are simply because there are no services called "CPU Load" or "Memory Usage" for the host localhost
NOTE: Once you add service objects to Nagios for these Passive check results, they will no longer be logged in nagios.log unless you define this in your core nagios.cfg.
What about the Host itself?
When NSCA receives these check results, they are targeted at a host, because all services in Nagios must belong to a host. You can actually submit a check result for the host object itself , simply add this to nsc.ini:
[/settings/scheduler/schedules]
host_check = CheckOK "Everything is working fine"
And you will see these results in nagios.log:
[1419048991] EXTERNAL COMMAND: PROCESS_HOST_CHECK_RESULT;DC01;0;Everything is working fine
[1419048991] Warning: Passive check result was received for host 'DC01', but the host could not be found!
[1419048991] Error: External command failed -> PROCESS_HOST_CHECK_RESULT;DC01;0;Everything is working fine
[1419048991] External command error: Command failed
More Examples
Different checks require different modules in NSClient++ to be enabled:
Disks
[/modules]
CheckDisk = enabled[/settings/scheduler/schedules]
Drive Usage = CheckDriveSize MinWarn=10% MinCrit=5% CheckAll FilterType=FIXED
WMI Queries
[/modules]
CheckWMI = enabled
[/settings/scheduler/schedules]
Operating System Version = CheckWMI "Query=Select Version,Caption from win32_OperatingSystem"
Nagios Passive Host and Service Definitions
Don't forget to create passive host and service definitions for these inbound NSCA check results.
Here are some to compliment these examples.
Summary
At this point NSClient++ is now installed and configured. In the example above, it will send check results to the NSCA server 10.25.5.2 every 1 minute.
Final Thoughts
For any support related questions please visit the Nagios Support Forums at: