Monitoring Linux Servers behind squid proxy via Nagioscore

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
muhib.malik
Posts: 1
Joined: Fri Oct 01, 2021 12:14 pm

Monitoring Linux Servers behind squid proxy via Nagioscore

Post by muhib.malik »

Hi All,
This is my first post here, please help me.
I want to monitor a few redhat servers which are behind squid proxy server. I have done the below configuration:

RedHat Node behind proxy server configuration:-
I have installed nrpe and also copied check_disk, check_cpu and check_mem plugins under /usr/lib64/nagios/plugins.
I also added the below lines in /etc/nagios/nrpe.cfg file.

allowed_hosts=127.0.0.1,Squid_Proxy_server_IP
command[check_disk]=/usr/lib64/nagios/plugins/check_disk -w $ARG1$ -c $ARG2$ -p $ARG3$
command[check_cpu]=/usr/lib64/nagios/plugins/check_cpu -w $ARG1$ -c $ARG2$
command[check_mem]=/usr/lib64/nagios/plugins/check_mem -w $ARG1$ -c $ARG2$ -W $ARG3$ -C $ARG4$

Squid Proxy Server Configuration:-
I have also installed nrpe in squid proxy server and copied check_disk, check_cpu, check_mem, check_nrpe and check_ping plugins under /usr/lib64/nagios/plugins. I also added the below lines in /etc/nagios/nrpe.cfg file.

allowed_hosts=127.0.0.1,Nagios_server_IP
command[check_disk]=/usr/lib64/nagios/plugins/check_disk -w $ARG1$ -c $ARG2$ -p $ARG3$
command[check_cpu]=/usr/lib64/nagios/plugins/check_cpu -w $ARG1$ -c $ARG2$
command[check_mem]=/usr/lib64/nagios/plugins/check_mem -w $ARG1$ -c $ARG2$ -W $ARG3$ -C $ARG4$
command[check_proxy]=/usr/lib64/nagios/plugins/check_nrpe -t 60 -H $ARG1$ -c $ARG2$ -a $ARG3$ $ARG4$
command[check_ping]=/usr/lib64/nagios/plugins/check_ping -H $ARG1$ -w 3000.0,80% -c 5000.0,100% -p 5

If I run the below command from squid proxy server to RedHat server, I can get a correct output.
/usr/local/nagios/libexec/check_nrpe -H RedHat_IP -c check_disk -a 20% 10% /app
Also If I run the below command from nagios server to squid proxy server, I can get a correct output.
/usr/local/nagios/libexec/check_nrpe -H Proxy_server_IP -c check_disk -a 20% 10% /app
But if I run the below command to check the RedHat server status directly from nagios server via Proxy server I get "Error: Unable to read the output".
./check_nrpe -H Proxy_node_IP -c check_proxy -a RedHat_IP check_disk "20% 10% /app"

Please help as it has become quite critical for our environment.
gormank
Posts: 1114
Joined: Tue Dec 02, 2014 12:00 pm

Re: Monitoring Linux Servers behind squid proxy via Nagiosco

Post by gormank »

I don't have anything behind a proxy so I'm just guessing...

I think I'd set the allowed_hosts with the nagios server, not the proxy.
If all your monitored hosts are behind the proxy you can set a global proxy like this on the nagios server:
echo "http_proxy=http://proxy.example.com:3128/" > /etc/environment
If only some hosts are behind the proxy, you might be able to use no_proxy in /etc/environment to not proxy noproxy.domain.com:
no_proxy="localhost, noproxy.domain.com"
Locked