UDP port for monitor

This support forum board is for support questions relating to Nagios XI, our flagship commercial network monitoring solution.
Vigneshwar.A
Posts: 25
Joined: Fri May 12, 2017 2:02 am

Re: UDP port for monitor

Post by Vigneshwar.A »

lmiltchev wrote:Have you applied configuration after making the changes to your configs, e.g. adding sudo to the "check_udp_port" command? Try going to the CCM > Tools > Config File Management > Delete Files > Write Configs > Verify Files > Apply Configuration (in this exact order).

Another reason for the issue could be multiple nagios processes running on this machine. Perhaps, there is an old nagios process running that is "stuck" and it's still reporting "Critical".

To check for multiple instances of nagios, run:

Code: Select all

ps -ef | head -1 && ps -ef | grep bin/nagios
To kill the process run:

Code: Select all

service nagios stop
killall nagios
service nagios start
Still issue is same :|
User avatar
lmiltchev
Former Nagios Staff
Posts: 13587
Joined: Mon May 23, 2011 12:15 pm

Re: UDP port for monitor

Post by lmiltchev »

Run the following commands from the command line and show the output:

Code: Select all

ps -ef | head -1 && ps -ef | grep bin/nagios
/usr/local/nagiosxi/scripts/reconfigure_nagios.sh
Next, go to Home > Details > Service Status > UPD Port 1162, click on Force an immediate check link under the Quick Actions section, and show a screenshot of the page.
Be sure to check out our Knowledgebase for helpful articles and solutions!
Vigneshwar.A
Posts: 25
Joined: Fri May 12, 2017 2:02 am

Re: UDP port for monitor

Post by Vigneshwar.A »

lmiltchev wrote:Run the following commands from the command line and show the output:

Code: Select all

ps -ef | head -1 && ps -ef | grep bin/nagios
/usr/local/nagiosxi/scripts/reconfigure_nagios.sh
Next, go to Home > Details > Service Status > UPD Port 1162, click on Force an immediate check link under the Quick Actions section, and show a screenshot of the page.
PFB the below following commands output

[root@xxxxxxxx ~]# ps -ef | head -1 && ps -ef | grep bin/nagios
UID PID PPID C STIME TTY TIME CMD
nagios 20215 1 1 00:00 ? 00:12:04 /usr/local/nagios/bin/nagios -d /usr/local/nagios/etc/nagios.cfg
nagios 20216 20215 0 00:00 ? 00:00:15 /usr/local/nagios/bin/nagios --worker /usr/local/nagios/var/rw/nagios.qh
nagios 20218 20215 0 00:00 ? 00:00:15 /usr/local/nagios/bin/nagios --worker /usr/local/nagios/var/rw/nagios.qh
nagios 20219 20215 0 00:00 ? 00:00:15 /usr/local/nagios/bin/nagios --worker /usr/local/nagios/var/rw/nagios.qh
nagios 20220 20215 0 00:00 ? 00:00:15 /usr/local/nagios/bin/nagios --worker /usr/local/nagios/var/rw/nagios.qh
nagios 20221 20215 0 00:00 ? 00:00:15 /usr/local/nagios/bin/nagios --worker /usr/local/nagios/var/rw/nagios.qh
nagios 20222 20215 0 00:00 ? 00:00:15 /usr/local/nagios/bin/nagios --worker /usr/local/nagios/var/rw/nagios.qh
nagios 20223 20215 0 00:00 ? 00:00:15 /usr/local/nagios/bin/nagios --worker /usr/local/nagios/var/rw/nagios.qh
nagios 20225 20215 0 00:00 ? 00:00:15 /usr/local/nagios/bin/nagios --worker /usr/local/nagios/var/rw/nagios.qh
nagios 20226 20215 0 00:00 ? 00:00:15 /usr/local/nagios/bin/nagios --worker /usr/local/nagios/var/rw/nagios.qh
nagios 20227 20215 0 00:00 ? 00:00:15 /usr/local/nagios/bin/nagios --worker /usr/local/nagios/var/rw/nagios.qh
nagios 20228 20215 0 00:00 ? 00:00:15 /usr/local/nagios/bin/nagios --worker /usr/local/nagios/var/rw/nagios.qh
nagios 20229 20215 0 00:00 ? 00:00:15 /usr/local/nagios/bin/nagios --worker /usr/local/nagios/var/rw/nagios.qh
nagios 20230 20215 0 00:00 ? 00:00:15 /usr/local/nagios/bin/nagios --worker /usr/local/nagios/var/rw/nagios.qh
nagios 20231 20215 0 00:00 ? 00:00:15 /usr/local/nagios/bin/nagios --worker /usr/local/nagios/var/rw/nagios.qh
nagios 20232 20215 0 00:00 ? 00:00:15 /usr/local/nagios/bin/nagios --worker /usr/local/nagios/var/rw/nagios.qh
nagios 20233 20215 0 00:00 ? 00:00:15 /usr/local/nagios/bin/nagios --worker /usr/local/nagios/var/rw/nagios.qh
nagios 20234 20215 0 00:00 ? 00:00:15 /usr/local/nagios/bin/nagios --worker /usr/local/nagios/var/rw/nagios.qh
nagios 20235 20215 0 00:00 ? 00:00:15 /usr/local/nagios/bin/nagios --worker /usr/local/nagios/var/rw/nagios.qh
nagios 20253 20215 0 00:00 ? 00:00:01 /usr/local/nagios/bin/nagios -d /usr/local/nagios/etc/nagios.cfg
root 30451 29824 0 10:23 pts/0 00:00:00 grep --color=auto bin/nagios
[root@xxxxxxxxx ~]# /usr/local/nagiosxi/scripts/reconfigure_nagios.sh

