Check_http over a proxy

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.
mleo40
Posts: 37
Joined: Tue Jan 27, 2015 10:21 pm

Check_http over a proxy

Post by mleo40 »

We are moving our nagios server behind a firewall and will need to route a lot of our check_http over a proxy

I have added variables to /etc/sysconfig/nagios and have confirmed /etc/init.d/nagios is sources that file and have restarted.

However, none of my check make it through.

Is there a way to verify that it is actually sourcing that file?

Where else can I universally set proxy settings so I don't have to re-write all of my checks?

From the command line:
./check_http --hostname={HOSTNAME} -v
CRITICAL - Socket timeout after 10 seconds

./check_http --hostname={HOSTNAME} -L {PROXY} -v
...
**** CONTENT ****
<html>
<head><title>301 Moved Permanently</title></head>
<body bgcolor="white">
<center><h1>301 Moved Permanently</h1></center>
<hr><center>nginx/1.4.7</center>
</body>
</html>

Thanks in advance
User avatar
hsmith
Agent Smith
Posts: 3539
Joined: Thu Jul 30, 2015 11:09 am
Location: 127.0.0.1
Contact:

Re: Check_http over a proxy

Post by hsmith »

What operating system are you running on? Did you update your profile to have the proxy added?
Former Nagios Employee.
me.
mleo40
Posts: 37
Joined: Tue Jan 27, 2015 10:21 pm

Re: Check_http over a proxy

Post by mleo40 »

redhat linux 6.something.

What profile? It is a shell environment setting already (etc/profile.d/{shell}.sh and .bash) and in /etc/sysconfig/nagios where the nagios documents say to put it.

Is there somewhere else my proxy settings should be so that nagios traffic naturally flows over it?
User avatar
hsmith
Agent Smith
Posts: 3539
Joined: Thu Jul 30, 2015 11:09 am
Location: 127.0.0.1
Contact:

Re: Check_http over a proxy

Post by hsmith »

Is this the document you were referring to?

https://support.nagios.com/wiki/index.p ... th_Proxies

I was referring to ~/.bash_profile
Former Nagios Employee.
me.
mleo40
Posts: 37
Joined: Tue Jan 27, 2015 10:21 pm

Re: Check_http over a proxy

Post by mleo40 »

FYI: that makes no difference because the same environment settings are pulled in from /etc/sysconfig/profile.d/{name}.sh or bash when the nagios user logs in.
mleo40
Posts: 37
Joined: Tue Jan 27, 2015 10:21 pm

Re: Check_http over a proxy

Post by mleo40 »

Your reply only talks about nagiosXI...is there a similar nagios core 4.1.1 solution?
jolson
Attack Rabbit
Posts: 2560
Joined: Thu Feb 12, 2015 12:40 pm

Re: Check_http over a proxy

Post by jolson »

I'd like to know more about the configuration changes that you made to get your proxy working, and any guides you may have followed. What does your /etc/sysconfig/nagios files look like?
cat /etc/sysconfig/nagios

It is my understanding that Nagios Core is not aware of /etc/sysconfig/nagios, which is why I'm curious about any guides you might have followed. In my experience, re-writing your service checks is the only way to accomplish what you're trying to do, but if you have a guide or information that states otherwise I would like to see it.
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.
amprantino
Posts: 140
Joined: Thu Apr 18, 2013 8:25 am
Location: libexec

Re: Check_http over a proxy

Post by amprantino »

You may use the following to check a proxy without messing with the system
define command{
command_name check_proxy_auth
command_line $USER1$/check_proxy $ARG1$ $ARG2$ $ARG3$
}

check_command check_proxy_auth!proxy1:8080!www.kernel.org!40
Inside the script (line 73) you can define a user:

$WGET --proxy-user "domain\users" --proxy-password "mypassword" -t 1 --timeout=$TIMEOUT --proxy --execute=http_proxy=$HTTP_PROXY -O $PROXIED_FILE $SAMPLE_URL $LOG
User avatar
hsmith
Agent Smith
Posts: 3539
Joined: Thu Jul 30, 2015 11:09 am
Location: 127.0.0.1
Contact:

Re: Check_http over a proxy

Post by hsmith »

Thanks @amprantino!


@mleo40, does this help you out at all?
Former Nagios Employee.
me.
amprantino
Posts: 140
Joined: Thu Apr 18, 2013 8:25 am
Location: libexec

Re: Check_http over a proxy

Post by amprantino »

To force traffic pass through a proxy add the following

export http_proxy=http://192.168.0.1:3128

Modify the above if you want to add username or password to access proxy.
Locked