Explicitly write the 1.x legacy attribute 'interval_length' for Livestatus

fixes #7402
This commit is contained in:
Michael Friedrich 2019-08-07 15:22:09 +02:00
parent 59081c4f82
commit 3f18741c41
5 changed files with 14 additions and 5 deletions

View File

@ -771,7 +771,7 @@ Value HostsTable::CheckIntervalAccessor(const Value& row)
if (!host)
return Empty;
return host->GetCheckInterval() / 60.0;
return host->GetCheckInterval() / LIVESTATUS_INTERVAL_LENGTH;
}
Value HostsTable::RetryIntervalAccessor(const Value& row)
@ -781,7 +781,7 @@ Value HostsTable::RetryIntervalAccessor(const Value& row)
if (!host)
return Empty;
return host->GetRetryInterval() / 60.0;
return host->GetRetryInterval() / LIVESTATUS_INTERVAL_LENGTH;
}
Value HostsTable::NotificationIntervalAccessor(const Value& row)

View File

@ -792,7 +792,7 @@ Value ServicesTable::CheckIntervalAccessor(const Value& row)
if (!service)
return Empty;
return service->GetCheckInterval() / 60.0;
return service->GetCheckInterval() / LIVESTATUS_INTERVAL_LENGTH;
}
Value ServicesTable::RetryIntervalAccessor(const Value& row)
@ -802,7 +802,7 @@ Value ServicesTable::RetryIntervalAccessor(const Value& row)
if (!service)
return Empty;
return service->GetRetryInterval() / 60.0;
return service->GetRetryInterval() / LIVESTATUS_INTERVAL_LENGTH;
}
Value ServicesTable::NotificationIntervalAccessor(const Value& row)

View File

@ -67,7 +67,7 @@ void StatusTable::AddColumns(Table *table, const String& prefix,
table->AddColumn(prefix + "program_start", Column(&StatusTable::ProgramStartAccessor, objectAccessor));
table->AddColumn(prefix + "last_command_check", Column(&Table::ZeroAccessor, objectAccessor));
table->AddColumn(prefix + "last_log_rotation", Column(&Table::ZeroAccessor, objectAccessor));
table->AddColumn(prefix + "interval_length", Column(&Table::ZeroAccessor, objectAccessor));
table->AddColumn(prefix + "interval_length", Column(&StatusTable::IntervalLengthAccessor, objectAccessor));
table->AddColumn(prefix + "num_hosts", Column(&StatusTable::NumHostsAccessor, objectAccessor));
table->AddColumn(prefix + "num_services", Column(&StatusTable::NumServicesAccessor, objectAccessor));
table->AddColumn(prefix + "program_version", Column(&StatusTable::ProgramVersionAccessor, objectAccessor));
@ -187,6 +187,11 @@ Value StatusTable::ProgramStartAccessor(const Value&)
return static_cast<long>(Application::GetStartTime());
}
Value StatusTable::IntervalLengthAccessor(const Value&)
{
return LIVESTATUS_INTERVAL_LENGTH;
}
Value StatusTable::NumHostsAccessor(const Value&)
{
return ConfigType::Get<Host>()->GetObjectCount();

View File

@ -45,6 +45,7 @@ protected:
static Value EnableFlapDetectionAccessor(const Value& row);
static Value ProcessPerformanceDataAccessor(const Value& row);
static Value ProgramStartAccessor(const Value& row);
static Value IntervalLengthAccessor(const Value& row);
static Value NumHostsAccessor(const Value& row);
static Value NumServicesAccessor(const Value& row);
static Value ProgramVersionAccessor(const Value& row);

View File

@ -12,6 +12,9 @@
namespace icinga
{
// Well, don't ask.
#define LIVESTATUS_INTERVAL_LENGTH 60.0
struct LivestatusRowValue {
Value Row;
LivestatusGroupByType GroupByType;