Module: check_mk
Branch: master
Commit: 6f259ff8876d736b209e9a662252dc058574f57e
URL:
http://git.mathias-kettner.de/git/?p=check_mk.git;a=commit;h=6f259ff8876d73…
Author: Mathias Kettner <mk(a)mathias-kettner.de>
Date: Tue Mar 31 06:54:39 2015 +0200
Make Multisite work with Nagios again
---
livestatus/src/Makefile.am | 2 +-
livestatus/src/MetricsColumn.cc | 35 ++++++++++++++++++++++++++++++++++
livestatus/src/MetricsColumn.h | 40 +++++++++++++++++++++++++++++++++++++++
livestatus/src/TableHosts.cc | 4 ++++
livestatus/src/TableServices.cc | 4 ++++
5 files changed, 84 insertions(+), 1 deletion(-)
diff --git a/livestatus/src/Makefile.am b/livestatus/src/Makefile.am
index 2233d64..151a34c 100644
--- a/livestatus/src/Makefile.am
+++ b/livestatus/src/Makefile.am
@@ -33,7 +33,7 @@ livestatus_so_SOURCES = \
ContactsColumn.cc CustomVarsColumn.cc CustomVarsFilter.cc DoubleColumn.cc \
DoubleColumnFilter.cc DowntimeOrComment.cc DownCommColumn.cc EmptyColumn.cc \
Filter.cc GlobalCountersColumn.cc HostContactsColumn.cc HostgroupsColumn.cc \
- HostlistColumn.cc HostlistColumnFilter.cc HostlistStateColumn.cc \
+ HostlistColumn.cc HostlistColumnFilter.cc HostlistStateColumn.cc MetricsColumn.cc \
HostSpecialIntColumn.cc ServiceSpecialIntColumn.cc InputBuffer.cc IntColumn.cc
IntColumnFilter.cc \
ListColumn.cc ListColumnFilter.cc OffsetDoubleColumn.cc OffsetIntColumn.cc \
OffsetStringColumn.cc OffsetTimeperiodColumn.cc OringFilter.cc OutputBuffer.cc \
diff --git a/livestatus/src/MetricsColumn.cc b/livestatus/src/MetricsColumn.cc
new file mode 100644
index 0000000..d31da0f
--- /dev/null
+++ b/livestatus/src/MetricsColumn.cc
@@ -0,0 +1,35 @@
+// +------------------------------------------------------------------+
+// | ____ _ _ __ __ _ __ |
+// | / ___| |__ ___ ___| | __ | \/ | |/ / |
+// | | | | '_ \ / _ \/ __| |/ / | |\/| | ' / |
+// | | |___| | | | __/ (__| < | | | | . \ |
+// | \____|_| |_|\___|\___|_|\_\___|_| |_|_|\_\ |
+// | |
+// | Copyright Mathias Kettner 2014 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 "MetricsColumn.h"
+#include "Query.h"
+
+void MetricsColumn::output(void *data, Query *query)
+{
+ data = shiftPointer(data);
+ if (!data) return;
+
+ query->outputBeginList();
+ query->outputEndList();
+}
diff --git a/livestatus/src/MetricsColumn.h b/livestatus/src/MetricsColumn.h
new file mode 100644
index 0000000..ccdf555
--- /dev/null
+++ b/livestatus/src/MetricsColumn.h
@@ -0,0 +1,40 @@
+// +------------------------------------------------------------------+
+// | ____ _ _ __ __ _ __ |
+// | / ___| |__ ___ ___| | __ | \/ | |/ / |
+// | | | | '_ \ / _ \/ __| |/ / | |\/| | ' / |
+// | | |___| | | | __/ (__| < | | | | . \ |
+// | \____|_| |_|\___|\___|_|\_\___|_| |_|_|\_\ |
+// | |
+// | Copyright Mathias Kettner 2014 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.
+
+#ifndef MetricsColumn_h
+#define MetricsColumn_h
+
+#include "Column.h"
+
+class MetricsColumn : public Column
+{
+public:
+ MetricsColumn(string name, string description, int indirect_offset)
+ : Column(name, description, indirect_offset) {}
+ int type() { return COLTYPE_LIST; }
+ void output(void *, Query *);
+ // Filter *createFilter(int opid, char *value);
+};
+
+#endif // MetricsColumn_h
diff --git a/livestatus/src/TableHosts.cc b/livestatus/src/TableHosts.cc
index 6ed28ae..10bffe5 100644
--- a/livestatus/src/TableHosts.cc
+++ b/livestatus/src/TableHosts.cc
@@ -44,6 +44,7 @@
#include "ServicelistColumn.h"
#include "ServicelistStateColumn.h"
#include "HostgroupsColumn.h"
+#include "MetricsColumn.h"
#include "ContactgroupsColumn.h"
#include "HostSpecialIntColumn.h"
#include "HostSpecialDoubleColumn.h"
@@ -356,6 +357,9 @@ void TableHosts::addColumns(Table *table, string prefix, int
indirect_offset)
table->addColumn(new ServicelistColumn(prefix +
"services_with_fullstate",
"A list of all services including full state information. The list
of entries can grow in future versions.",
(char *)(&hst.services) - ref, indirect_offset, false, 3));
+
+ table->addColumn(new MetricsColumn(prefix + "metrics",
+ "A dummy column in order to be compatible with Check_MK
Multisite", indirect_offset));
}
void *TableHosts::findObject(char *objectspec)
diff --git a/livestatus/src/TableServices.cc b/livestatus/src/TableServices.cc
index 1a397c9..1c4d9e5 100644
--- a/livestatus/src/TableServices.cc
+++ b/livestatus/src/TableServices.cc
@@ -45,6 +45,7 @@
#include "CustomVarsColumn.h"
#include "ServicegroupsColumn.h"
#include "ContactgroupsColumn.h"
+#include "MetricsColumn.h"
#include "tables.h"
#include "auth.h"
#include "strutil.h"
@@ -409,6 +410,9 @@ void TableServices::addColumns(Table *table, string prefix, int
indirect_offset,
"A list of all service groups the service is in", (char
*)(&svc.servicegroups_ptr) - ref, indirect_offset));
table->addColumn(new ContactgroupsColumn(prefix + "contact_groups",
"A list of all contact groups this service is in", (char
*)(&svc.contact_groups) - ref, indirect_offset));
+
+ table->addColumn(new MetricsColumn(prefix + "metrics",
+ "A dummy column in order to be compatible with Check_MK
Multisite", indirect_offset));
}