| Version 3 (modified by mickem, 4 years ago) (diff) |
|---|
TracNav
Documentation
Guides
Information
Sponsoring
Modules
Checks and commands
- CauseCrashes
- CheckNSCP
- CheckDisk
- CheckLogFile
- CheckEventLog
- CheckSystem
- CheckHelpers
- CheckTaskSched
- CheckTaskSched2
- CheckWMI
Scripting Languages?
Servers and protocols?
- check_nrpe (NRPE Server)
- check_nrpe (NRPE Client)
- check_nt (NSClient Server)
- check_nt (NSClient Client)?
- NSCA (NSCA Server)
- NSCA (NSCA Client)
- NRDP (NRDP Client)
- check_mk (CheckMK Server)
- check_mk (CheckMK Client)
- graphite (Graphite Client)
- SMTP (SMTP Client)
- syslog (Syslog Client)
Utilities and tools?
Donate
Using NSClient++ from nagios with check_nrpe
NRPE is the preferred way over NSClient (check_nt) and you get the most out of NSClient++ choosing this mode (NSCA and what not will support the same commands but are more complex to setup). NRPE works much like NRPE for unix (if you are familiar with it) and in short you can say it relays a plugin request to a remote server. NRPE acts like a simple transport layer allowing remote execution. The difference between regular NRPE and NSClient++ is that NSClient++ has built-in checks. So with NSClient++ you get a lot of ready-to-use checks that wont require you to have scripts. But if you choose you can disable all "modules" and stick with a pure NRPE installation and only external scripts.
1. Overview of NRPE
For those not familiar with NRPE (Nagios Remote Plugin Execution) here is a quick introduction.
NRPE works much like SSH or telnet etc. It relays a command and awaits the result. In the above diagram what happens is:
- Nagios executes check_nrpe with the proper arguments.
- NSClient++ receives the command to be executed
- NSClient++ will execute the command and get a result on the form of <status>, <message> and optionally <performance data>
- NSClient++ sends the result back to Nagios
- Nagios gets the result from check_nrpe (and uses it much like any other plugin)
So in essence NRPE is merely a transport mechanism to send the result of a check command over the network.
2. using from the command line
NRPE require you to install a special plug-in on your nagios server called NRPE. The unix-side of NRPE consists of a server and a client on nagios you only need the client so you can skip any "servers" or what not that it want to start when you install it.
The client is (generally) called check_nrpe and works like so:
./check_nrpe -H <nsclient++ server ip> -c <command> [-a <a> <list> <of> <arguments>]
- <command> = The command (script) you want to run (often this is a pre-built command from within NSClient++)
- <a> <list> <of> <arguments> = a list of arguments for the command.
So the simplest way to see if things are a-working just run it without a command and you should get a response specifying the version of "NRPE" (in this case NSClient++) like so:
./check_nrpe -H <nsclient++ server ip> I (0.3.3.19 2008-07-02) seem to be doing fine...
And again like in the NSClient example above don't worry if you get a timeout here since we have to configure NSClient++ before it actually works.
First think about a nagios command to check the actual installed version (see above)
# 'check_nrpeVersion' command definition
define command{
command_name check_nrpeVersion
command_line $USER1$/check_nrpe -H $HOSTADDRESS$ -p 5666
}
3. NSClient++ configuration
Configuring NRPE is a bit more involved but not overly so. The first thing you need to do to get things working is add the NRPEListener module.
[modules] ... NRPEListener.dll ...
If you have not already done so (above) you also need to set which computers are allowed to query the agent. This is set either under the [Settings] section (globally) or under the [NRPE] section (locally). If you when you configured NSClient above set this globally you are already set to go. If not the key you need to change is the allowed_hosts. There is no password for NRPE.
- allowed_hosts = A list of addresses that is allowed to ask questions (i.e. your nagios ip).
The result should look like this (assuming your nagios server ip address is 10.0.0.2):
[Settings] allowed_hosts=10.0.0.2
After this restart the service.
nsclient++ /stop nsclient++ /start ... or ... net stop nsclientpp net start nsclientpp
Now feel free to try the command line agent again and hopefully things should work out perfectly. Run the following command from your nagios server.
./check_nrpe -H 10.0.0.1 I (0.3.3.19 2008-07-02) seem to be doing fine...
4. Finding and solving problems
A good way to find and solve problems is to run nsclient++ in "test" mode this is done by stopping the service and starting it in "test" mode.
nsclient++ /stop nsclient++ /test ... test mode ... (quit with: exit) nsclient++ /start
When in test mode you will get a lot of interesting log messages when things are happening so it is fairly simple to figure out what is wrong.
NSClient++ configuration (revisited)
As we said before it is a bit more involved to configure NRPE and yet thus far it has actually been simpler? This is because we have not configured things yet NRPE has a few more keys and I shall go over the most important ones here:
- use_ssl Boolean If this is 1 (true) we will use SSL encryption when communicating. Notice this flag has to be the same on both ends or you will end up with strange errors. The flag is set on check_nrpe with the -n option (if you use -n no SSL will be used).
- allow_arguments Since arguments can be potentially dangerous (it allows your users to control the execution) there is a flag (which defaults to off) to enable arguments. So if you plan on control NSClient++ from the nagios end you need to enable this. But be warned this is a security issue you need to think about. If you do not want to allow arguments you can instead configure all checks in the NSC.ini file and just execute the aliases from nagios.
- allow_nasty_meta_chars This flag allows arguments to contain "dangerous" characters such as redirection and pipe (<>|) and makes things a tad more dangerous. But if you decide to use arguments you most likely want to use this flag as well. But again this is a security risk
5. using from the command line (revisited)
Now that we have the agent up and running (if not probably want to go back over the previous sections to get it up and running before reading on) what can we do with it?. From here on we will assume you have allow arguments and metchars enabled since it makes it simpler to try things out. As we stated before check_nrpe is a lot more powerful then the "old" check_nt and there is a lot of built in commands as well as a lot of external ones you can use. The built in ones are listed below. ListTagged(check)? Lets start with a simple one [CheckCPU] and see how to use it.
If we check the docs for it it has an example like so:
checkCPU warn=80 crit=90 time=20m time=10s time=4 CPU Load ok.|'20m average'=11%;80;90; '10s average'=7%;80;90; '4 average'=10%;80;90;
Now this is a "NSCLient++ /test mode command" so it is not usable in it self for you instead you need to change it slightly. The first word is the command and the rest are arguments. check_nrpe has two options for settings commands (-c) and arguments (-a) and is used like so:
check_nrpe ... -c <command> [-a <argument> <argument> <argument>]
in this case (CheckCPU) this translates to:
check_nrpe ... -c CheckCPU -a <the argument list as-is> check_nrpe ... -c CheckCPU -a warn=80 crit=90 time=20m time=10s time=4 CPU Load ok.|'20m average'=11%;80;90; '10s average'=7%;80;90; '4 average'=10%;80;90;
And that is as hard as it gets all you need to do is figure out which arguments you want to use for the command and stack them all in a long line.
Attachments (5)
- nrpe-overview.png (46.3 KB) - added by mickem 4 years ago.
- nagios-active-nrpe-001.png (27.4 KB) - added by mickem 4 years ago.
- nagios-active-nrpe-002.png (27.4 KB) - added by mickem 4 years ago.
- nagios-active-nrpe-003.png (27.7 KB) - added by mickem 4 years ago.
- nagios-configuration-inheritance.png (47.0 KB) - added by mickem 4 years ago.
Download all attachments as: .zip










