Configure Nagios to monitor multiple environments

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
NicoN
Posts: 3
Joined: Tue Jun 26, 2018 3:40 am

Configure Nagios to monitor multiple environments

Post by NicoN »

Good day

Can someone please assist on how to configure nagios to navigate to, and display more than one environment on the same host? For example:

http://host/nagios/uat
http://host/nagios/prod


In short, I've tried and copied most folders/files inside /usr/local/nagios/, rename them, and tried some config changes e.g.

etc/cgi_uat.cfg , nagios_uat.cfg
etc/cgi_prod.cfg , nagios_prod.cfg


Als too tried configure apache config and created two nagios.configs e.g.

nagios_uat.conf
nagios_prod.conf


But still it only displayed one and the same environment, irrespective if I navigated to the UAT or to PROD URL's

Thanks
Nic
scottwilkerson
DevOps Engineer
Posts: 19396
Joined: Tue Nov 15, 2011 3:11 pm
Location: Nagios Enterprises
Contact:

Re: Configure Nagios to monitor multiple environments

Post by scottwilkerson »

you would also need to start 2 different instances of nagios

Code: Select all

/usr/local/nagios/bin/nagios -c /usr/local/nagios/etc/nagios_prod.cfg -d
and

Code: Select all

/usr/local/nagios/bin/nagios -c /usr/local/nagios/etc/nagios_uat.cfg -d
Either way this is going to be a mess because you are going to have to change all the paths in all of the files to reference the new paths for each type

Finally you would need to change the http directive to match the correct share and cgi directories.

Honestly, if at all possible I would recommend just installing Nagios on 2 separate VM's
Former Nagios employee
Creator:
Human Design Website
Get Your Human Design Chart
NicoN
Posts: 3
Joined: Tue Jun 26, 2018 3:40 am

Re: Configure Nagios to monitor multiple environments

Post by NicoN »

Thanks for the reply
Preferably would like to stick to one VM monitoring multiple environments.
But will give it one more try though...

The actual problem seems to be it everytime reads the below default main config file, irrespective of the changes and different URL's

Code: Select all

['main_config_file']='/usr/local/nagios/etc/cgi.cfg';
Explanation:
Ive tried and started two seperate nagios daemons as suggested (the -c option does not exists)

Code: Select all

/usr/local/nagios/bin/nagios -d /usr/local/nagios/etc/nagios_uat.cfg
/usr/local/nagios/bin/nagios -d /usr/local/nagios/etc/nagios_prod.cfg


All config related folders were copied and modified to a uat path
/usr/local/nagios/uat/* -- etc, share, sbin ..

I've changed nagios/uat/share/config.inc.php, to point to a new UAT config

Code: Select all

['main_config_file']='/usr/local/nagios/uat/etc/cgi.cfg';
After some tests realised the problem is that it still reads the original file '/usr/local/nagios/etc/cgi.cfg'
Irrespective of the URL
http://host/uat
http://host/prod

Any idea how to make it read the uat config file?

Snippets of Updated Apache UAT config

Code: Select all

ScriptAlias /uat/cgi-bin "/usr/local/nagios/uat/sbin"
Alias /uat "/usr/local/nagios/uat/share"
<Directory "/usr/local/nagios/uat/share"
scottwilkerson
DevOps Engineer
Posts: 19396
Joined: Tue Nov 15, 2011 3:11 pm
Location: Nagios Enterprises
Contact:

Re: Configure Nagios to monitor multiple environments

Post by scottwilkerson »

Oh yes, you hit the other problem

What you would need to do is re-compile nagios for this 2nd version and pass the following to the ./configure

Code: Select all

./configure --sysconfdir=/usr/local/nagios/uat/etc
but then you would need to have the binaries stored in a different location.... and down the rabbit hole you go

Around line 1425 you can see the configure options
https://github.com/NagiosEnterprises/na ... /configure
Former Nagios employee
Creator:
Human Design Website
Get Your Human Design Chart
NicoN
Posts: 3
Joined: Tue Jun 26, 2018 3:40 am

Re: Configure Nagios to monitor multiple environments

Post by NicoN »

Thanks very much for assistance, issue clarified now. Decided to go for a Nagios VM per environment
scottwilkerson
DevOps Engineer
Posts: 19396
Joined: Tue Nov 15, 2011 3:11 pm
Location: Nagios Enterprises
Contact:

Re: Configure Nagios to monitor multiple environments

Post by scottwilkerson »

NicoN wrote:Thanks very much for assistance, issue clarified now. Decided to go for a Nagios VM per environment
Sounds like a good plan
Former Nagios employee
Creator:
Human Design Website
Get Your Human Design Chart
Locked