azureamazon-ec2nagiosnrpe

NRPE Socket timeout via NRPE, works as nrpe user


nrpe on azure server - nrpe-srvr, user nrpe, executing script /usr/local/naemon/libexec/check_curl_http.php I'll call it script

Desired output after ./script -U www.google.com:

Page OK: HTTP Status Code 200 - 11099 bytest in 0.** seconds | time=0.059 size=11099

I achieve the above output by running the script from root or nrpe

Running sudo -u nrpe ./script -U www.google.com returns:

Error in opening page! Err:Failed to connect to [ipv6 addr] Network is unreachable

However running su - nrpe -c './script -U www.google.com' works with the desired result.

Naemon reports:

CHECK_NRPE: Socket timeout after 30 secs

Other NRPE checks to the same host are working, so I think it's something to do with user execution of this specific script. I did have a deny from SELinux, but adjusted the context. Removing the context and setting SELinux to permissive yielded the same error. Enabled NRPE Log files, with debugging, but other than Running command it doesn't really reveal much. There is a:

WARNING: my_system() seteuid(0): Operation not permitted

in the logs, but looking at the support documentation that is "Normal" behavior.


Solution

  • I'll post this just in case someone else has this issue, and I'll tag Azure / AWS.

    Essentially, cloud providers (mostly) have an internal proxy that is stored in an environment variable http_proxy && https_proxy. NRPE by default doesn't use load environment variables. Now I don't know if there is an option for it (it's mentioned in the docs that there is a bug when using uid instead of username (was using username)) however it's simple enough to call proxy for checks like this.