Skip to content
Permalink
Browse files

Pack offsest in Column::Offsets array (2)

Change-Id: I43b6d1424dc8445f87c6e693ce3a8fd8f38dea73
  • Loading branch information
Synss committed Nov 29, 2019
1 parent 14229dd commit a91f9cead30d71883017472f5f5718c756c5fe20
@@ -39,11 +39,7 @@ class RowRenderer;

class DoubleColumn : public Column {
public:
DoubleColumn(const std::string &name, const std::string &description,
int indirect_offset, int extra_offset, int extra_extra_offset,
int offset)
: Column(name, description, indirect_offset, extra_offset,
extra_extra_offset, offset) {}
using Column::Column;
[[nodiscard]] virtual double getValue(Row row) const = 0;
void output(Row row, RowRenderer &r, const contact *auth_user,
std::chrono::seconds timezone_offset) const override;
@@ -26,14 +26,14 @@
#define DoublePointerColumn_h

#include "config.h" // IWYU pragma: keep
#include "Column.h"
#include "DoubleColumn.h"

class DoublePointerColumn : public DoubleColumn {
public:
DoublePointerColumn(const std::string &name, const std::string &description,
const double *number)
: DoubleColumn(name, description, -1, -1, -1, 0), _number(number) {}

Column::Offsets offsets, const double *number)
: DoubleColumn(name, description, offsets), _number(number) {}
[[nodiscard]] double getValue(Row /*unused*/) const override {
return *_number;
}
@@ -27,6 +27,7 @@

#include "config.h" // IWYU pragma: keep
#include <string>
#include "Column.h"
#include "DoubleColumn.h"
class Row;

@@ -39,12 +40,9 @@ class HostSpecialDoubleColumn : public DoubleColumn {
enum class Type { staleness };

HostSpecialDoubleColumn(const std::string& name,
const std::string& description, int indirect,
int extra_offset, int extra_extra_offset,
int offset, Type hsdc_type)
: DoubleColumn(name, description, indirect, extra_offset,
extra_extra_offset, offset)
, _type(hsdc_type) {}
const std::string& description,
Column::Offsets offsets, Type hsdc_type)
: DoubleColumn(name, description, offsets), _type(hsdc_type) {}

[[nodiscard]] double getValue(Row row) const override;

@@ -26,17 +26,12 @@
#define OffsetDoubleColumn_h

#include "config.h" // IWYU pragma: keep
#include <string>
#include "DoubleColumn.h"
class Row;

class OffsetDoubleColumn : public DoubleColumn {
public:
OffsetDoubleColumn(const std::string& name, const std::string& description,
int indirect_offset, int extra_offset,
int extra_extra_offset, int offset)
: DoubleColumn(name, description, indirect_offset, extra_offset,
extra_extra_offset, offset) {}
using DoubleColumn::DoubleColumn;
[[nodiscard]] double getValue(Row row) const override;
};

@@ -27,6 +27,7 @@

#include "config.h" // IWYU pragma: keep
#include <string>
#include "Column.h"
#include "DoubleColumn.h"
class Row;

@@ -35,12 +36,9 @@ class ServiceSpecialDoubleColumn : public DoubleColumn {
enum class Type { staleness };

ServiceSpecialDoubleColumn(const std::string& name,
const std::string& description, int indirect,
int extra_offset, int extra_extra_offset,
int offset, Type ssdc_type)
: DoubleColumn(name, description, indirect, extra_offset,
extra_extra_offset, offset)
, _type(ssdc_type) {}
const std::string& description,
Column::Offsets offsets, Type ssdc_type)
: DoubleColumn(name, description, offsets), _type(ssdc_type) {}

[[nodiscard]] double getValue(Row row) const override;

@@ -394,50 +394,56 @@ void TableHosts::addColumns(Table *table, const std::string &prefix,
table->addColumn(std::make_unique<OffsetDoubleColumn>(
prefix + "check_interval",
"Number of basic interval lengths between two scheduled checks of the host",
indirect_offset, extra_offset, -1,
DANGEROUS_OFFSETOF(host, check_interval)));
Column::Offsets{indirect_offset, extra_offset, -1,
DANGEROUS_OFFSETOF(host, check_interval)}));
table->addColumn(std::make_unique<OffsetDoubleColumn>(
prefix + "retry_interval",
"Number of basic interval lengths between checks when retrying after a soft error",
indirect_offset, extra_offset, -1,
DANGEROUS_OFFSETOF(host, retry_interval)));
Column::Offsets{indirect_offset, extra_offset, -1,
DANGEROUS_OFFSETOF(host, retry_interval)}));
table->addColumn(std::make_unique<OffsetDoubleColumn>(
prefix + "notification_interval",
"Interval of periodic notification or 0 if its off", indirect_offset,
extra_offset, -1, DANGEROUS_OFFSETOF(host, notification_interval)));
"Interval of periodic notification or 0 if its off",
Column::Offsets{indirect_offset, extra_offset, -1,
DANGEROUS_OFFSETOF(host, notification_interval)}));
table->addColumn(std::make_unique<OffsetDoubleColumn>(
prefix + "first_notification_delay",
"Delay before the first notification", indirect_offset, extra_offset,
-1, DANGEROUS_OFFSETOF(host, first_notification_delay)));
"Delay before the first notification",
Column::Offsets{indirect_offset, extra_offset, -1,
DANGEROUS_OFFSETOF(host, first_notification_delay)}));
table->addColumn(std::make_unique<OffsetDoubleColumn>(
prefix + "low_flap_threshold", "Low threshold of flap detection",
indirect_offset, extra_offset, -1,
DANGEROUS_OFFSETOF(host, low_flap_threshold)));
Column::Offsets{indirect_offset, extra_offset, -1,
DANGEROUS_OFFSETOF(host, low_flap_threshold)}));
table->addColumn(std::make_unique<OffsetDoubleColumn>(
prefix + "high_flap_threshold", "High threshold of flap detection",
indirect_offset, extra_offset, -1,
DANGEROUS_OFFSETOF(host, high_flap_threshold)));
Column::Offsets{indirect_offset, extra_offset, -1,
DANGEROUS_OFFSETOF(host, high_flap_threshold)}));
table->addColumn(std::make_unique<OffsetDoubleColumn>(
prefix + "x_3d", "3D-Coordinates: X", indirect_offset, extra_offset, -1,
DANGEROUS_OFFSETOF(host, x_3d)));
prefix + "x_3d", "3D-Coordinates: X",
Column::Offsets{indirect_offset, extra_offset, -1,
DANGEROUS_OFFSETOF(host, x_3d)}));
table->addColumn(std::make_unique<OffsetDoubleColumn>(
prefix + "y_3d", "3D-Coordinates: Y", indirect_offset, extra_offset, -1,
DANGEROUS_OFFSETOF(host, y_3d)));
prefix + "y_3d", "3D-Coordinates: Y",
Column::Offsets{indirect_offset, extra_offset, -1,
DANGEROUS_OFFSETOF(host, y_3d)}));
table->addColumn(std::make_unique<OffsetDoubleColumn>(
prefix + "z_3d", "3D-Coordinates: Z", indirect_offset, extra_offset, -1,
DANGEROUS_OFFSETOF(host, z_3d)));
prefix + "z_3d", "3D-Coordinates: Z",
Column::Offsets{indirect_offset, extra_offset, -1,
DANGEROUS_OFFSETOF(host, z_3d)}));
table->addColumn(std::make_unique<OffsetDoubleColumn>(
prefix + "latency",
"Time difference between scheduled check time and actual check time",
indirect_offset, extra_offset, -1, DANGEROUS_OFFSETOF(host, latency)));
Column::Offsets{indirect_offset, extra_offset, -1,
DANGEROUS_OFFSETOF(host, latency)}));
table->addColumn(std::make_unique<OffsetDoubleColumn>(
prefix + "execution_time", "Time the host check needed for execution",
indirect_offset, extra_offset, -1,
DANGEROUS_OFFSETOF(host, execution_time)));
Column::Offsets{indirect_offset, extra_offset, -1,
DANGEROUS_OFFSETOF(host, execution_time)}));
table->addColumn(std::make_unique<OffsetDoubleColumn>(
prefix + "percent_state_change", "Percent state change",
indirect_offset, extra_offset, -1,
DANGEROUS_OFFSETOF(host, percent_state_change)));
Column::Offsets{indirect_offset, extra_offset, -1,
DANGEROUS_OFFSETOF(host, percent_state_change)}));