--- reset_config_perms.sh ------------
> Setting CCM script permissions
> Setting script permissions
> Setting special component script permissions
> Setting configuration file/directory permissions
> Setting perfdata directory and RRD permissions
> Setting NOM checkpoint user:group permissions
> + Setting Nagios Core corelog.newobjects user:group permissions
> + Setting CCM configuration file user:group permissions
> + Setting Recurring Downtime file user:group permissions
> + Setting BPI configuration file user:group permissions
--------------------------------------

--- ccm_import.php -------------------
> Setting import directory: /usr/local/nagios/etc/import/
> Importing config files into the CCM
No files to import
--------------------------------------

--- ccm_export.php -------------------
> Writing CCM configuration to Nagios files
Finished writing out configuraton
--------------------------------------

--------------------------------------
> Verifying configuration with Nagios Core
> Output:
Nagios Core 4.4.2
Copyright (c) 2009-present Nagios Core Development Team and Community Contributors
Copyright (c) 1999-2009 Ethan Galstad
Last Modified: 2018-08-16
License: GPL

Website: https://www.nagios.org
Reading configuration data...
Read main config file okay...
Read object config files okay...

Running pre-flight check on configuration data...

Checking objects...
Checked 10767 services.
Checked 370 hosts.
Checked 11 host groups.
Checked 0 service groups.
Checked 55 contacts.
Checked 2 contact groups.
Checked 188 commands.
Checked 74 time periods.
Checked 0 host escalations.
Checked 0 service escalations.
Checking for circular paths...
Checked 370 hosts
Checked 0 service dependencies
Checked 0 host dependencies
Checked 74 timeperiods
Checking global event handlers...
Checking obsessive compulsive processor commands...
Checking misc settings...

Total Warnings: 0
Total Errors: 0

Things look okay - No serious problems were detected during the pre-flight check
> Return Code: 0
--------------------------------------
[root@xxxxxxxx ~]#
You do not have the required permissions to view the files attached to this post.
User avatar
lmiltchev
Former Nagios Staff
Posts: 13587
Joined: Mon May 23, 2011 12:15 pm

Re: UDP port for monitor

Post by lmiltchev »

Open the "check_udp_port" plugin in a text editor and add three "echo" lines for debugging purposes, showing the value of the "result", "f_result", and "p_result" variable.

Example:

Code: Select all

result=`/usr/bin/nmap -sU -p $port -P0 $host`
echo "result: $result"
f_result=`echo $result | egrep -o "${port}/udp [a-zA-Z0-9_-\| ]+Nmap done"`
echo "f_result: $f_result"
p_result=`echo $f_result | awk '{print $1" "$2" "$3}'`
echo "p_result: $p_result"
Save, and exit.

Run the plugin as nagios user, and show the output:

Code: Select all

su - nagios
sudo /usr/local/nagios/libexec/check_udp_port -H XXXXXX -p 1162 -s "health-trap"
Also, PM me your profile (Admin > System Config > System Profile > Download Profile)
Be sure to check out our Knowledgebase for helpful articles and solutions!
User avatar
lmiltchev
Former Nagios Staff
Posts: 13587
Joined: Mon May 23, 2011 12:15 pm

