check_nrpe is showing incorrect output

This support forum board is for support questions relating to Nagios XI, our flagship commercial network monitoring solution.
Amit_Alone
Posts: 89
Joined: Fri May 08, 2020 11:47 am

Re: check_nrpe is showing incorrect output

Post by Amit_Alone »

Hi,

XXX.XXX.XXX.0/26 this allowed IP range is a NagiosXI IP.

Thanks.
gsmith
Posts: 1253
Joined: Tue Mar 02, 2021 11:15 am

Re: check_nrpe is showing incorrect output

Post by gsmith »

Hi,


When you express it as XXX.XXX.XXX.0/26 CIDR notation it can be any one of
64 IP addresses

The NRPE agent needs to know the IP of the Nagios XI server. It can't accept a range of IPs,
it isn't built that way.

So please update the line:

Code: Select all

only_from       = 127.0.0.1 XXX.XXX.XXX.0/26
to use the IP4 (XXX.XXX.XXX.XXX) address of the Nagios XI server.

Thank you
Amit_Alone
Posts: 89
Joined: Fri May 08, 2020 11:47 am

Re: check_nrpe is showing incorrect output

Post by Amit_Alone »

Hi Smith,

As suggested, I have updated the /etc/xinetd.d/nrpe file but still no luck. It's still displaying incorrect output.

Below data from Linux Oracle server.

Code: Select all

[root@agasporap1855 ~]# vi /etc/xinetd.d/nrpe
[root@agasporap1855 ~]# systemctl restart xinetd.service
[root@agasporap1855 ~]# cat /etc/xinetd.d/nrpe
# default: off
# description: NRPE (Nagios Remote Plugin Executor)
service nrpe
{
    disable         = no
    per_source      = 25
    socket_type     = stream
    port            = 5666
    wait            = no
    user            = nagios
    group           = nagios
    server          = /usr/local/nagios/bin/nrpe
    server_args     = -c /usr/local/nagios/etc/nrpe.cfg --inetd
    only_from       = 127.0.0.1 XX.XXX.XXX.26
    log_on_success  =
}
[root@agasporap1855 ~]#
Below is from NagiosXI server

Code: Select all

bash-4.2$ /usr/local/nagios/libexec/check_nrpe -H XX.XX.XX.55 -t 30 -c DBconnection_status
CRITICAL - Oracle DB Connection Failed
bash-4.2$
Thanks.
gsmith
Posts: 1253
Joined: Tue Mar 02, 2021 11:15 am

Re: check_nrpe is showing incorrect output

Post by gsmith »

Hi

1. What happens when you do this on the Linux Oracle server:

Code: Select all

sudo su - nagios
/usr/local/nagios/libexec/check_dbconnection.sh
2. Could you send me the check_dbconnection.sh please?

Thanks
Amit_Alone
Posts: 89
Joined: Fri May 08, 2020 11:47 am

Re: check_nrpe is showing incorrect output

Post by Amit_Alone »

Hi Smith,

As suggested, I run the cmd under nagios user on Linux Oracle server and observed the incorrect o/p.

Code: Select all

[root@agasporap1855 ~]# /usr/local/nagios/libexec/check_dbconnection.sh
OK - Oracle DB connected Successfully
[root@agasporap1855 ~]# sudo su - nagios
Last login: Mon Aug  9 12:04:13 EDT 2021 on pts/0
[nagios@agasporap1855 ~]$ /usr/local/nagios/libexec/check_dbconnection.sh
CRITICAL - Oracle DB Connection Failed
[nagios@agasporap1855 ~]$
I had PM the check_dbconnection.sh to you.
Amit_Alone
Posts: 89
Joined: Fri May 08, 2020 11:47 am

Re: check_nrpe is showing incorrect output

Post by Amit_Alone »

Now getting correct o/p after running the script as a nagios user on Linux Oracel server

Code: Select all

[nagios@agasporap1855 ~]$ /usr/local/nagios/libexec/check_dbconnection.sh
OK - Oracle DB connected Successfully
[nagios@agasporap1855 ~]$
However, still I'm observing the issue while running the command through check_nrpe from NagiosXI server.

Code: Select all

bash-4.2$ /usr/local/nagios/libexec/check_nrpe -H XX.XX.XX.55 -t 30 -c DBconnection_status
CRITICAL - Oracle DB Connection Failed
bash-4.2$
gsmith
Posts: 1253
Joined: Tue Mar 02, 2021 11:15 am

Re: check_nrpe is showing incorrect output

Post by gsmith »

Hi

Could you temporarily update your script as follows:

DBstatus=`echo "exit;" | sqlplus user/password@(connect string)" 2>&1 | tee /tmp/dbout.log| grep "Connected to:" | wc -l`

Then run the command through check_nrpe on the Nagios server.

Then take a look at and post /tmp/dbout.log

Thanks
Amit_Alone
Posts: 89
Joined: Fri May 08, 2020 11:47 am

Re: check_nrpe is showing incorrect output

Post by Amit_Alone »

Hi Smith,

As suggested, I have updated the script by adding the tee command and ran the script from NagiosXI server.

Below is the o/p of dbout.log file

Code: Select all

[root@agasporap1855 tmp]# cat dbout.log
/usr/local/nagios/libexec/check_dbconnection.sh: line 6: sqlplus: command not found
Below is from NagiosXI server

Code: Select all

bash-4.2$ /usr/local/nagios/libexec/check_nrpe -H 10.110.3.55 -t 30 -c DBconnection_status
CRITICAL - Oracle DB Connection Failed
Thanks.
gsmith
Posts: 1253
Joined: Tue Mar 02, 2021 11:15 am

Re: check_nrpe is showing incorrect output

Post by gsmith »

Hi

In your script please include the full path to sqlplus:

DBstatus=`echo "exit;" | sqlplus user/password@(connect string)" 2>&1 | tee /tmp/dbout.log| grep "Connected to:" | wc -l`

Let me know how that works please. If it gives you an error please post the contents of /tmp/dbout.log

Thanks
Amit_Alone
Posts: 89
Joined: Fri May 08, 2020 11:47 am

Re: check_nrpe is showing incorrect output

Post by Amit_Alone »

Hi Smith,

Not sure which oracle full path you're referring to add me. However, on the Linux Oracle server under the nagios profile I already mention Oracle Home path.

Code: Select all

[nagios@agasporap1855 ~]$ cat ~/.bash_profile
# .bash_profile

# Get the aliases and functions
if [ -f ~/.bashrc ]; then
        . ~/.bashrc
fi

# User specific environment and startup programs

#PATH=$PATH:$HOME/.local/bin:$HOME/bin

PATH=$PATH:$HOME/.local/bin:$HOME/bin:/u01/app/grid/19.3.0/gridhome_1/bin/

export PATH

export ORACLE_HOME=/u01/app/oracle/product/19.3.0/dbhome_1


[nagios@agasporap1855 ~]$
Locked