table->addColumn(std::make_unique<TimeperiodColumn>(
prefix + "in_notification_period",
@@ -713,7 +719,7 @@ void TableHosts::addColumns(Table *table, const std::string &prefix,

table->addColumn(std::make_unique<HostSpecialDoubleColumn>(
prefix + "staleness", "Staleness indicator for this host",
indirect_offset, extra_offset, -1, 0,
Column::Offsets{indirect_offset, extra_offset, -1, 0},
HostSpecialDoubleColumn::Type::staleness));

table->addColumn(std::make_unique<HostGroupsColumn>(
@@ -357,46 +357,53 @@ void TableServices::addColumns(Table *table, const std::string &prefix,
ServiceSpecialIntColumn::Type::pnp_graph_present));
table->addColumn(std::make_unique<ServiceSpecialDoubleColumn>(
prefix + "staleness", "The staleness indicator for this service",
indirect_offset, -1, -1, 0,
Column::Offsets{indirect_offset, -1, -1, 0},
ServiceSpecialDoubleColumn::Type::staleness));

// columns of type double
table->addColumn(std::make_unique<OffsetDoubleColumn>(
prefix + "check_interval",
"Number of basic interval lengths between two scheduled checks of the service",
indirect_offset, -1, -1, DANGEROUS_OFFSETOF(service, check_interval)));
Column::Offsets{indirect_offset, -1, -1,
DANGEROUS_OFFSETOF(service, check_interval)}));
table->addColumn(std::make_unique<OffsetDoubleColumn>(
prefix + "retry_interval",
"Number of basic interval lengths between checks when retrying after a soft error",
indirect_offset, -1, -1, DANGEROUS_OFFSETOF(service, retry_interval)));
Column::Offsets{indirect_offset, -1, -1,
DANGEROUS_OFFSETOF(service, retry_interval)}));
table->addColumn(std::make_unique<OffsetDoubleColumn>(
prefix + "notification_interval",
"Interval of periodic notification or 0 if its off", indirect_offset,
-1, -1, DANGEROUS_OFFSETOF(service, notification_interval)));
"Interval of periodic notification or 0 if its off",
Column::Offsets{indirect_offset, -1, -1,
DANGEROUS_OFFSETOF(service, notification_interval)}));
table->addColumn(std::make_unique<OffsetDoubleColumn>(
prefix + "first_notification_delay",
"Delay before the first notification", indirect_offset, -1, -1,
DANGEROUS_OFFSETOF(service, first_notification_delay)));
"Delay before the first notification",
Column::Offsets{
indirect_offset, -1, -1,
DANGEROUS_OFFSETOF(service, first_notification_delay)}));
table->addColumn(std::make_unique<OffsetDoubleColumn>(
prefix + "low_flap_threshold", "Low threshold of flap detection",
indirect_offset, -1, -1,
DANGEROUS_OFFSETOF(service, low_flap_threshold)));
Column::Offsets{indirect_offset, -1, -1,
DANGEROUS_OFFSETOF(service, low_flap_threshold)}));
table->addColumn(std::make_unique<OffsetDoubleColumn>(
prefix + "high_flap_threshold", "High threshold of flap detection",
indirect_offset, -1, -1,
DANGEROUS_OFFSETOF(service, high_flap_threshold)));
Column::Offsets{indirect_offset, -1, -1,
DANGEROUS_OFFSETOF(service, high_flap_threshold)}));
table->addColumn(std::make_unique<OffsetDoubleColumn>(
prefix + "latency",
"Time difference between scheduled check time and actual check time",
indirect_offset, -1, -1, DANGEROUS_OFFSETOF(service, latency)));
Column::Offsets{indirect_offset, -1, -1,
DANGEROUS_OFFSETOF(service, latency)}));
table->addColumn(std::make_unique<OffsetDoubleColumn>(
prefix + "execution_time",
"Time the service check needed for execution", indirect_offset, -1, -1,
DANGEROUS_OFFSETOF(service, execution_time)));
"Time the service check needed for execution",
Column::Offsets{indirect_offset, -1, -1,
DANGEROUS_OFFSETOF(service, execution_time)}));
table->addColumn(std::make_unique<OffsetDoubleColumn>(
prefix + "percent_state_change", "Percent state change",
indirect_offset, -1, -1,
DANGEROUS_OFFSETOF(service, percent_state_change)));
Column::Offsets{indirect_offset, -1, -1,
DANGEROUS_OFFSETOF(service, percent_state_change)}));

