regex nagios.cfg in static dir

This support forum board is for support questions relating to Nagios XI, our flagship commercial network monitoring solution.
Locked
User avatar
jenglish
Posts: 59
Joined: Sat Jun 09, 2018 3:51 pm
Location: Boyers, PA

regex nagios.cfg in static dir

Post 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.

#
benjaminsmith
Posts: 5324
Joined: Wed Aug 22, 2018 4:39 pm
Location: saint paul

Re: regex nagios.cfg in static dir

Post 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
As of May 25th, 2018, all communications with Nagios Enterprises and its employees are covered under our new Privacy Policy.

Be sure to check out our Knowledgebase for helpful articles and solutions!
User avatar
jenglish
Posts: 59
Joined: Sat Jun 09, 2018 3:51 pm
Location: Boyers, PA

Re: regex nagios.cfg in static dir

Post 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
You do not have the required permissions to view the files attached to this post.
dchurch
Posts: 858
Joined: Wed Oct 07, 2020 12:46 pm
Location: Yo mama

Re: regex nagios.cfg in static dir

Post 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
If you didn't get an 8% raise over the course of the pandemic, you took a pay cut.

Discussion of wages is protected speech under the National Labor Relations Act, and no employer can tell you you can't disclose your pay with your fellow employees.
User avatar
jenglish
Posts: 59
Joined: Sat Jun 09, 2018 3:51 pm
Location: Boyers, PA

Re: regex nagios.cfg in static dir

Post 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.
scottwilkerson
DevOps Engineer
Posts: 19396
Joined: Tue Nov 15, 2011 3:11 pm
Location: Nagios Enterprises
Contact:

Re: regex nagios.cfg in static dir

Post 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
Former Nagios employee
Creator:
Human Design Website
Get Your Human Design Chart
Locked