Bug-Nagios or Regexp, but bug

Support forum for Nagios Core, Nagios Plugins, NCPA, NRPE, NSCA, NDOUtils and more. Engage with the community of users including those using the open source solutions.
Locked
tim_wood
Posts: 2
Joined: Mon Jun 27, 2011 3:34 pm

Bug-Nagios or Regexp, but bug

Post by tim_wood »

I have found a bug, or loss of logic, in Nagios or it's regexp implementation. I have the following config snippets to show what I have implemented, and although it might not be the "purists" way to implement my checks, it has highlighted a problem.

Below is my definition file, and you will see I am using a regexp to match the hosts to run a particular service check against. I have commented one of the devices, the service checks expand and work just fine, however, if I have more than one host that matches the second service check regexp, the second and subsequent regexp-matched-hosts use the first service definition and not the second one.

Since it works using two regexp's in one file if you only match one host in the second regexp expansion, I assumed more than one regexp in one file was OK, maybe not? Otherwise, it's a bug or loss of logic. I could have used multiple hostgroups to group devices but they just fit logically into one hence why I chose this method. Is this a genuine bug? Nagios related Regexp docs seem thin on the ground.

Regards,
Tim

Nagios.cfg contains :-
use_regexp_matching=1
use_true_regexp_matching=0

Device, group and service checks in one file :-
###############################################################################
# device.cfg - devices
###############################################################################

#define host{
# use generic-switch
# host_name 03-device-int2
# address 192.168.116.235
# hostgroups device
# }

define host{
use generic-switch
host_name 03-device-int
address 192.168.116.238
hostgroups device
}

define host{
use generic-switch
host_name 09-device-int2
address 192.168.106.235
hostgroups device
}

define host{
use generic-switch
host_name 09-device-int
address 192.168.106.238
hostgroups device
}

###############################################################################

# A hostgroup for device

define hostgroup{
hostgroup_name device
alias device
}

###############################################################################

# service definition

define service{
use local-service
host_name .*-device-int
service_description TCP
check_command check_tcp!-v!-p 10001
notifications_enabled 0
}

define service{
use local-service
host_name .*-device-int2
service_description TCP
check_command check_tcp!-v!-p 10002
notifications_enabled 0
}
tim_wood
Posts: 2
Joined: Mon Jun 27, 2011 3:34 pm

Re: Bug-Nagios or Regexp, but bug

Post by tim_wood »

Apologies, couple fo schoolboy errors in my post, I forgot to mention I am running 3.2.2 with Plugins 1.4.15, and, I have used the term regexp when I really meant wildcard.

That said, the wildcard logic is what is broken in my example, hopefully this is still a valuable "issue" to be commented on/fixed. I have resolved my problem by using correct regex syntax as below :-
Regards,
Tim

<snip>
# service definition

define service{
use local-service
host_name ^.*-device-int$
service_description TCP
check_command check_tcp!-v!-p 10001
notifications_enabled 0
}

define service{
use local-service
host_name ^.*-device-int2$
service_description TCP
check_command check_tcp!-v!-p 10002
notifications_enabled 0
}
</snip>
Locked