table->addColumn(std::make_unique<TimeperiodColumn>(
prefix + "in_check_period",
@@ -433,15 +440,18 @@ void TableServices::addColumns(Table *table, const std::string &prefix,
DowntimeColumn::info::full));
table->addColumn(std::make_unique<CommentColumn>(
prefix + "comments", "A list of all comment ids of the service",
indirect_offset, -1, -1, 0, table->core(), true, false, false));
Column::Offsets{indirect_offset, -1, -1, 0}, table->core(), true, false,
false));
table->addColumn(std::make_unique<CommentColumn>(
prefix + "comments_with_info",
"A list of all comments of the service with id, author and comment",
indirect_offset, -1, -1, 0, table->core(), true, true, false));
Column::Offsets{indirect_offset, -1, -1, 0}, table->core(), true, true,
false));
table->addColumn(std::make_unique<CommentColumn>(
prefix + "comments_with_extra_info",
"A list of all comments of the service with id, author, comment, entry type and entry time",
indirect_offset, -1, -1, 0, table->core(), true, true, true));
Column::Offsets{indirect_offset, -1, -1, 0}, table->core(), true, true,
true));

if (add_hosts) {
TableHosts::addColumns(table, "host_",
@@ -108,8 +108,9 @@ TableStateHistory::TableStateHistory(MonitoringCore *mc, LogCache *log_cache)
"duration", "Duration of state (until - from)", -1, -1, -1,
DANGEROUS_OFFSETOF(HostServiceState, _duration)));
addColumn(std::make_unique<OffsetDoubleColumn>(
"duration_part", "Duration part in regard to the query timeframe", -1,
-1, -1, DANGEROUS_OFFSETOF(HostServiceState, _duration_part)));
"duration_part", "Duration part in regard to the query timeframe",
Column::Offsets{-1, -1, -1,
DANGEROUS_OFFSETOF(HostServiceState, _duration_part)}));
addColumn(std::make_unique<OffsetIntColumn>(
"state",
"The state of the host or service in question - OK(0) / WARNING(1) / CRITICAL(2) / UNKNOWN(3) / UNMONITORED(-1)",
@@ -163,40 +164,50 @@ TableStateHistory::TableStateHistory(MonitoringCore *mc, LogCache *log_cache)
DANGEROUS_OFFSETOF(HostServiceState, _duration_ok)));
addColumn(std::make_unique<OffsetDoubleColumn>(
"duration_part_ok", "OK duration part in regard to the query timeframe",
-1, -1, -1, DANGEROUS_OFFSETOF(HostServiceState, _duration_part_ok)));
Column::Offsets{
-1, -1, -1,
DANGEROUS_OFFSETOF(HostServiceState, _duration_part_ok)}));

