OPNsense Forum

English Forums => General Discussion => Topic started by: kgcrgi on October 30, 2024, 11:05:04 AM

Title: Problems with NRPE
Post by: kgcrgi on October 30, 2024, 11:05:04 AM
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.
Title: Re: Problems with NRPE
Post by: kgcrgi on November 12, 2024, 04:47:07 PM
up
Title: Re: Problems with NRPE
Post by: michaelsage on December 01, 2025, 03:52:28 PM
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
Title: Re: Problems with NRPE
Post by: Patrick M. Hausen on December 01, 2025, 03:56:44 PM
In the OP no command named "bfd_state" is defined in the configuration. That's why "check_users" works but "bfd_state" doesn't.
Title: Re: Problems with NRPE
Post by: iYx3Zp8Q08hrNVZCHTYt on December 02, 2025, 05:11:16 PM
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)?!
Title: Re: Problems with NRPE
Post by: Patrick M. Hausen on December 02, 2025, 06:25:03 PM
AFAIK NRPE does log locally. So trigger an execution from the Nagios server, then check the NRPE log files on OPNsense.
Title: Re: Problems with NRPE
Post by: franco on December 02, 2025, 10:18:07 PM
Quote from: iYx3Zp8Q08hrNVZCHTYt on December 02, 2025, 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