REGEX with look ahead not working
Posted: 03 Aug 2023, 15:31
I am trying to ignore entries in my /usr/local/cpanel/logs/error_log, where my hosting company does not allow use of the cPanel Store directly. The hosting company also resells the cPanel add-on products.
My server environment is:
OS: CentOS v7.9.2009 STANDARD virtuozzo
cPanel Version: 110.0.9
The special need is that the error_log entry begins with a date/time, and then there are subsequent lines followed by a newline character that are part of the initial error_log entry; until the next new entry which begins with a date/time. I want to ignore the entire log entry (multiple lines) using csf.logignore.
My REGEX works at regex101.com but DOES NOT work on my server, when added to my csf.logignore.
YES, I have restarted LFD after editing the file.
If I remove the regex look ahead "?=..." csf will ignore the 1st line OK, but will include the subsequent lines in the email logfile report (not what we want).
I have the following working when tested at regex101.com , using flavor PCRE2.
Regex101 shortcut: https://regex101.com/r/4jdfym/1
Regex:
Against these error_log lines:
My server environment is:
OS: CentOS v7.9.2009 STANDARD virtuozzo
cPanel Version: 110.0.9
The special need is that the error_log entry begins with a date/time, and then there are subsequent lines followed by a newline character that are part of the initial error_log entry; until the next new entry which begins with a date/time. I want to ignore the entire log entry (multiple lines) using csf.logignore.
My REGEX works at regex101.com but DOES NOT work on my server, when added to my csf.logignore.
YES, I have restarted LFD after editing the file.
If I remove the regex look ahead "?=..." csf will ignore the 1st line OK, but will include the subsequent lines in the email logfile report (not what we want).
I have the following working when tested at regex101.com , using flavor PCRE2.
Regex101 shortcut: https://regex101.com/r/4jdfym/1
Regex:
Code: Select all
^(\S+|\S+\s+\d+\s+\S+) [^\s\.]+ .*warn .* Failed to fetch cPStore[\s\S]*?(?=\n.*?\[)
Code: Select all
[2023-08-03 06:45:04 -0400] warn [xml-api] Failed to fetch cPStore products list: Cpanel::Exception::Market::Disabled/(XID qxedn2) “cPanel Store” indicated that the Market has been disabled by the license holder.
at /usr/local/cpanel/Cpanel/Exception/External.pm line 106.
Cpanel::Exception::External::create("Market::Disabled", HASH(0x4cc2b50)) called at /usr/local/cpanel/Cpanel/Market/Provider/cPStore/ProductsCache.pm line 94
Cpanel::Market::Provider::cPStore::ProductsCache::__ANON__(Cpanel::Exception::cPStoreError=HASH(0x53ee560)) called at /usr/local/cpanel/3rdparty/perl/536/cpanel-lib/Try/Tiny.pm line 121
Try::Tiny::try(CODE(0x4dde068), Try::Tiny::Catch=REF(0x4c71d90)) called at /usr/local/cpanel/Cpanel/Market/Provider/cPStore/ProductsCache.pm line 96
Cpanel::Market::Provider::cPStore::ProductsCache::_LOAD_FRESH("Cpanel::Market::Provider::cPStore::ProductsCache") called at /usr/local/cpanel/Cpanel/CacheFile.pm line 239
Cpanel::CacheFile::load("Cpanel::Market::Provider::cPStore::ProductsCache") called at /usr/local/cpanel/Cpanel/Market/Provider/cPStore/ProductsCache.pm line 139
Cpanel::Market::Provider::cPStore::ProductsCache::load_with_short_name("Cpanel::Market::Provider::cPStore::ProductsCache") called at /usr/local/cpanel/Cpanel/Market/Provider/cPStore/ProductsCache.pm line 104
Cpanel::Market::Provider::cPStore::ProductsCache::load("Cpanel::Market::Provider::cPStore::ProductsCache") called at /usr/local/cpanel/Cpanel/Market/Provider/cPStore.pm line 180
Cpanel::Market::Provider::cPStore::_get_products_list_for_validation() called at /usr/local/cpanel/Cpanel/Market/Provider/cPStore.pm line 167
Cpanel::Market::Provider::cPStore::get_products_list() called at /usr/local/cpanel/Cpanel/Config/ConfigObj/Driver/Market/META.pm line 119
Cpanel::Config::ConfigObj::Driver::Market::META::__ANON__() called at /usr/local/cpanel/3rdparty/perl/536/cpanel-lib/Try/Tiny.pm line 100
eval {...} called at /usr/local/cpanel/3rdparty/perl/536/cpanel-lib/Try/Tiny.pm line 91
Try::Tiny::try(CODE(0x4dcaf10), Try::Tiny::Catch=REF(0x48fd770)) called at /usr/local/cpanel/Cpanel/Config/ConfigObj/Driver/Market/META.pm line 124
Cpanel::Config::ConfigObj::Driver::Market::META::can_be_enabled() called at /usr/local/cpanel/Cpanel/Config/ConfigObj/Driver/Market/META.pm line 148
Cpanel::Config::ConfigObj::Driver::Market::META::auto_enable("Cpanel::Config::ConfigObj::Driver::Market::META") called at /usr/local/cpanel/Cpanel/Config/ConfigObj.pm line 106
Cpanel::Config::ConfigObj::_unload_if_auto_enabled("Cpanel::Config::ConfigObj::Driver::Market", "Cpanel::Config::ConfigObj::Driver::Market::META") called at /usr/local/cpanel/Cpanel/Config/ConfigObj.pm line 160
Cpanel::Config::ConfigObj::get_available_drivers(undef, 0, 0) called at /usr/local/cpanel/Cpanel/Config/ConfigObj.pm line 563
Cpanel::Config::ConfigObj::_get_drivers(Cpanel::Config::ConfigObj=HASH(0x486f4b0)) called at /usr/local/cpanel/Cpanel/Config/ConfigObj.pm line 707
Cpanel::Config::ConfigObj::call_all(Cpanel::Config::ConfigObj=HASH(0x486f4b0), "acl_desc") called at /usr/local/cpanel/Whostmgr/ACLS.pm line 112
Whostmgr::ACLS::_dynamic_acl_items() called at /usr/local/cpanel/Whostmgr/ACLS.pm line 133
Whostmgr::ACLS::_get_dynamic_acl_lists() called at /usr/local/cpanel/Whostmgr/ACLS.pm line 175
Whostmgr::ACLS::_dynamic_acl_update() called at /usr/local/cpanel/Whostmgr/ACLS.pm line 117
Whostmgr::ACLS::get_dynamic_acl_lists() called at /usr/local/cpanel/Whostmgr/ACLS.pm line 97
Whostmgr::ACLS::get_filtered_reseller_privs() called at /usr/local/cpanel/Whostmgr/ACLS.pm line 68
Whostmgr::ACLS::_acls() called at /usr/local/cpanel/Whostmgr/ACLS.pm line 53
Whostmgr::ACLS::init_acls() called at whostmgr/bin/xml-api.pl line 5024
whostmgr::bin::xml_api::script(CODE(0x472a388), "-json", "./listaccts") called at whostmgr/bin/xml-api.pl line 5015