-1

Services are up and running on the remote nodes. CLI execution returns OK, but in UI it returning CRITICAL with Status Information:'Return code of 7 is out of bounds'

nagios-xxxxxxxx:~# /usr/lib/nagios/plugins/check_tcp -H hostname -p <port> -w 5 -c 10 -t 60

TCP OK - 0.002 second response time on hostname port XXXXXXX|time=0.001642s;5.000000;10.000000;0.000000;60.000000

Can someone help me in fixing it?

Nagios log:

[XXXXXXX] Warning: Return code of 7 for check of service 'XXXXXXX' on host was out of bounds. [XXXXXXX] Warning: Return code of 7 for check of service 'XXXXXXX' on host was out of bounds. [XXXXXXX] Warning: Return code of 7 for check of service 'XXXXXXX' on host was out of bounds. [XXXXXXX] Warning: Return code of 7 for check of service 'XXXXXXX' on host was out of bounds. [XXXXXXX] Warning: Return code of 7 for check of service 'XXXXXXX' on host was out of bounds.

munna
  • 103
  • 2
  • 9
  • Try this solution on official forum: https://support.nagios.com/forum/viewtopic.php?f=7&t=43810#p220778 – Rohlik Dec 04 '18 at 10:47
  • @Rohlik thanks for you comments. I tried with the options provided on the page, but i dont see any +ve results to clear the false alerts. I fixed these issues. Actually issues are with duplicated service configs on nagios server: location:: /etc/nagios4/objects/services/ Cleard the duplcate service configs from the location and reloaded nagios service. Issues cleared. – munna Dec 13 '18 at 10:01

3 Answers3

1

I fixed these issues.Actually issues are with duplicated service configs on nagios server: location:: /etc/nagios4/objects/services/

Cleard the duplcate service configs from the location and reloaded nagios service.

Issues cleared.

munna
  • 103
  • 2
  • 9
0

I reproduced this problem on my systems. I have 620 hosts, 7000 services. When the number of services exceed 6189, all plugins become unusable with "Return code of 7 out of bounds", even if there are just /bin/true command.

The main solution is to set in nagios.cfg:

enable_environment_macros=0

I did not want to do this for a long time, because I have one of plugins which uses nagios ENV variables during building HTML e-mail for notifications. But I found this solution for its running, you need to set manually necessary ENV for particular plugin in this way:

define command{
 command_name    notify-html-service
 command_line NAGIOS_NOTIFICATIONTYPE='$NOTIFICATIONTYPE$' NAGIOS_SERVICEATTEMPT='$SERVICEATTEMPT$' NAGIOS_SERVICESTATE='$SERVICESTATE$'  NAGIOS_CONTACTGROUPNAME='$CONTACTGROUPNAME$' NAGIOS_HOSTNAME='$HOSTNAME$' NAGIOS_SERVICEDESC='$SERVICEDESC$' NAGIOS_LONGSERVICEOUTPUT='$LONGSERVICEOUTPUT$' NAGIOS_HOSTADDRESS='$HOSTADDRESS$' NAGIOS_HOSTGROUPNAMES='$HOSTGROUPNAMES$' NAGIOS_HOSTALIAS='$HOSTALIAS$' NAGIOS_SERVICEOUTPUT='$SERVICEOUTPUT$' NAGIOS_LONGDATETIME='$LONGDATETIME$' NAGIOS_SERVICEDURATION='$SERVICEDURATION$' NAGIOS_NOTIFICATIONRECIPIENTS='$NOTIFICATIONRECIPIENTS$' NAGIOS_SERVICEGROUPALIAS='$SERVICEGROUPALIAS$' NAGIOS_HOSTALIAS='$HOSTALIAS$' NAGIOS_NOTIFICATIONAUTHOR='$NOTIFICATIONAUTHOR$' NAGIOS_NOTIFICATIONCOMMENT='$NOTIFICATIONCOMMENT$' NAGIOS_CONTACTEMAIL='$CONTACTEMAIL$' NAGIOS_SERVICEATTEMPT='$SERVICEATTEMPT$' /usr/bin/perl '$USER7$/send.notify' http://192.168.1.1/nagios 2>/tmp/send.log
}
define command{
 command_name    notify-html-host
 command_line NAGIOS_NOTIFICATIONTYPE='$NOTIFICATIONTYPE$' NAGIOS_HOSTSTATE='$HOSTSTATE$' NAGIOS_CONTACTGROUPNAME='$CONTACTGROUPNAME$' NAGIOS_HOSTNAME='$HOSTNAME$' NAGIOS_HOSTADDRESS='$HOSTADDRESS$' NAGIOS_HOSTGROUPNAMES='$HOSTGROUPNAMES$' NAGIOS_HOSTALIAS='$HOSTALIAS$' NAGIOS_LONGDATETIME='$LONGDATETIME$' NAGIOS_NOTIFICATIONRECIPIENTS='$NOTIFICATIONRECIPIENTS$' NAGIOS_SERVICEGROUPALIAS='$SERVICEGROUPALIAS$' NAGIOS_LONGHOSTOUTPUT='$LONGHOSTOUTPUT$' NAGIOS_HOSTALIAS='$HOSTALIAS$' NAGIOS_HOSTOUTPUT='$HOSTOUTPUT$' NAGIOS_HOSTDURATION='$HOSTDURATION$' NAGIOS_NOTIFICATIONAUTHOR='$NOTIFICATIONAUTHOR$' NAGIOS_NOTIFICATIONCOMMENT='$NOTIFICATIONCOMMENT$' NAGIOS_CONTACTEMAIL='$CONTACTEMAIL$' NAGIOS_SERVICEATTEMPT='' /usr/bin/perl '$USER7$/send.notify' http://192.168.1.1/nagios 2>/tmp/send.log
}

This helped to me. At the beginning it was one command for both notifications, with different host/service ENV vars presetting by nagios:

define command{
command_name    notify-html
command_line /usr/bin/perl $USER2$/send.notify http://192.168.1.1/nagios 2>/tmp/send.log
}

By the way, nagios documentation not recommends to set enable_environment_macros=1:

Enabling this is a very bad idea for anything but very small setups, as it means plugins, notification scripts and eventhandlers may run out of environment space. It will also cause a significant increase in CPU- and memory usage and drastically reduce the number of checks you can run.

PS/ My answer was edited, due to need to split notify-html command to notify-html-host and notify-html-service. I started to receive wrong host notifications due to errors with macros deffinitions (service macros are absent in host notification events), and I had to trace debug log of nagios and saw a lots of 'WARNING: An error occurred processing macro' messages. Good Luck.

Sasha Golikov
  • 638
  • 5
  • 11
  • Also you can think about reducing the number of checks. In fact when I found the solution I refused from a number of checks, because of their duplication or unimportance. – Sasha Golikov May 20 '19 at 16:50
0

I had this exact same issue but it seems it was due to the number of services tied to a single Servicegroup. Once the Servicegroup had more than nine services reporting they would return:

[XXXXXXX] Warning: Return code of 7 for check of service 'XXXXXXX' on host  was out of bounds.

I reorganized my services into a few separate Servicegroups and all the checks functioned normally again without any further adjustment.