NagiosEnterprises/nrpe

NRPE not showing real output of check_apt

basd82 opened this issue · 6 comments

When i run the check_apt plug localy on a ubuntu 22.04 server i get:
/usr/lib/nagios/plugins/check_apt
APT OK: 0 packages available for upgrade (0 critical updates). |available_upgrades=0;;;0 critical_updates=0;;;0
when i run the the command with nrpe
/usr/local/nagios/libexec/check_nrpe -H 172.31.1.250 -c check_apt
APT WARNING: 2 packages available for upgrade (0 critical updates). |available_upgrades=2;;;0 critical_updates=0;;;0

it look liks nrpe does some caching ???

It works great on 20.04 but on 22.04 i have this.
After 1 or 2 days it reports correctly

version info
Server: nrpe Version: 4.0.3
client Version: 4.0.3

Hi @basd82, thanks for reaching out.

I don't think NRPE does any caching of check results. If you're skeptical, you can look over the source code yourself. It's a fairly small program.

The most likely cause for this issue is that you're running the plugin on two different machines and don't realize it - there are a few different situations where multiple machines (especially VMs) can think that they have the same IP address. If you haven't already, try using SSH from the check_nrpe machine into 172.31.1.250 and manually run check_apt from that terminal. If that still gets a different result from check_nrpe, troubleshooting gets a lot harder - maybe check the command configuration in nrpe.cfg? After that I'd probably be using gdb to attach to the running nrpe daemon, but that's pretty involved.

I have exactly the same issue:

$# /usr/lib/nagios/plugins/check_apt
 APT OK: 0 packages available for upgrade (0 critical updates). |available_upgrades=0;;;0 critical_updates=0;;;0

$# /usr/lib/nagios/plugins/check_nrpe -H 127.0.0.1 -c check_apt 
APT WARNING: 9 packages available for upgrade (0 critical updates). |available_upgrades=9;;;0 critical_updates=0;;;0

Here is the NRPE log:

[1656085752] CONN_CHECK_PEER: checking if host is allowed: XX port XX
[1656085752] Connection from XX port XX
[1656085752] is_an_allowed_host (AF_INET): is host >XX< an allowed host >XX<
[1656085752] is_an_allowed_host (AF_INET): host is in allowed host list!
[1656085752] Host address is in allowed_hosts
[1656085752] Host XXis asking for command 'check_apt' to be run...
[1656085752] Running command: /usr/lib/nagios/plugins/check_apt -t 60
[1656085752] WARNING: my_system() seteuid(0): Operation not permitted
[1656085753] Command completed with return code 1 and output: APT WARNING: 7 packages available for upgrade (0 critical updates). |available_upgrades=7;;;0 critical_updates=0;;;0
[1656085753] Return Code: 1, Output: APT WARNING: 7 packages available for upgrade (0 critical updates). |available_upgrades=7;;;0 critical_updates=0;;;0
[1656085753] Connection from XXclosed.

Issue is also with other check command's

for example simple script that checks if a reboot is needed:

#!/bin/bash

if [ -f /var/run/reboot-required ]; then
        echo "WARNING, Reboot is nodig"
        exit 1
else
        echo "OK, geen reboot nodig"
        exit 0
fi

Strange sting is thats only with ubuntu 22.04 servers at my end
But for this script a reboot of nagios server solves the issue, but for apt it doesn't

Hi !

Did you find a workaround for this problem ?