NagiosEnterprises / nrpe

NRPE Agent
GNU General Public License v2.0
257 stars 133 forks source link

NRPE not showing real output of check_apt #261

Open basd82 opened 2 years ago

basd82 commented 2 years ago

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

sawolf commented 2 years ago

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.

kevinwincott commented 2 years ago

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
kevinwincott commented 2 years ago

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.
basd82 commented 2 years ago

Good to know i'm not The only one

Outlook voor Androidhttps://aka.ms/AAb9ysg downloaden


From: Kevin Wincott @.> Sent: Friday, June 24, 2022 5:59:26 PM To: NagiosEnterprises/nrpe @.> Cc: Bas van den Dikkenberg @.>; Mention @.> Subject: Re: [NagiosEnterprises/nrpe] NRPE not showing real output of check_apt (Issue #261)

Here is the NRPE log:

[1656085752] CONN_CHECK_PEER: checking if host is allowed: 178.79.156.121 port 3275 [1656085752] Connection from 178.79.156.121 port 3275 [1656085752] is_an_allowed_host (AF_INET): is host >178.79.156.121< an allowed host >178.79.156.121< [1656085752] is_an_allowed_host (AF_INET): host is in allowed host list! [1656085752] Host address is in allowed_hosts [1656085752] Host 178.79.156.121 is 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 178.79.156.121 closed.

— Reply to this email directly, view it on GitHubhttps://github.com/NagiosEnterprises/nrpe/issues/261#issuecomment-1165712047, or unsubscribehttps://github.com/notifications/unsubscribe-auth/AAJJY6OSVQ5XIPCJNDLOBMLVQXLN5ANCNFSM5W34KZCA. You are receiving this because you were mentioned.Message ID: @.***>

basd82 commented 2 years ago

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

yabrab commented 1 year ago

Hi !

Did you find a workaround for this problem ?