Re: UDP port for monitor

Post by lmiltchev »

Let's try sending the error to the standard output in the GUI. Temporarily change your command from this:

Code: Select all

define command {
    command_name    check_udp_port
    command_line    sudo $USER1$/check_udp_port -H $HOSTADDRESS$ -p $ARG1$ -s $ARG2$
}
to this:

Code: Select all

define command {
    command_name    check_udp_port
    command_line    sudo $USER1$/check_udp_port -H $HOSTADDRESS$ -p $ARG1$ -s $ARG2$ 2>&1
}
Save, apply configuration, then go to your service (under the Service Status Detail), force an immediate check, and show us a screenshot of the output.
Be sure to check out our Knowledgebase for helpful articles and solutions!
Vigneshwar.A
Posts: 25
Joined: Fri May 12, 2017 2:02 am

Re: UDP port for monitor

Post by Vigneshwar.A »

lmiltchev wrote:Let's try sending the error to the standard output in the GUI. Temporarily change your command from this:

Code: Select all

define command {
    command_name    check_udp_port
    command_line    sudo $USER1$/check_udp_port -H $HOSTADDRESS$ -p $ARG1$ -s $ARG2$
}
to this:

Code: Select all

define command {
    command_name    check_udp_port
    command_line    sudo $USER1$/check_udp_port -H $HOSTADDRESS$ -p $ARG1$ -s $ARG2$ 2>&1
}
Save, apply configuration, then go to your service (under the Service Status Detail), force an immediate check, and show us a screenshot of the output.
as mentioned above i changed my command now, still issue is same ;)
PFA SS
You do not have the required permissions to view the files attached to this post.
User avatar
lmiltchev
Former Nagios Staff
Posts: 13587
Joined: Mon May 23, 2011 12:15 pm

Re: UDP port for monitor

Post by lmiltchev »

We believe that the check fails, because of the "pipe" in the output:
1162/udp open|filtered health-trap
Try modifying the plugin one more time by replacing this:

Code: Select all

result=`/usr/bin/nmap -sU -p $port -P0 $host`
with this:

Code: Select all

result=`/usr/bin/nmap -sU -p $port -P0 $host | sed 's/|/ /g'`
to see if this is going to fix your issue. If it works for you, you could remove the "echo" lines, that were added to the plugin for debugging purposes, and change your command back to:

Code: Select all

sudo $USER1$/check_udp_port -H $HOSTADDRESS$ -p $ARG1$ -s $ARG2$
Be sure to check out our Knowledgebase for helpful articles and solutions!
Vigneshwar.A
Posts: 25
Joined: Fri May 12, 2017 2:02 am

Re: UDP port for monitor

Post by Vigneshwar.A »

lmiltchev wrote:We believe that the check fails, because of the "pipe" in the output:
1162/udp open|filtered health-trap
Try modifying the plugin one more time by replacing this:

Code: Select all

result=`/usr/bin/nmap -sU -p $port -P0 $host`
with this:

Code: Select all

result=`/usr/bin/nmap -sU -p $port -P0 $host | sed 's/|/ /g'`
to see if this is going to fix your issue. If it works for you, you could remove the "echo" lines, that were added to the plugin for debugging purposes, and change your command back to:

Code: Select all

sudo $USER1$/check_udp_port -H $HOSTADDRESS$ -p $ARG1$ -s $ARG2$
Hi lmiltchev,

Sorry for the delay, i modified the plugin/command as of you mentioned and still issue persist :|. PFB info

[root@xxxxxxxx libexec]# ./check_udp_port -H xxxxxxxx -p 1162 -s "health-trap"
WARNING: Incorrect service filtered listening on port 1162: 1162/udp open filtered

[nagios@xxxxxx ~]$ sudo /usr/local/nagios/libexec/check_udp_port -H xxxxxx -p 1162 -s "health-trap"
WARNING: Incorrect service filtered listening on port 1162: 1162/udp open filtered
You do not have the required permissions to view the files attached to this post.
User avatar
lmiltchev
Former Nagios Staff
Posts: 13587
Joined: Mon May 23, 2011 12:15 pm

Re: UDP port for monitor

Post by lmiltchev »

Put back all of the "echo" lines in the plugin (as before) for debugging purposes. Also, change back your command to:

