Module: check_mk
Branch: master
Commit: d4b02251b9ab085d88c74087c00cd4f3f04757e5
URL:
http://git.mathias-kettner.de/git/?p=check_mk.git;a=commit;h=d4b02251b9ab08…
Author: Sven Panne <sp(a)mathias-kettner.de>
Date: Thu Jun 29 11:28:21 2017 +0200
Unbreak --with-nagios4 configuration.
Change-Id: I866b0971ec25c5274a72514ecf9d8af91cbcb0f4
---
livestatus/src/NagiosMockup.cc | 1 +
livestatus/src/TableHosts.cc | 24 ++++++++++++++----------
livestatus/src/TableServices.cc | 9 +++++----
livestatus/src/TableStatus.cc | 11 ++++++-----
livestatus/src/contact_fwd.h | 4 +++-
5 files changed, 29 insertions(+), 20 deletions(-)
diff --git a/livestatus/src/NagiosMockup.cc b/livestatus/src/NagiosMockup.cc
index fc9ccee..0304233 100644
--- a/livestatus/src/NagiosMockup.cc
+++ b/livestatus/src/NagiosMockup.cc
@@ -59,6 +59,7 @@ int neb_register_callback(int /*unused*/, void * /*unused*/, int
/*unused*/,
int obsess_over_hosts;
int obsess_over_services;
int process_performance_data;
+int process_external_command1(char * /*unused*/) { return 0; }
time_t program_start;
int rotate_log_file(time_t /*unused*/) { return 0; }
int schedule_new_event(int /*unused*/, int /*unused*/, time_t /*unused*/,
diff --git a/livestatus/src/TableHosts.cc b/livestatus/src/TableHosts.cc
index 4c1fc63..388b8b7 100644
--- a/livestatus/src/TableHosts.cc
+++ b/livestatus/src/TableHosts.cc
@@ -94,11 +94,13 @@ void TableHosts::addColumns(Table *table, MonitoringCore *mc,
table->addColumn(make_unique<OffsetStringColumn>(
prefix + "check_command",
"Nagios command for active host check of this host",
- (char *)(&hst.check_command) - ref, indirect_offset, extra_offset));
+ DANGEROUS_OFFSETOF(host, check_command), indirect_offset, extra_offset,
+ -1));
table->addColumn(make_unique<OffsetStringHostMacroColumn>(
prefix + "check_command_expanded",
"Nagios command for active host check of this host with the macros
expanded",
- (char *)(&hst.check_command) - ref, indirect_offset, extra_offset));
+ DANGEROUS_OFFSETOF(host, check_command), indirect_offset, extra_offset,
+ -1));
#else
table->addColumn(make_unique<OffsetStringColumn>(
prefix + "check_command",
@@ -220,11 +222,11 @@ void TableHosts::addColumns(Table *table, MonitoringCore *mc,
DANGEROUS_OFFSETOF(host, accept_passive_host_checks), indirect_offset,
extra_offset, -1));
#else
- table->addColumn(
- new OffsetIntColumn(prefix + "accept_passive_checks",
- "Whether passive host checks are accepted (0/1)",
- (char *)(&hst.accept_passive_checks) - ref,
- indirect_offset, extra_offset));
+ table->addColumn(make_unique<OffsetIntColumn>(
+ prefix + "accept_passive_checks",
+ "Whether passive host checks are accepted (0/1)",
+ DANGEROUS_OFFSETOF(host, accept_passive_checks), indirect_offset,
+ extra_offset, -1));
#endif // NAGIOS4
table->addColumn(make_unique<OffsetIntColumn>(
prefix + "event_handler_enabled",
@@ -267,11 +269,13 @@ void TableHosts::addColumns(Table *table, MonitoringCore *mc,
table->addColumn(make_unique<OffsetTimeColumn>(
prefix + "last_notification",
"Time of the last notification (Unix timestamp)",
- (char *)(&hst.last_notification) - ref, indirect_offset, extra_offset));
+ DANGEROUS_OFFSETOF(host, last_notification), indirect_offset,
+ extra_offset, -1));
table->addColumn(make_unique<OffsetTimeColumn>(
prefix + "next_notification",
"Time of the next notification (Unix timestamp)",
- (char *)(&hst.next_notification) - ref, indirect_offset, extra_offset));
+ DANGEROUS_OFFSETOF(host, next_notification), indirect_offset,
+ extra_offset, -1));
#endif // NAGIOS4
table->addColumn(make_unique<OffsetTimeColumn>(
prefix + "next_check",
@@ -398,7 +402,7 @@ void TableHosts::addColumns(Table *table, MonitoringCore *mc,
table->addColumn(make_unique<OffsetIntColumn>(
prefix + "obsess_over_host",
"The current obsess_over_host setting... (0/1)",
- (char *)(&hst.obsess) - ref, indirect_offset, extra_offset));
+ DANGEROUS_OFFSETOF(host, obsess), indirect_offset, extra_offset, -1));
#endif // NAGIOS4
table->addColumn(make_unique<AttributeListAsIntColumn>(
prefix + "modified_attributes",
diff --git a/livestatus/src/TableServices.cc b/livestatus/src/TableServices.cc
index 659e585..e82658f 100644
--- a/livestatus/src/TableServices.cc
+++ b/livestatus/src/TableServices.cc
@@ -93,11 +93,11 @@ void TableServices::addColumns(Table *table, MonitoringCore *mc,
#else
table->addColumn(make_unique<OffsetStringColumn>(
prefix + "check_command", "Nagios command used for active
checks",
- (char *)(&svc.check_command) - ref, indirect_offset));
+ DANGEROUS_OFFSETOF(service, check_command), indirect_offset, -1, -1));
table->addColumn(make_unique<OffsetStringServiceMacroColumn>(
prefix + "check_command_expanded",
"Nagios command used for active checks with the macros expanded",
- (char *)(&svc.check_command) - ref, indirect_offset));
+ DANGEROUS_OFFSETOF(service, check_command), indirect_offset, -1, -1));
#endif
table->addColumn(make_unique<OffsetStringColumn>(
prefix + "event_handler", "Nagios command used as event
handler",
@@ -284,7 +284,8 @@ void TableServices::addColumns(Table *table, MonitoringCore *mc,
table->addColumn(make_unique<OffsetIntColumn>(
prefix + "accept_passive_checks",
"Whether the service accepts passive checks (0/1)",
- (char *)(&svc.accept_passive_checks) - ref, indirect_offset));
+ DANGEROUS_OFFSETOF(service, accept_passive_checks), indirect_offset, -1,
+ -1));
#endif // NAGIOS4
table->addColumn(make_unique<OffsetIntColumn>(
prefix + "event_handler_enabled",
@@ -332,7 +333,7 @@ void TableServices::addColumns(Table *table, MonitoringCore *mc,
table->addColumn(make_unique<OffsetIntColumn>(
prefix + "obsess_over_service",
"Whether 'obsess_over_service' is enabled for the service
(0/1)",
- (char *)(&svc.obsess) - ref, indirect_offset));
+ DANGEROUS_OFFSETOF(service, obsess), indirect_offset, -1, -1));
#endif // NAGIOS4
table->addColumn(make_unique<AttributeListAsIntColumn>(
prefix + "modified_attributes",
diff --git a/livestatus/src/TableStatus.cc b/livestatus/src/TableStatus.cc
index d3a3873..2acd78c 100644
--- a/livestatus/src/TableStatus.cc
+++ b/livestatus/src/TableStatus.cc
@@ -74,7 +74,8 @@ extern int external_command_buffer_slots;
#else
// TODO: check if this data is available in nagios_squeue
namespace {
-time_t dummy = 0;
+time_t dummy_time = 0;
+int dummy_int = 0;
} // namespace
#endif // NAGIOS4
@@ -166,7 +167,7 @@ TableStatus::TableStatus(MonitoringCore *mc) : Table(mc) {
addColumn(make_unique<TimePointerColumn>(
"last_command_check",
"The time of the last check for a command as UNIX timestamp
(placeholder)",
- &dummy));
+ &dummy_time));
#endif // NAGIOS4
addColumn(make_unique<TimePointerColumn>(
"last_log_rotation", "Time time of the last log file
rotation",
@@ -202,15 +203,15 @@ TableStatus::TableStatus(MonitoringCore *mc) : Table(mc) {
addColumn(make_unique<IntPointerColumn>(
"external_command_buffer_slots",
"The size of the buffer for the external commands (placeholder)",
- &dummy));
+ &dummy_int));
addColumn(make_unique<IntPointerColumn>(
"external_command_buffer_usage",
"The number of slots in use of the external command buffer
(placeholder)",
- &dummy));
+ &dummy_int));
addColumn(make_unique<IntPointerColumn>(
"external_command_buffer_max",
"The maximum number of slots used in the external command buffer
(placeholder)",
- &dummy));
+ &dummy_int));
#endif // NAGIOS4
// Livestatus' own status
diff --git a/livestatus/src/contact_fwd.h b/livestatus/src/contact_fwd.h
index 0c977b6..3cf0d03 100644
--- a/livestatus/src/contact_fwd.h
+++ b/livestatus/src/contact_fwd.h
@@ -25,9 +25,11 @@
#ifndef contact_fwd_h
#define contact_fwd_h
-#ifdef CMC
+#if defined(CMC)
class Contact;
typedef Contact contact;
+#elif defined(NAGIOS4)
+typedef struct contact contact;
#else
typedef struct contact_struct contact;
#endif