check_pgsql doesn't work

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.
tezarin
Posts: 32
Joined: Tue Apr 07, 2015 8:03 am

Re: check_pgsql doesn't work

Post by tezarin »

Thanks much for your reply.

I found the check_ssh plugin inside the plugin directory, now assuming I'm on my localhost and ran the following two commands and already have the SSH tunnel running, what would my check_ssh command look like?

On my local host, where nagios is installed:
192.168.1.5 is the IP of the remote host which is on a restricted network:

ssh -f [email protected] -L 5000:192.168.1.5:5432 -N

Then on localhost, run ./check_tcp -H 192.168.1.5 -p 5000 -v

Thanks much in advance
User avatar
tgriep
Madmin
Posts: 9190
Joined: Thu Oct 30, 2014 9:02 am

Re: check_pgsql doesn't work

Post by tgriep »

If you want to check to see if port 5432 is open on the remote system over the ssh tunnel, I think you would use this as your check

Code: Select all

./check_tcp -H localhost -p 5000 -v
Since port 5000 on the localhost is tunneled to 5432 on the remote host, this is what you would use.
Be sure to check out our Knowledgebase for helpful articles and solutions!
tezarin
Posts: 32
Joined: Tue Apr 07, 2015 8:03 am

Re: check_pgsql doesn't work

Post by tezarin »

Thanks much, that's exactly what I'm currently doing.

Now, since on my localhost I don't have anything that listens to port 5432, I modified my SSH tunnel port number from 5000 to 5432, now I probably can use the check_pgql plugin.Has anybody used either check_pgsql or check_rabbitmq?

I found a check_rabbitmq plugin from here: https://github.com/CaptPhunkosis/check_rabbitmq and added it to the plugins directory. Then, used the ssh tunnel command like this:

ssh -f [email protected] -L 15672:192.168.1.11:15672 -N
192.168.1.11 is where I have the Rabbitmq installed.

But when I tried to run the check_rabbitmq on the localhost, I get an error:

./check_rabbitmq -a connection_count -C 100 -W 80

Looks like the command needs to be executed on the machine where rabbitmq is installed not on the machine where Nagios is installed, is that true? I can't install NRPE on this remote server, check_tcp will work: ./check_tcp -H localhost -p 15672 but that's not what I would like to do, I want to be able to take advantage of the check_rabbitmq plugin as it was intended to which is checking on the queues, etc.:

Usage: ./check_rabbitmq -a [action] -C [critical] -W [warning]
Actions:
- connection_count
checks the number of connection in rabbitmq's list_connections
- queues_count
checks the count in each of the queues in rabbitmq's list_queues

Will that be possible to use check_rabbitmq and check_pgsql the way they intended to be used?

Thanks
jolson
Attack Rabbit
Posts: 2560
Joined: Thu Feb 12, 2015 12:40 pm

Re: check_pgsql doesn't work

Post by jolson »

Looks like the command needs to be executed on the machine where rabbitmq is installed not on the machine where Nagios is installed, is that true? I can't install NRPE on this remote server, check_tcp will work: ./check_tcp -H localhost -p 15672 but that's not what I would like to do, I want to be able to take advantage of the check_rabbitmq plugin as it was intended to which is checking on the queues, etc.:
I took a look at the check_rabbitmq plugin - it looks like it's designed to be run on the same server rabbitmq is installed on. In this case, you will either need to use NRPE or the check_by_ssh plugin. Either way, the check_rabbitmq plugin needs to be installed on the remote system.
Will that be possible to use check_rabbitmq and check_pgsql the way they intended to be used?
Yes. The complication is that check_rabbitmq needs to be installed on the same server that rabbitmq is running on.

As for check_pgsql, it can be initiated remotely - but you will need remote access (open port, credentials) to the pgsql server in question. If that isn't possible, you could install the plugin on the remote pgsql server and use check_by_ssh or NRPE to run the check locally.
Twits Blog
Show me a man who lives alone and has a perpetually clean kitchen, and 8 times out of 9 I'll show you a man with detestable spiritual qualities.
tezarin
Posts: 32
Joined: Tue Apr 07, 2015 8:03 am

Re: check_pgsql doesn't work

Post by tezarin »

Jolson,

Thanks for your reply. You said I should use check_by_ssh, could you elaborate on that a little? What will I achieve if I replace the check_tcp with check_by_ssh? Any examples on how to use it to monitor rabbitmq and pgsql?

Thanks
jolson
Attack Rabbit
Posts: 2560
Joined: Thu Feb 12, 2015 12:40 pm

Re: check_pgsql doesn't work

Post by jolson »

I'll walk through how this would work out:

1. You would run check_by_ssh on the Nagios Core box in question.

2. The Nagios Core box would login to your rabbitmq server via SSH as a specified user.

3. Now, the specified user will run a plugin that you specify. The plugin must be on the remote server somewhere, and the user needs to be able to execute the plugin.

4. The plugin results are returned to Nagios.


An example command may look something like this:

Code: Select all

/usr/local/nagios/libexec/check_by_ssh -H <remoteserverip> -C "/home/user/bin/check_load -w 60 -c 80"
Note that you must replace <remoteserverip> with the IP address of your remote server to log into via SSH. You must also specify the command to run using the '-C' flag.

You will need to have key-based authentication set up on the remote server as well. I recommend this document: https://assets.nagios.com/downloads/nag ... ng_SSH.pdf
Twits Blog
Show me a man who lives alone and has a perpetually clean kitchen, and 8 times out of 9 I'll show you a man with detestable spiritual qualities.
tezarin
Posts: 32
Joined: Tue Apr 07, 2015 8:03 am

Re: check_pgsql doesn't work

Post by tezarin »

Jolson,

Thanks much for your great reply, I will see if I can get authorization to install something on the remote host first and we go from there.
jolson
Attack Rabbit
Posts: 2560
Joined: Thu Feb 12, 2015 12:40 pm

Re: check_pgsql doesn't work

Post by jolson »

No problem - I'm looking forward to your results.
Twits Blog
Show me a man who lives alone and has a perpetually clean kitchen, and 8 times out of 9 I'll show you a man with detestable spiritual qualities.
tezarin
Posts: 32
Joined: Tue Apr 07, 2015 8:03 am

Re: check_pgsql doesn't work

Post by tezarin »

Sure, thanks much
jolson
Attack Rabbit
Posts: 2560
Joined: Thu Feb 12, 2015 12:40 pm

Re: check_pgsql doesn't work

Post by jolson »

No problem.
Twits Blog
Show me a man who lives alone and has a perpetually clean kitchen, and 8 times out of 9 I'll show you a man with detestable spiritual qualities.
Locked