mirror of https://github.com/Icinga/icinga2.git
Merge branch 'feature/livestatus-regexp-filter-5007' into next
Fixes #5007
This commit is contained in:
commit
0eb5daaad9
|
@ -48,7 +48,7 @@ if(WIN32)
|
||||||
add_definitions(-DBOOST_ALL_NO_LIB)
|
add_definitions(-DBOOST_ALL_NO_LIB)
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
find_package(Boost 1.41.0 COMPONENTS thread system program_options REQUIRED)
|
find_package(Boost 1.41.0 COMPONENTS thread system program_options regex REQUIRED)
|
||||||
link_directories(${Boost_LIBRARY_DIRS})
|
link_directories(${Boost_LIBRARY_DIRS})
|
||||||
include_directories(${Boost_INCLUDE_DIRS})
|
include_directories(${Boost_INCLUDE_DIRS})
|
||||||
|
|
||||||
|
|
|
@ -21,7 +21,9 @@
|
||||||
#include "base/convert.h"
|
#include "base/convert.h"
|
||||||
#include "base/array.h"
|
#include "base/array.h"
|
||||||
#include "base/objectlock.h"
|
#include "base/objectlock.h"
|
||||||
|
#include "base/logger_fwd.h"
|
||||||
#include <boost/foreach.hpp>
|
#include <boost/foreach.hpp>
|
||||||
|
#include <boost/regex.hpp>
|
||||||
|
|
||||||
using namespace icinga;
|
using namespace icinga;
|
||||||
using namespace livestatus;
|
using namespace livestatus;
|
||||||
|
@ -59,11 +61,33 @@ bool AttributeFilter::Apply(const Table::Ptr& table, const Value& row)
|
||||||
else
|
else
|
||||||
return (static_cast<String>(value) == m_Operand);
|
return (static_cast<String>(value) == m_Operand);
|
||||||
} else if (m_Operator == "~") {
|
} else if (m_Operator == "~") {
|
||||||
|
boost::regex expr(static_cast<std::string>(m_Operand));
|
||||||
|
boost::smatch what;
|
||||||
|
String val = static_cast<String>(value);
|
||||||
|
std::string::const_iterator begin = val.Begin();
|
||||||
|
std::string::const_iterator end = val.End();
|
||||||
|
|
||||||
|
bool ret = boost::regex_search(begin, end, what, expr);
|
||||||
|
|
||||||
|
//Log(LogDebug, "livestatus", "Attribute filter '" + m_Operand + " " + m_Operator + " " +
|
||||||
|
// static_cast<String>(value) + "' " + (ret ? "matches" : "doesn't match") + "." );
|
||||||
|
|
||||||
|
return ret;
|
||||||
} else if (m_Operator == "=~") {
|
} else if (m_Operator == "=~") {
|
||||||
return string_iless()(value, m_Operand);
|
return string_iless()(value, m_Operand);
|
||||||
} else if (m_Operator == "~~") {
|
} else if (m_Operator == "~~") {
|
||||||
|
boost::regex expr(static_cast<std::string>(m_Operand), boost::regex::icase);
|
||||||
|
boost::smatch what;
|
||||||
|
String val = static_cast<String>(value);
|
||||||
|
std::string::const_iterator begin = val.Begin();
|
||||||
|
std::string::const_iterator end = val.End();
|
||||||
|
|
||||||
|
bool ret = boost::regex_search(begin, end, what, expr);
|
||||||
|
|
||||||
|
//Log(LogDebug, "livestatus", "Attribute filter '" + m_Operand + " " + m_Operator + " " +
|
||||||
|
// static_cast<String>(value) + "' " + (ret ? "matches" : "doesn't match") + "." );
|
||||||
|
|
||||||
|
return ret;
|
||||||
} else if (m_Operator == "<") {
|
} else if (m_Operator == "<") {
|
||||||
if (value.GetType() == ValueNumber)
|
if (value.GetType() == ValueNumber)
|
||||||
return (static_cast<double>(value) < Convert::ToDouble(m_Operand));
|
return (static_cast<double>(value) < Convert::ToDouble(m_Operand));
|
||||||
|
|
|
@ -73,12 +73,14 @@ Requires: boost%{el5_boost_version}-program-options
|
||||||
Requires: boost%{el5_boost_version}-system
|
Requires: boost%{el5_boost_version}-system
|
||||||
Requires: boost%{el5_boost_version}-test
|
Requires: boost%{el5_boost_version}-test
|
||||||
Requires: boost%{el5_boost_version}-thread
|
Requires: boost%{el5_boost_version}-thread
|
||||||
|
Requires: boost%{el5_boost_version}-regex
|
||||||
%else
|
%else
|
||||||
BuildRequires: boost-devel >= 1.41
|
BuildRequires: boost-devel >= 1.41
|
||||||
Requires: boost-program-options >= 1.41
|
Requires: boost-program-options >= 1.41
|
||||||
Requires: boost-system >= 1.41
|
Requires: boost-system >= 1.41
|
||||||
Requires: boost-test >= 1.41
|
Requires: boost-test >= 1.41
|
||||||
Requires: boost-thread >= 1.41
|
Requires: boost-thread >= 1.41
|
||||||
|
Requires: boost-regex >= 1.41
|
||||||
%endif
|
%endif
|
||||||
%endif
|
%endif
|
||||||
|
|
||||||
|
@ -98,6 +100,7 @@ Requires: libboost_program_options%{opensuse_boost_version}
|
||||||
Requires: libboost_system%{opensuse_boost_version}
|
Requires: libboost_system%{opensuse_boost_version}
|
||||||
Requires: libboost_test%{opensuse_boost_version}
|
Requires: libboost_test%{opensuse_boost_version}
|
||||||
Requires: libboost_thread%{opensuse_boost_version}
|
Requires: libboost_thread%{opensuse_boost_version}
|
||||||
|
Requires: libboost_regex%{opensuse_boost_version}
|
||||||
%endif
|
%endif
|
||||||
%endif
|
%endif
|
||||||
|
|
||||||
|
|
|
@ -0,0 +1,6 @@
|
||||||
|
GET log
|
||||||
|
Columns: host_name service_description time lineno class type options plugin_output state state_type comment contact_name command_name
|
||||||
|
Filter: time >= 1348657741
|
||||||
|
Filter: message ~ ALERT
|
||||||
|
ResponseHeader: fixed16
|
||||||
|
|
Loading…
Reference in New Issue