Prerequisite
Before you begin verify you server and client configuration. From the server test client connection.
$ /usr/lib64/nagios/plugins/check_nrpe -H <client_ip_or_hostname>
NRPE v2.14
To setup server, see http://magnus-k-karlsson.blogspot.se/2014/01/install-nagios-core-35-on-rhel-6-from.html.
And for client, see http://magnus-k-karlsson.blogspot.se/2014/01/install-nagios-agent-nrpe-on-rhel-6.html
Client Nagios Plugins Configuration
First decide what you want to monitor. Then find a plugin that do the job. The standard plugins are documented here (http://nagios-plugins.org/doc/man/index.html).
You could also get help documentation for a specific plugin by executing it with option '--help'.
$ /usr/lib64/nagios/plugins/check_disk --help
check_disk v1.4.16 (nagios-plugins 1.4.16)
After you have tested it and is satisfied, you now define it as a nagios command.
$ vi /etc/nrpe.d/commands.cfg
...
command[check_sda2_disk]=/usr/lib64/nagios/plugins/check_disk -w 20% -c 15% -p /dev/sda2
...
Restart nrpe to let new configuration take effect.
$ service nrpe restart
Shutting down nrpe: [ OK ]
Starting nrpe: [ OK ]
Server Nagios Plugins Configuration
From the server test that you can call the client nrpe command.
$ /usr/lib64/nagios/plugins/check_nrpe -H <client_ip_or_hostname> -c check_sda2_disk
If this did not work, go back to the prerequisites and verify you server and client installation. If good, lets continue and define the nrpe command on the server.
$ vi /etc/nagios/conf.d/server1.domain.local.cfg
...
# 'check_nrpe' command definition
define command{
command_name check_nrpe
command_line $USER1$/check_nrpe -H <client_ip_or_hostname> -c $ARG1$
}
...
Then we need to define a service that will run this command.
$ vi /etc/nagios/conf.d/server1.domain.local.cfg
...
define service{
use generic-service ; Name of service template to use
host_name yourhostname.domain.local
service_description Checks partition sda2 at 20 proc and 15 proc
check_command check_nrpe!check_sda2_disk
}
...
Finally you will need to define a host, if you have not already done that.
$ vi /etc/nagios/conf.d/server1.domain.local.cfg
...
define host{
use linux-server ; Name of host template to use
; This host definition will inherit all variables that are defined
; in (or inherited by) the linux-server host template definition.
host_name yourhostname.domain.local
alias yourhostname.domain.local
address 192.168.1.117
}
...
Before we restart the nagios server, you can test you new configuration
$ nagios -v /etc/nagios/nagios.cfg
Nagios Core 3.5.1
...
Total Warnings: 0
Total Errors: 0
..
If everything is fine, you can now restart you nagios server.
Open you nagios web admin and login in and check you new service.
No comments:
Post a Comment