Module: check_mk
Branch: master
Commit: 62ba2afcc4c782a50ce0590f6abbc5496356ee54
URL:
http://git.mathias-kettner.de/git/?p=check_mk.git;a=commit;h=62ba2afcc4c782…
Author: Mathias Kettner <mk(a)mathias-kettner.de>
Date: Sat Aug 20 22:04:16 2011 +0200
Livestatus: Better error messages in case of unimplemented operators
---
.bugs/12 | 10 ++++++--
ChangeLog | 1 +
livestatus/src/AttributelistFilter.cc | 2 +-
livestatus/src/CustomVarsFilter.cc | 2 +-
livestatus/src/DoubleColumnFilter.cc | 6 ++--
livestatus/src/HostlistColumnFilter.cc | 2 +-
livestatus/src/IntColumnFilter.cc | 2 +-
livestatus/src/ListColumnFilter.cc | 8 +++---
livestatus/src/Makefile.am | 2 +-
livestatus/src/ServicelistColumnFilter.cc | 2 +-
livestatus/src/StringColumnFilter.cc | 2 +-
livestatus/src/opids.cc | 31 +++++++++++++++++++++++++++++
livestatus/src/opids.h | 2 +
13 files changed, 55 insertions(+), 17 deletions(-)
diff --git a/.bugs/12 b/.bugs/12
index 160ac9f..d137b1c 100644
--- a/.bugs/12
+++ b/.bugs/12
@@ -1,10 +1,11 @@
Title: Sorry, Operator 4 for lists not implemented.
Component: livestatus
+State: done
+Class: nastiness
+Date: 2010-12-21 12:11:12
Benefit: 1
-State: open
Cost: 3
-Date: 2010-12-21 12:11:12
-Class: nastiness
+Fun: 0
Wenn ich im Thruk im Suchfenster einfach Enter drücke, kommt folgende Query bei raus:
GET services
@@ -22,3 +23,6 @@ Or: 2
Or: 8
livestatus: Sorry, Operator 4 for lists not implemented.
Was ist eigentlich Operator 4?
+
+2011-08-20 22:04:00: changed state open -> done
+Operator wird jetzt ausgegeben.
diff --git a/ChangeLog b/ChangeLog
index ab0b783..77d883e 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -27,6 +27,7 @@
MK Livestatus:
* WaitObject: allow to separate host name and service with a semicolon.
That makes host names containing spaces possible.
+ * Better error messages in case of unimplemented operators
Multisite:
* FIX: reschedule now works for host names containing spaces
diff --git a/livestatus/src/AttributelistFilter.cc
b/livestatus/src/AttributelistFilter.cc
index 0aebd96..196e68d 100644
--- a/livestatus/src/AttributelistFilter.cc
+++ b/livestatus/src/AttributelistFilter.cc
@@ -65,7 +65,7 @@ bool AttributelistFilter::accepts(void *data)
case OP_REGEX_ICASE:
pass = (act_value & _ref) != 0; break;
default:
- logger(LG_INFO, "Sorry. Operator %d not implemented for attribute
lists", _opid);
+ logger(LG_INFO, "Sorry. Operator %s not implemented for attribute
lists", op_names_plus_8[_opid]);
}
return pass != _negate;
}
diff --git a/livestatus/src/CustomVarsFilter.cc b/livestatus/src/CustomVarsFilter.cc
index 9a140ab..4c64869 100644
--- a/livestatus/src/CustomVarsFilter.cc
+++ b/livestatus/src/CustomVarsFilter.cc
@@ -115,7 +115,7 @@ bool CustomVarsFilter::accepts(void *data)
case OP_LESS:
return (!is_member) == (!_negate);
default:
- logger(LG_INFO, "Sorry, Operator %d for custom variable lists not
implemented.", _opid);
+ logger(LG_INFO, "Sorry, Operator %s for custom variable lists not
implemented.", op_names_plus_8[_opid]);
return true;
}
}
diff --git a/livestatus/src/DoubleColumnFilter.cc b/livestatus/src/DoubleColumnFilter.cc
index d13c689..2cb6ec7 100644
--- a/livestatus/src/DoubleColumnFilter.cc
+++ b/livestatus/src/DoubleColumnFilter.cc
@@ -28,11 +28,11 @@
#include "logger.h"
#include "opids.h"
- DoubleColumnFilter::DoubleColumnFilter(DoubleColumn *column, int opid, char *value)
+DoubleColumnFilter::DoubleColumnFilter(DoubleColumn *column, int opid, char *value)
: _column(column)
, _ref_value(atof(value))
, _opid(abs(opid))
- , _negate(opid < 0)
+ , _negate(opid < 0)
{
}
@@ -48,7 +48,7 @@ bool DoubleColumnFilter::accepts(void *data)
case OP_LESS:
pass = act_value < _ref_value; break;
default:
- logger(LG_INFO, "Sorry. Operator %d for float columns not
implemented.", _opid);
+ logger(LG_INFO, "Sorry. Operator %s for float columns not
implemented.", op_names_plus_8[_opid]);
break;
}
return pass != _negate;
diff --git a/livestatus/src/HostlistColumnFilter.cc
b/livestatus/src/HostlistColumnFilter.cc
index 080124d..5ee2102 100644
--- a/livestatus/src/HostlistColumnFilter.cc
+++ b/livestatus/src/HostlistColumnFilter.cc
@@ -56,7 +56,7 @@ bool HostlistColumnFilter::accepts(void *data)
case OP_LESS:
return !is_member;
default:
- logger(LG_INFO, "Sorry, Operator %d for host lists lists not
implemented.", _opid);
+ logger(LG_INFO, "Sorry, Operator %s for host lists lists not
implemented.", op_names_plus_8[_opid]);
return true;
}
}
diff --git a/livestatus/src/IntColumnFilter.cc b/livestatus/src/IntColumnFilter.cc
index 2bf66cd..605814d 100644
--- a/livestatus/src/IntColumnFilter.cc
+++ b/livestatus/src/IntColumnFilter.cc
@@ -57,7 +57,7 @@ bool IntColumnFilter::accepts(void *data)
case OP_LESS:
pass = act_value < ref_value; break;
default:
- logger(LG_INFO, "Sorry. Operator %d for integers not implemented.",
_opid);
+ logger(LG_INFO, "Sorry. Operator %s for integers not implemented.",
op_names_plus_8[_opid]);
break;
}
return pass != _negate;
diff --git a/livestatus/src/ListColumnFilter.cc b/livestatus/src/ListColumnFilter.cc
index 2bcb828..eebd4dc 100644
--- a/livestatus/src/ListColumnFilter.cc
+++ b/livestatus/src/ListColumnFilter.cc
@@ -29,10 +29,10 @@
#include "ListColumnFilter.h"
#include "ListColumn.h"
- ListColumnFilter::ListColumnFilter(ListColumn *column, int opid, char *value)
+ListColumnFilter::ListColumnFilter(ListColumn *column, int opid, char *value)
: _column(column)
, _opid(opid)
- , _empty_ref(!value[0])
+ , _empty_ref(!value[0])
{
_ref_member = _column->getNagiosObject(value);
}
@@ -52,11 +52,11 @@ bool ListColumnFilter::accepts(void *data)
case -OP_EQUAL:
if (_empty_ref)
return _column->isEmpty(data) == (_opid == OP_EQUAL);
- logger(LG_INFO, "Sorry, Equality for lists implemented only for
emptyness");
+ logger(LG_INFO, "Sorry, equality for lists implemented only for
emptyness");
return false;
default:
- logger(LG_INFO, "Sorry, Operator %d for lists not implemented.",
_opid);
+ logger(LG_INFO, "Sorry, Operator %s for lists not implemented.",
op_names_plus_8[_opid]);
return true;
}
}
diff --git a/livestatus/src/Makefile.am b/livestatus/src/Makefile.am
index c0117dc..054027d 100644
--- a/livestatus/src/Makefile.am
+++ b/livestatus/src/Makefile.am
@@ -47,7 +47,7 @@ livestatus_so_SOURCES = \
OffsetStringHostMacroColumn.cc StatsColumn.cc IntAggregator.cc CountAggregator.cc \
DoubleAggregator.cc AttributelistColumn.cc AttributelistFilter.cc \
global_counters.c module.c logger.c waittriggers.c TimeperiodsCache.cc pnp4nagios.cc
\
- ContactgroupsColumn.cc
+ ContactgroupsColumn.cc opids.cc
livestatus_so_CXXFLAGS = -I$(top_srcdir)/nagios -fPIC
livestatus_so_CFLAGS = $(livestatus_so_CXXFLAGS)
diff --git a/livestatus/src/ServicelistColumnFilter.cc
b/livestatus/src/ServicelistColumnFilter.cc
index 06ad6a8..2fb2d1a 100644
--- a/livestatus/src/ServicelistColumnFilter.cc
+++ b/livestatus/src/ServicelistColumnFilter.cc
@@ -75,7 +75,7 @@ bool ServicelistColumnFilter::accepts(void *data)
case OP_LESS:
return !is_member;
default:
- logger(LG_INFO, "Sorry, Operator %d for service lists lists not
implemented.", _opid);
+ logger(LG_INFO, "Sorry, Operator %s for service lists lists not
implemented.", op_names_plus_8[_opid]);
return true;
}
}
diff --git a/livestatus/src/StringColumnFilter.cc b/livestatus/src/StringColumnFilter.cc
index 613333d..031bfba 100644
--- a/livestatus/src/StringColumnFilter.cc
+++ b/livestatus/src/StringColumnFilter.cc
@@ -83,7 +83,7 @@ bool StringColumnFilter::accepts(void *data)
pass = 0 < strcmp(_ref_string.c_str(), act_string); break;
default:
// this should never be reached, all operators are handled
- logger(LG_INFO, "Sorry. Operator %d for strings not implemented.",
_opid);
+ logger(LG_INFO, "Sorry. Operator %s for strings not implemented.",
op_names_plus_8[_opid]);
break;
}
return pass != _negate;
diff --git a/livestatus/src/opids.cc b/livestatus/src/opids.cc
new file mode 100644
index 0000000..50e6b39
--- /dev/null
+++ b/livestatus/src/opids.cc
@@ -0,0 +1,31 @@
+// +------------------------------------------------------------------+
+// | ____ _ _ __ __ _ __ |
+// | / ___| |__ ___ ___| | __ | \/ | |/ / |
+// | | | | '_ \ / _ \/ __| |/ / | |\/| | ' / |
+// | | |___| | | | __/ (__| < | | | | . \ |
+// | \____|_| |_|\___|\___|_|\_\___|_| |_|_|\_\ |
+// | |
+// | Copyright Mathias Kettner 2010 mk(a)mathias-kettner.de |
+// +------------------------------------------------------------------+
+//
+// This file is part of Check_MK.
+// The official homepage is at
http://mathias-kettner.de/check_mk.
+//
+// check_mk is free software; you can redistribute it and/or modify it
+// under the terms of the GNU General Public License as published by
+// the Free Software Foundation in version 2. check_mk is distributed
+// in the hope that it will be useful, but WITHOUT ANY WARRANTY; with-
+// out even the implied warranty of MERCHANTABILITY or FITNESS FOR A
+// PARTICULAR PURPOSE. See the GNU General Public License for more de-
+// ails. You should have received a copy of the GNU General Public
+// License along with GNU Make; see the file COPYING. If not, write
+// to the Free Software Foundation, Inc., 51 Franklin St, Fifth Floor,
+// Boston, MA 02110-1301 USA.
+
+#include "opids.h"
+
+const char *op_names_plus_8[] {
+ "", "", ">=", "<=", "!~~",
"!=~", "!~", "!=",
+ "(invalid)", "=", "~", "=~", "~~",
">", "<"
+};
+
diff --git a/livestatus/src/opids.h b/livestatus/src/opids.h
index c5260e4..34ef770 100644
--- a/livestatus/src/opids.h
+++ b/livestatus/src/opids.h
@@ -35,6 +35,8 @@
#define OP_GREATER 5 // >
#define OP_LESS 6 // <
+extern const char *op_names_plus_8[];
+
// Note: The operators !=, <= and >= are parsed into ! =, ! > and ! <.
// The negation is represented by negating the value of the operator.
// Example >= is represented as -6 (- OP_LESS)