addColumn(std::make_unique<OffsetIntColumn>(
"duration_warning", "WARNING duration of state (until - from)", -1, -1,
-1, DANGEROUS_OFFSETOF(HostServiceState, _duration_warning)));
addColumn(std::make_unique<OffsetDoubleColumn>(
"duration_part_warning",
"WARNING duration part in regard to the query timeframe", -1, -1, -1,
DANGEROUS_OFFSETOF(HostServiceState, _duration_part_warning)));
"WARNING duration part in regard to the query timeframe",
Column::Offsets{
-1, -1, -1,
DANGEROUS_OFFSETOF(HostServiceState, _duration_part_warning)}));

addColumn(std::make_unique<OffsetIntColumn>(
"duration_critical", "CRITICAL duration of state (until - from)", -1,
-1, -1, DANGEROUS_OFFSETOF(HostServiceState, _duration_critical)));
addColumn(std::make_unique<OffsetDoubleColumn>(
"duration_part_critical",
"CRITICAL duration part in regard to the query timeframe", -1, -1, -1,
DANGEROUS_OFFSETOF(HostServiceState, _duration_part_critical)));
"CRITICAL duration part in regard to the query timeframe",
Column::Offsets{
-1, -1, -1,
DANGEROUS_OFFSETOF(HostServiceState, _duration_part_critical)}));

addColumn(std::make_unique<OffsetIntColumn>(
"duration_unknown", "UNKNOWN duration of state (until - from)", -1, -1,
-1, DANGEROUS_OFFSETOF(HostServiceState, _duration_unknown)));
addColumn(std::make_unique<OffsetDoubleColumn>(
"duration_part_unknown",
"UNKNOWN duration part in regard to the query timeframe", -1, -1, -1,
DANGEROUS_OFFSETOF(HostServiceState, _duration_part_unknown)));
"UNKNOWN duration part in regard to the query timeframe",
Column::Offsets{
-1, -1, -1,
DANGEROUS_OFFSETOF(HostServiceState, _duration_part_unknown)}));

addColumn(std::make_unique<OffsetIntColumn>(
"duration_unmonitored", "UNMONITORED duration of state (until - from)",
-1, -1, -1,
DANGEROUS_OFFSETOF(HostServiceState, _duration_unmonitored)));
addColumn(std::make_unique<OffsetDoubleColumn>(
"duration_part_unmonitored",
"UNMONITORED duration part in regard to the query timeframe", -1, -1,
-1, DANGEROUS_OFFSETOF(HostServiceState, _duration_part_unmonitored)));
"UNMONITORED duration part in regard to the query timeframe",
Column::Offsets{
-1, -1, -1,
DANGEROUS_OFFSETOF(HostServiceState, _duration_part_unmonitored)}));

// join host and service tables
TableHosts::addColumns(this, "current_host_",

0 comments on commit a91f9ce

Please sign in to comment.
You can’t perform that action at this time.