Code: Select all

    define command {
        command_name    check_udp_port
        command_line    sudo $USER1$/check_udp_port -H $HOSTADDRESS$ -p $ARG1$ -s $ARG2$ 2>&1
    }
Upload the modified plugin on the forum, so that we can verify the changes.

Run the check from the command line, and show the output. Also, force an immediate check in the GUI, and show a screenshot of the "Service Status Detail" page.

You could also try escaping the pipe in the line below:

Code: Select all

result=`/usr/bin/nmap -sU -p $port -P0 $host | sed 's/|/ /g'`
as such:

Code: Select all

result=`/usr/bin/nmap -sU -p $port -P0 $host | sed 's/\|/ /g'`
to see if this is going to make a difference.
Be sure to check out our Knowledgebase for helpful articles and solutions!
Vigneshwar.A
Posts: 25
Joined: Fri May 12, 2017 2:02 am

Re: UDP port for monitor

Post by Vigneshwar.A »

lmiltchev wrote:Put back all of the "echo" lines in the plugin (as before) for debugging purposes. Also, change back your command to:

Code: Select all

    define command {
        command_name    check_udp_port
        command_line    sudo $USER1$/check_udp_port -H $HOSTADDRESS$ -p $ARG1$ -s $ARG2$ 2>&1
    }
Upload the modified plugin on the forum, so that we can verify the changes.

Run the check from the command line, and show the output. Also, force an immediate check in the GUI, and show a screenshot of the "Service Status Detail" page.

You could also try escaping the pipe in the line below:

Code: Select all

result=`/usr/bin/nmap -sU -p $port -P0 $host | sed 's/|/ /g'`
as such:

Code: Select all

result=`/usr/bin/nmap -sU -p $port -P0 $host | sed 's/\|/ /g'`
to see if this is going to make a difference.
Hi Lmiltchev,

PFB Output and SS as of you requested.

define command {
command_name check_udp_port
command_line sudo $USER1$/check_udp_port -H $HOSTADDRESS$ -p $ARG1$ -s $ARG2$ 2>&1
}
-------------
[root@xxxxxxx libexec]# ./check_udp_port -H xxxxxxxxxx -p 1162 -s "health-trap" 2>&1
result:
S t a r t i n g N m a p 6 . 4 7 ( h t t p : / / n m a p . o r g ) a t 2 0 1 8 - 1 0 - 0 5 1 9 : 0 8 B S T
N m a p s c a n r e p o r t f o r xxxxxxxxxxxxxxxxxx
H o s t i s u p ( 0 . 0 0 0 1 4 s l a t e n c y ) .
P O R T S T A T E S E R V I C E
1 1 6 2 / u d p o p e n | f i l t e r e d h e a l t h - t r a p
M A C A d d r e s s : 0 0 : 1 5 : 5 D : 6 E : 4 E : 2 7 ( M i c r o s o f t )

N m a p d o n e : 1 I P a d d r e s s ( 1 h o s t u p ) s c a n n e d i n 0 . 2 7 s e c o n d s
f_result:
p_result:
CRITICAL:
[root@xxxxxxxxx libexec]# su - nagios
Last login: Fri Oct 5 19:09:15 BST 2018
[nagios@xxxxxxxxx ~]$ sudo /usr/local/nagios/libexec/check_udp_port -H xxxxxxxxx -p 1162 -s "health-trap" 2>&1
result:
S t a r t i n g N m a p 6 . 4 7 ( h t t p : / / n m a p . o r g ) a t 2 0 1 8 - 1 0 - 0 5 1 9 : 0 9 B S T
N m a p s c a n r e p o r t f o r xxxxxxxxxxxxxxxxxxxxx
H o s t i s u p ( 0 . 0 0 0 3 6 s l a t e n c y ) .
P O R T S T A T E S E R V I C E
1 1 6 2 / u d p o p e n | f i l t e r e d h e a l t h - t r a p
M A C A d d r e s s : 0 0 : 1 5 : 5 D : 6 E : 4 E : 2 7 ( M i c r o s o f t )

N m a p d o n e : 1 I P a d d r e s s ( 1 h o s t u p ) s c a n n e d i n 0 . 2 7 s e c o n d s
f_result:
p_result:
CRITICAL:
[nagios@xxxxxxxxx ~]$
You do not have the required permissions to view the files attached to this post.
Locked