Problems with NRPE

Started by kgcrgi, October 30, 2024, 11:05:04 AM

Previous topic - Next topic
Hi, I have a problem using a custom script via NRPE. The scripts installed with the plugin work. Here is the config:
log_facility=daemon
log_file=/var/log/nrpe.log
debug=0
pid_file=/var/run/nrpe/nrpe.pid
nrpe_user=nagios
nrpe_group=nagios

server_port=5666
server_address=<opn server>
allowed_hosts=<nagios ip>,127.0.0.1
command_timeout=60
connection_timeout=300
dont_blame_nrpe=0
allow_bash_command_substitution=0
include=/usr/local/etc/nrpe_commands.cfg


nrpe_commands:
command[bgp_state]=/usr/local/libexec/nagios/check_bgp_state2.py
command[check_users]=/usr/local/libexec/nagios/check_users -w 5 -c 10
command[test_vtysh]=/usr/local/bin/vtysh -c "show ip bgp summary


/etc/nagios4/conf.d# /usr/lib/nagios/plugins/check_nrpe -H <opn server> -p 5666 -c bfd_state
NRPE: Unable to read output


/usr/lib/nagios/plugins/check_nrpe -H <opn server> -p 5666 -c check_users
USERS OK - 0 users currently logged in |users=0;5;10;0


I tried various scripts, both python and bash, complex and simple, each of them had exit codes adapted for nagios.
I tried adding sudo to the command, or the full path to sudo.
I added an entry in sudoers to the path where all the scripts are.
nagios ALL=(ALL) NOPASSWD: /usr/local/libexec/nagios/*
The script has permissions like those that work.
In the scripts I checked the output character limit. Is it in utf-8 format?
Locally, when I use the nagios user, the script works.
Where could the error be?
I also ran debug, but it didn't show anything of value.


Did you manage to fix this? In the lastest version of OPNSense I am having the same issue with one plugin (check_procs) it executes fine locally, but when I try and run it over NRPE from my Nagios server, I get unable to read output.
Thanks

In the OP no command named "bfd_state" is defined in the configuration. That's why "check_users" works but "bfd_state" doesn't.
Deciso DEC750
People who think they know everything are a great annoyance to those of us who do. (Isaac Asimov)

Same problem with check_procs here (other commands work) and sudo did not help. I suspect a relation to "unbound: safe command execution changes" (from the release notes of 25.7.8)?!

AFAIK NRPE does log locally. So trigger an execution from the Nagios server, then check the NRPE log files on OPNsense.
Deciso DEC750
People who think they know everything are a great annoyance to those of us who do. (Isaac Asimov)

Quote from: iYx3Zp8Q08hrNVZCHTYt on Today at 05:11:16 PMSame problem with check_procs here (other commands work) and sudo did not help. I suspect a relation to "unbound: safe command execution changes" (from the release notes of 25.7.8)?!

Highly unlikely.

I have the ticket here as requested on reddit from michaelsage. Will look into it tomorrow.

https://github.com/opnsense/plugins/issues/5059