Version used (icinga2 --version)
Compiler: GNU 11.2.1
Build host: runner-hh8q3bz2-project-575-concurrent-0
OpenSSL version: OpenSSL 1.0.2k-fips 26 Jan 2017
I’m trying to run a script that is located on each of my remote nodes, capture the output, and use the output of either 0 or 1 to determine whether or not an alarm should be sent. I’ve been looking at the Monitoring documentation and I just can’t figure out what is necessary. I’ve Googled this question a dozen times and either my search terms are wrong or “execute remote script Icinga” has never been asked before.
The NRPE agent is installed. I just want my icinga node to be able to call the nrpe agent on server X, have the agent run a script, capture the output, and return the value to Icinga. Is that possible?
Please take yourself some time to work through at least the first five chapters of the Icinga 2 documentation, as those will likely address follow up questions.
Btw, RHEL 7 is end of life and there will be no further official Icinga releases for it.
Of course you can still execute checks against an NRPE agent with Icinga2, though the Icinga2 agent would be preferred on Windows agents. On linux I would opt for check_by_ssh with publickey auth.
You will need your script to return and exit code of 0 (OK), 1 (WARN), 2 (CRIT) or 3 (UNKNOWN) and some form of string output (see “monitoring plugin guidelines” for a more detailed explanation.)
Configure a service template to use the check command nrpe, supply the necessary parameters and apply the service template to the target host(s) to create the service.
When running my command locally, it returns 0. But when running it with nrpe, its returning ‘126$’.
Here’s the command: AVALUE=/opt/illumio_ven/illumio-ven-ctl connectivity-test; echo $?; echo $AVALUE
I have to run the echo because the command itself doesn’t return a value. Just: /opt/illumio_ven/illumio-ven-ctl connectivity-test
will not print a value.
Any ideas? I’m assigning the value to AVALUE just to hold the result incase the nrpe command is overriding it.
Why not write a small script that executes the command, get’s the output and then handles it accordingly to what you expect?
And then run that script via nrpe.
If your command is behaving differently when called locally or via nrpe, I assume it is caused by running it with different users. Check what user is owning the nrpe process and run the command with that user locally again.