Monitor multiple servers with single public IP by Nagios

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
msachikanta
Posts: 58
Joined: Tue Jan 03, 2012 2:35 am

Monitor multiple servers with single public IP by Nagios

Post by msachikanta »

Hello,

I am looking for a solution where nagios can monitor multiple hosts with single Public IP where Public port will be different according hosts. Currently I have added one hosts with public port and public IP which is working fine. But when i am trying to add other hosts with different public port and same public IP its giving me error.

Can anyone guide me how to monitor multiple servers with respective public port and single public IP. the scenario will be like below.

host1 - Public Port is 50022, Public IP is 75.124.74.73
host2 - Public Port is 50023, Public IP is 75.124.74.73
host3 - Public Port is 50024, Public IP is 75.124.74.73

like above I just want to Implement Nagios. Please help me if anyone aware of it.

Thanks,
Sachikanta
tmcdonald
Posts: 9117
Joined: Mon Sep 23, 2013 8:40 am

Re: Monitor multiple servers with single public IP by Nagios

Post by tmcdonald »

What error are you receiving? If you are trying to have multiple hosts the IP should not matter as long as the names are unique. And as for the ports, if they each only have one port open you could use NRPE or something similar and funnel all checks through that. Or make them all passive and the port/IP really isn't even an issue anymore.
Former Nagios employee
msachikanta
Posts: 58
Joined: Tue Jan 03, 2012 2:35 am

Re: Monitor multiple servers with single public IP by Nagios

Post by msachikanta »

I was getting duplicate host entry found in configuration file for server 75.124.74.73

Actually I am trying monitor Servers hosted under one zone in cloud Compute environment. In this case Public IP 75.124.74.73 is belongs to US Zone and its having two servers hosted under it, where ssh port is same for both the servers that is 22, and i have done the port forwarding on cloud compute level two identify the two servers by public IP. The reason is my Nagios Server is hosted under different Zone.

Regards,
Sachikanta
User avatar
eloyd
Cool Title Here
Posts: 2190
Joined: Thu Sep 27, 2012 9:14 am
Location: Rochester, NY
Contact:

Re: Monitor multiple servers with single public IP by Nagios

Post by eloyd »

You can't have more than one host with the same name. But you could have multiple names that point to the same IP if you have /etc/host or DNS capabilities.

I'm not sure what you want to monitor exactly, but I'd specify one host with the correct IP, and use check_dummy as the host check. Then I'd make three services, one for each port, that monitored the status of each individual machine.

I think that accomplishes what you're trying to do.
Image
Eric Loyd • http://everwatch.global • 844.240.EVER • @EricLoyd
I'm a Nagios Fanatic! • Join our public Nagios Discord Server!
User avatar
lmiltchev
Bugs find me
Posts: 13589
Joined: Mon May 23, 2011 12:15 pm

Re: Monitor multiple servers with single public IP by Nagios

Post by lmiltchev »

msachikanta, have you tried the solution provided by eloyd?
Be sure to check out our Knowledgebase for helpful articles and solutions!
msachikanta
Posts: 58
Joined: Tue Jan 03, 2012 2:35 am

Re: Monitor multiple servers with single public IP by Nagios

Post by msachikanta »

Hi,

I have found a different solution, like - in our case only one public IP will be allocate to a zone in cloud compute and servers under that zone will get private ip's accordingly, so the servers which would have build under that zone can be access from one public IP with different public ssh port by port forwarding method of Cloud Compute.

Following are my configuration that i have done and tested as of now:
1 - Nagios server is connecting to one server (example server01) in that zone by public IP and public ssh port of server01.
2 - Now server01 will get all data from rest of the servers (server02, server03 etc..) which would have built under that zone and update to nagios server.

I have used the below command from nagios server to get update from rest of the other servers from that zone by server01.

/usr/local/nagios/libexec/check_by_ssh -p 30006 -l nagios -H 75.124.74.73 -C "/usr/local/nagios/libexec/ check_by_ssh -l nagios -H server02 -C 'uname -a'"

(75.124.74.73 is the public IP and public port 30006 is mapped to internal port 22 for server01)

Output: Linux server02 3.5.0-17-generic #28-Ubuntu SMP Tue Oct 9 19:31:23 UTC 2012 x86_64 x86_64 x86_64 GNU/Linux

In the above command server01 will be act like a gateway between nagios server and servers (server02, server03 etc..). similarly for rest of the servers i am using the same method.

Under host definition i have my public IP as address and zone name as the host_name so that t will be easy to identify the servers zone wise.
Under Host group definition i have specified the Zone name to identify in Nagios Web portal.

That's how i have fulfilled my requirement. Hope it will help others in preparing this kind of environment.

Regards,
Sachikanta
User avatar
eloyd
Cool Title Here
Posts: 2190
Joined: Thu Sep 27, 2012 9:14 am
Location: Rochester, NY
Contact:

Re: Monitor multiple servers with single public IP by Nagios

Post by eloyd »

You have now, unintentionally, created a parent/child relationship between your gateway and your destination hosts. You will most likely want to set a dependency that says that the child hosts are only checked if the parent host is in an OK state. Otherwise, if your gateway host goes down, your destination hosts will look like they are down as well.

But yes, you can "chain" ssh checks this way, and in fact, we do it all the time to get around firewall restrictions very similar to what you have done here.
Image
Eric Loyd • http://everwatch.global • 844.240.EVER • @EricLoyd
I'm a Nagios Fanatic! • Join our public Nagios Discord Server!
Locked