Page 1 of 1

regex nagios.cfg in static dir

Posted: Tue Mar 30, 2021 3:31 pm
by jenglish
Hello,

I'm trying to get regex matching to work.

Something like this:

Code: Select all

define hostgroup {
        hostgroup_name          Linux-Regex
        alias                   Regex Test for All Linux Hosts
        members                 ^[a-zA-Z]{4}[l]*.*
        }
I have attempted to turn on regex matching, but something is catching probably due to CCM. Can I declare two nagios.cfg files? One for CCM and one for static?

Code: Select all

# grep regex /etc/nagios/nagios.cfg
use_regexp_matching=1
use_true_regexp_matching=0

Code: Select all

# /usr/local/nagios/bin/nagios -vv /etc/nagios/nagios.cfg

Nagios Core 4.4.6
Copyright (c) 2009-present Nagios Core Development Team and Community Contributors
Copyright (c) 1999-2009 Ethan Galstad
Last Modified: 2020-04-28
License: GPL

Website: https://www.nagios.org
Reading configuration data...
   Read main config file okay...
Processing object config directory '/usr/local/nagios/etc/static'...
Processing object config file '/usr/local/nagios/etc/static/commands.cfg'...
Processing object config file '/usr/local/nagios/etc/static/host-templates.cfg'...
Processing object config file '/usr/local/nagios/etc/static/service-templates.cfg'...
Processing object config directory '/usr/local/nagios/etc/static/EIS'...
Processing object config directory '/usr/local/nagios/etc/static/EIS/backup'...
Processing object config directory '/usr/local/nagios/etc/static/EIS/HOSTS'...
Processing object config file '/usr/local/nagios/etc/static/EIS/HOSTS/other-hosts.cfg'...
Processing object config file '/usr/local/nagios/etc/static/EIS/HOSTS/VIP-hosts.cfg'...
Processing object config file '/usr/local/nagios/etc/static/EIS/HOSTS/linux-hosts.cfg'...
Processing object config file '/usr/local/nagios/etc/static/EIS/HOSTS/vmware-hosts.cfg'...
Processing object config file '/usr/local/nagios/etc/static/EIS/HOSTS/security-hosts.cfg'...
Processing object config file '/usr/local/nagios/etc/static/EIS/HOSTS/hosts.cfg'...
Processing object config file '/usr/local/nagios/etc/static/EIS/HOSTS/netops-hosts.cfg'...
Processing object config file '/usr/local/nagios/etc/static/EIS/HOSTS/windows-prod-hosts.cfg'...
Processing object config file '/usr/local/nagios/etc/static/EIS/HOSTS/windows-dev-hosts.cfg'...
Processing object config file '/usr/local/nagios/etc/static/EIS/HOSTS/windows-test-hosts.cfg'...
Processing object config file '/usr/local/nagios/etc/static/EIS/HOSTS/infoblox-hosts.cfg'...
Processing object config file '/usr/local/nagios/etc/static/EIS/HOSTS/acd-hosts.cfg'...
Processing object config file '/usr/local/nagios/etc/static/EIS/HOSTS/paloalto-hosts.cfg'...
Processing object config file '/usr/local/nagios/etc/static/EIS/HOSTS/network-security-hosts.cfg'...
Processing object config directory '/usr/local/nagios/etc/static/EIS/SERVICES'...
Processing object config file '/usr/local/nagios/etc/static/EIS/SERVICES/netops-services.cfg'...
Processing object config file '/usr/local/nagios/etc/static/EIS/SERVICES/ACD-services.cfg'...
Processing object config file '/usr/local/nagios/etc/static/EIS/SERVICES/ldap-admin-checks.cfg'...
Processing object config file '/usr/local/nagios/etc/static/EIS/SERVICES/ldap-service-accounts-checks.cfg'...
Processing object config file '/usr/local/nagios/etc/static/EIS/SERVICES/security-services.cfg'...
Processing object config file '/usr/local/nagios/etc/static/EIS/SERVICES/services.cfg'...
Processing object config file '/usr/local/nagios/etc/static/EIS/SERVICES/windows-services.cfg'...
Processing object config file '/usr/local/nagios/etc/static/EIS/SERVICES/linux-services.cfg'...
Processing object config file '/usr/local/nagios/etc/static/EIS/SERVICES/palo-alto-services.cfg'...
Processing object config file '/usr/local/nagios/etc/static/EIS/SERVICES/netsec-windows-services.cfg'...
Processing object config file '/usr/local/nagios/etc/static/EIS/hostgroups.cfg'...
Processing object config file '/usr/local/nagios/etc/static/EIS/hostgroups-empty.cfg'...
Processing object config file '/usr/local/nagios/etc/static/xiobjects.cfg'...
Processing object config file '/usr/local/nagios/etc/static/xitemplates.cfg'...
Processing object config file '/usr/local/nagios/etc/static/xitest.cfg'...
Processing object config file '/usr/local/nagios/etc/contacttemplates.cfg'...
Processing object config file '/usr/local/nagios/etc/contactgroups.cfg'...
Processing object config file '/usr/local/nagios/etc/contacts.cfg'...
Processing object config file '/usr/local/nagios/etc/timeperiods.cfg'...
Processing object config file '/usr/local/nagios/etc/commands.cfg'...
Processing object config file '/usr/local/nagios/etc/hostgroups.cfg'...
Processing object config file '/usr/local/nagios/etc/servicegroups.cfg'...
Processing object config file '/usr/local/nagios/etc/hosttemplates.cfg'...
Processing object config file '/usr/local/nagios/etc/servicetemplates.cfg'...
Processing object config file '/usr/local/nagios/etc/servicedependencies.cfg'...
Processing object config file '/usr/local/nagios/etc/serviceescalations.cfg'...
Processing object config file '/usr/local/nagios/etc/hostdependencies.cfg'...
Processing object config file '/usr/local/nagios/etc/hostescalations.cfg'...
Processing object config file '/usr/local/nagios/etc/hostextinfo.cfg'...
Processing object config file '/usr/local/nagios/etc/serviceextinfo.cfg'...
Processing object config directory '/usr/local/nagios/etc/hosts'...
Processing object config directory '/usr/local/nagios/etc/services'...
   Error processing object config files!


