Best practice for config files

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.
Locked
lraymond
Posts: 29
Joined: Thu Jul 12, 2012 10:14 am

Best practice for config files

Post by lraymond »

ok I had some help from the board with some initial things and now I'm running but ready to roll this out to more servers and just wanted some help/direction as to the best way to go about it. I have 3 windows servers which are in one windows config, a host-group, all separate IP's and things are working perfect.

I have added a test remote linux server with a public IP, NRPE and monitoring some basics like load, processes and there working perfect. That box is under one config (linux-remote). My next step is to monitor my tomcat servers (I have 5) which are behind a loadbalancer. The LB has some 1-1 virtual services so from the nagios server I can issue;
/usr/lib/nagios/plugins/check_nrpe -H n.tc1.domain.com -p 5667
NRPE v2.12 is what get's returned.

I can do the same for 5668 which goes to server 2 (all the servers are listening on 5666 and the LB is switching). Now finally the question(s).

I don't think I can define a port at the host level can I? Basically I want a tomcat.cfg with something like this;

define host{
use linux-remote
host_name tc1
address 1.1.1.1
port 5667
}

By doing that I can then just define;
define service{
use generic-service,srv-pnp
host_name tc1
service_description Server Load
check_command check_nrpe!check_load
}

A basic service. I know I can define the port in the service, but then if I had 25 servers behind the LB, I would have 25 * number of services which would be HUGE config wise. So I was looking to make a hostgroup of each group and give them one service but not sure if it's possible.

That is the basic set of what I want. If I can't and need to define each service port, should I still keep under one file, or make a file for each server?

Thanks
User avatar
jsmurphy
Posts: 989
Joined: Wed Aug 18, 2010 9:46 pm

Re: Best practice for config files

Post by jsmurphy »

In your commands.cfg look for your check_nrpe definition... it will look similar to:

Code: Select all

$USER1$/check_nrpe -H $HOSTADDRESS$ -u -t 30 -c $ARG1$ $ARG2$
so the easiest way to fix this would be to change your service definition to:

Code: Select all

define service{
use generic-service,srv-pnp
host_name tc1
service_description Server Load
check_command check_nrpe!check_load!-p 5668
}
Basically we are inserting the -p 5668 switch into where ARG2 is, which is used to tell check_nrpe which port to connect to. If however you are using this same service on all the tomcat servers instead of 1 service per server, you could accomplish this using host macros.

Code: Select all

define host{
use	 linux-remote
host_name	 tc1
address	1.1.1.1
_tcport 5668
}

define host{
use	 linux-remote
host_name	 tc2
address	2.2.2.2
_tcport 5669
}

define service{
use generic-service,srv-pnp
host_name tc1,tc2
service_description Server Load
check_command check_nrpe!check_load!-p $_HOSTTCPORT$
}
More information on custom macros: http://nagios.sourceforge.net/docs/3_0/ ... tvars.html and http://nagios.sourceforge.net/docs/3_0/macros.html
lraymond
Posts: 29
Joined: Thu Jul 12, 2012 10:14 am

Re: Best practice for config files

Post by lraymond »

That is EXACTLY what I was looking to do. I didn't want 50 services, I simply wanted each host to have one little variable and use the same service. Each NRPE host is listening on the default 5666, but to test each, I have the loadbalancer listen on multiple, so tc1 will hit the public IP port 5667 which sends to server 1 port 5666, tc2 same IP port 5668, etc.

Will test this and close if all good.

Thanks.
slansing
Posts: 7698
Joined: Mon Apr 23, 2012 4:28 pm
Location: Travelling through time and space...

Re: Best practice for config files

Post by slansing »

Great! Let us know if it worked out.
Locked