***> One or more problems was encountered while processing the config files...

     Check your configuration file(s) to ensure that they contain valid
     directives and data definitions.  If you are upgrading from a previous
     version of Nagios, you should be aware that some variables/definitions
     may have been removed or modified in this version.  Make sure to read
     the HTML documentation regarding the config files, as well as the
     'Whats New' section to find out what has changed.

#

Re: regex nagios.cfg in static dir

Posted: Wed Mar 31, 2021 3:26 pm
by benjaminsmith
Hi,

I was able to succussfully apply configuration with following settings:

Code: Select all

use_regexp_matching=1
use_true_regexp_matching=1
Reference: https://assets.nagios.com/downloads/nag ... ricks.html

However, this feature is not fully supported in Nagios XI, so it may have conflicts with the CCM.

--Benjamin

Re: regex nagios.cfg in static dir

Posted: Wed Mar 31, 2021 3:33 pm
by jenglish
However, this feature is not fully supported in Nagios XI, so it may have conflicts with the CCM.
What would be the best way to determine where I am getting stuck at? We use CCM for about ... 5 things and could be migrated to static, no?
Capture.PNG

Re: regex nagios.cfg in static dir

Posted: Wed Mar 31, 2021 4:44 pm
by dchurch
What turning that on is that every place you reference a host name, you'll have to change it to an appropriate regular expression.

E.g. you'll have to change

Code: Select all

define hostgroup {
    hostgroup_name    linux-servers
    alias             Linux Servers
    members           foo.example.com,bar.example.com
    notes_url         https://example.com
}
to

Code: Select all

define hostgroup {
    hostgroup_name    linux-servers
    alias             Linux Servers
    members           foo\.example\.com,bar\.example\.com
    notes_url         https://example.com
}
But sure you could do this all via static configuration

Re: regex nagios.cfg in static dir

Posted: Thu Apr 01, 2021 8:07 am
by jenglish
Understood. I think I'll just be skipping this for now then. I don't foresee us having to do that to every host_name value in our environment.

Thank you both, appreciate the insight. This can be closed.

Re: regex nagios.cfg in static dir

Posted: Thu Apr 01, 2021 8:37 am
by scottwilkerson
jenglish wrote:Understood. I think I'll just be skipping this for now then. I don't foresee us having to do that to every host_name value in our environment.

Thank you both, appreciate the insight. This can be closed.
Locking thread