mirror of https://github.com/Icinga/icinga2.git
Refactor CompatUtility::* for DB IDO, Livestatus, StatusData.
Fixes #5241
This commit is contained in:
parent
947b6f3207
commit
66765311c3
|
@ -98,10 +98,8 @@ void CompatLogger::CheckResultHandler(const Service::Ptr& service, const CheckRe
|
||||||
}
|
}
|
||||||
|
|
||||||
String output;
|
String output;
|
||||||
if (cr) {
|
if (cr)
|
||||||
std::pair<String, String> output_bag = CompatUtility::GetCheckResultOutput(cr);
|
output = CompatUtility::GetCheckResultOutput(cr);
|
||||||
output = output_bag.first;
|
|
||||||
}
|
|
||||||
|
|
||||||
std::ostringstream msgbuf;
|
std::ostringstream msgbuf;
|
||||||
msgbuf << "SERVICE ALERT: "
|
msgbuf << "SERVICE ALERT: "
|
||||||
|
@ -258,10 +256,8 @@ void CompatLogger::NotificationSentHandler(const Service::Ptr& service, const Us
|
||||||
return;
|
return;
|
||||||
|
|
||||||
String output;
|
String output;
|
||||||
if (cr) {
|
if (cr)
|
||||||
std::pair<String, String> output_bag = CompatUtility::GetCheckResultOutput(cr);
|
output = CompatUtility::GetCheckResultOutput(cr);
|
||||||
output = output_bag.first;
|
|
||||||
}
|
|
||||||
|
|
||||||
std::ostringstream msgbuf;
|
std::ostringstream msgbuf;
|
||||||
msgbuf << "SERVICE NOTIFICATION: "
|
msgbuf << "SERVICE NOTIFICATION: "
|
||||||
|
@ -489,10 +485,8 @@ void CompatLogger::ReopenFile(bool rotate)
|
||||||
String output;
|
String output;
|
||||||
CheckResult::Ptr cr = hc->GetLastCheckResult();
|
CheckResult::Ptr cr = hc->GetLastCheckResult();
|
||||||
|
|
||||||
if (cr) {
|
if (cr)
|
||||||
std::pair<String, String> output_bag = CompatUtility::GetCheckResultOutput(cr);
|
output = CompatUtility::GetCheckResultOutput(cr);
|
||||||
output = output_bag.first;
|
|
||||||
}
|
|
||||||
|
|
||||||
std::ostringstream msgbuf;
|
std::ostringstream msgbuf;
|
||||||
msgbuf << "CURRENT HOST STATE: "
|
msgbuf << "CURRENT HOST STATE: "
|
||||||
|
@ -511,10 +505,8 @@ void CompatLogger::ReopenFile(bool rotate)
|
||||||
String output;
|
String output;
|
||||||
CheckResult::Ptr cr = service->GetLastCheckResult();
|
CheckResult::Ptr cr = service->GetLastCheckResult();
|
||||||
|
|
||||||
if (cr) {
|
if (cr)
|
||||||
std::pair<String, String> output_bag = CompatUtility::GetCheckResultOutput(cr);
|
output = CompatUtility::GetCheckResultOutput(cr);
|
||||||
output = output_bag.first;
|
|
||||||
}
|
|
||||||
|
|
||||||
std::ostringstream msgbuf;
|
std::ostringstream msgbuf;
|
||||||
msgbuf << "CURRENT SERVICE STATE: "
|
msgbuf << "CURRENT SERVICE STATE: "
|
||||||
|
|
|
@ -232,14 +232,15 @@ void StatusDataWriter::DumpHostObject(std::ostream& fp, const Host::Ptr& host)
|
||||||
fp << "define host {" << "\n"
|
fp << "define host {" << "\n"
|
||||||
<< "\t" << "host_name" << "\t" << host->GetName() << "\n"
|
<< "\t" << "host_name" << "\t" << host->GetName() << "\n"
|
||||||
<< "\t" << "display_name" << "\t" << host->GetDisplayName() << "\n"
|
<< "\t" << "display_name" << "\t" << host->GetDisplayName() << "\n"
|
||||||
<< "\t" << "alias" << "\t" << host->GetDisplayName() << "\n";
|
<< "\t" << "alias" << "\t" << host->GetDisplayName() << "\n"
|
||||||
|
<< "\t" << "address" << "\t" << CompatUtility::GetHostAddress(host) << "\n"
|
||||||
Dictionary::Ptr macros = host->GetMacros();
|
<< "\t" << "address6" << "\t" << CompatUtility::GetHostAddress6(host) << "\n"
|
||||||
|
<< "\t" << "notes" << "\t" << CompatUtility::GetCustomAttributeConfig(host, "notes") << "\n"
|
||||||
if (macros) {
|
<< "\t" << "notes_url" << "\t" << CompatUtility::GetCustomAttributeConfig(host, "notes_url") << "\n"
|
||||||
fp << "\t" << "address" << "\t" << macros->Get("address") << "\n"
|
<< "\t" << "action_url" << "\t" << CompatUtility::GetCustomAttributeConfig(host, "action_url") << "\n"
|
||||||
<< "\t" << "address6" << "\t" << macros->Get("address6") << "\n";
|
<< "\t" << "icon_image" << "\t" << CompatUtility::GetCustomAttributeConfig(host, "icon_image") << "\n"
|
||||||
}
|
<< "\t" << "icon_image_alt" << "\t" << CompatUtility::GetCustomAttributeConfig(host, "icon_image_alt") << "\n"
|
||||||
|
<< "\t" << "statusmap_image" << "\t" << CompatUtility::GetCustomAttributeConfig(host, "statusmap_image") << "\n";
|
||||||
|
|
||||||
std::set<Host::Ptr> parents = host->GetParentHosts();
|
std::set<Host::Ptr> parents = host->GetParentHosts();
|
||||||
|
|
||||||
|
@ -253,14 +254,14 @@ void StatusDataWriter::DumpHostObject(std::ostream& fp, const Host::Ptr& host)
|
||||||
if (hc) {
|
if (hc) {
|
||||||
ObjectLock olock(hc);
|
ObjectLock olock(hc);
|
||||||
|
|
||||||
fp << "\t" << "check_interval" << "\t" << hc->GetCheckInterval() / 60.0 << "\n"
|
fp << "\t" << "check_interval" << "\t" << CompatUtility::GetServiceCheckInterval(hc) << "\n"
|
||||||
<< "\t" << "retry_interval" << "\t" << hc->GetRetryInterval() / 60.0 << "\n"
|
<< "\t" << "retry_interval" << "\t" << CompatUtility::GetServiceRetryInterval(hc) << "\n"
|
||||||
<< "\t" << "max_check_attempts" << "\t" << hc->GetMaxCheckAttempts() << "\n"
|
<< "\t" << "max_check_attempts" << "\t" << hc->GetMaxCheckAttempts() << "\n"
|
||||||
<< "\t" << "active_checks_enabled" << "\t" << (hc->GetEnableActiveChecks() ? 1 : 0) << "\n"
|
<< "\t" << "active_checks_enabled" << "\t" << (hc->GetEnableActiveChecks() ? 1 : 0) << "\n"
|
||||||
<< "\t" << "passive_checks_enabled" << "\t" << (hc->GetEnablePassiveChecks() ? 1 : 0) << "\n"
|
<< "\t" << "passive_checks_enabled" << "\t" << (hc->GetEnablePassiveChecks() ? 1 : 0) << "\n"
|
||||||
<< "\t" << "notifications_enabled" << "\t" << (hc->GetEnableNotifications() ? 1 : 0) << "\n"
|
<< "\t" << "notifications_enabled" << "\t" << (hc->GetEnableNotifications() ? 1 : 0) << "\n"
|
||||||
<< "\t" << "notification_options" << "\t" << "d,u,r" << "\n"
|
<< "\t" << "notification_options" << "\t" << "d,u,r" << "\n"
|
||||||
<< "\t" << "notification_interval" << "\t" << 1 << "\n"
|
<< "\t" << "notification_interval" << "\t" << CompatUtility::GetServiceNotificationNotificationInterval(hc) << "\n"
|
||||||
<< "\t" << "event_handler_enabled" << "\t" << (hc->GetEnableEventHandler() ? 1 : 0) << "\n";
|
<< "\t" << "event_handler_enabled" << "\t" << (hc->GetEnableEventHandler() ? 1 : 0) << "\n";
|
||||||
|
|
||||||
CheckCommand::Ptr checkcommand = hc->GetCheckCommand();
|
CheckCommand::Ptr checkcommand = hc->GetCheckCommand();
|
||||||
|
@ -271,9 +272,7 @@ void StatusDataWriter::DumpHostObject(std::ostream& fp, const Host::Ptr& host)
|
||||||
if (eventcommand)
|
if (eventcommand)
|
||||||
fp << "\t" << "event_handler" << "\t" << "event_" << eventcommand->GetName() << "\n";
|
fp << "\t" << "event_handler" << "\t" << "event_" << eventcommand->GetName() << "\n";
|
||||||
|
|
||||||
TimePeriod::Ptr check_period = hc->GetCheckPeriod();
|
fp << "\t" << "check_period" << "\t" << CompatUtility::GetServiceCheckPeriod(hc) << "\n";
|
||||||
if (check_period)
|
|
||||||
fp << "\t" << "check_period" << "\t" << check_period->GetName() << "\n";
|
|
||||||
|
|
||||||
fp << "\t" << "contacts" << "\t";
|
fp << "\t" << "contacts" << "\t";
|
||||||
DumpNameList(fp, CompatUtility::GetServiceNotificationUsers(hc));
|
DumpNameList(fp, CompatUtility::GetServiceNotificationUsers(hc));
|
||||||
|
@ -331,48 +330,56 @@ void StatusDataWriter::DumpHostObject(std::ostream& fp, const Host::Ptr& host)
|
||||||
|
|
||||||
void StatusDataWriter::DumpServiceStatusAttrs(std::ostream& fp, const Service::Ptr& service, CompatObjectType type)
|
void StatusDataWriter::DumpServiceStatusAttrs(std::ostream& fp, const Service::Ptr& service, CompatObjectType type)
|
||||||
{
|
{
|
||||||
Dictionary::Ptr attrs = CompatUtility::GetServiceStatusAttributes(service, type);
|
CheckResult::Ptr cr = service->GetLastCheckResult();
|
||||||
|
|
||||||
fp << "\t" << "check_command=" << attrs->Get("check_command") << "\n"
|
fp << "\t" << "check_command=check_" << CompatUtility::GetServiceCheckCommand(service) << "\n"
|
||||||
<< "\t" << "event_handler=" << attrs->Get("event_handler") << "\n"
|
<< "\t" << "event_handler=event_" << CompatUtility::GetServiceEventHandler(service) << "\n"
|
||||||
<< "\t" << "check_period=" << attrs->Get("check_period") << "\n"
|
<< "\t" << "check_period=" << CompatUtility::GetServiceCheckPeriod(service) << "\n"
|
||||||
<< "\t" << "check_interval=" << static_cast<double>(attrs->Get("check_interval")) << "\n"
|
<< "\t" << "check_interval=" << CompatUtility::GetServiceCheckInterval(service) << "\n"
|
||||||
<< "\t" << "retry_interval=" << static_cast<double>(attrs->Get("retry_interval")) << "\n"
|
<< "\t" << "retry_interval=" << CompatUtility::GetServiceRetryInterval(service) << "\n"
|
||||||
<< "\t" << "has_been_checked=" << attrs->Get("has_been_checked") << "\n"
|
<< "\t" << "has_been_checked=" << CompatUtility::GetServiceHasBeenChecked(service) << "\n"
|
||||||
<< "\t" << "should_be_scheduled=" << attrs->Get("should_be_scheduled") << "\n"
|
<< "\t" << "should_be_scheduled=" << CompatUtility::GetServiceShouldBeScheduled(service) << "\n";
|
||||||
<< "\t" << "check_execution_time=" << static_cast<double>(attrs->Get("check_execution_time")) << "\n"
|
|
||||||
<< "\t" << "check_latency=" << static_cast<double>(attrs->Get("check_latency")) << "\n"
|
if (cr) {
|
||||||
<< "\t" << "current_state=" << attrs->Get("current_state") << "\n"
|
fp << "\t" << "check_execution_time=" << static_cast<double>(Service::CalculateExecutionTime(cr)) << "\n"
|
||||||
<< "\t" << "state_type=" << attrs->Get("state_type") << "\n"
|
<< "\t" << "check_latency=" << static_cast<double>(Service::CalculateLatency(cr)) << "\n";
|
||||||
<< "\t" << "plugin_output=" << attrs->Get("plugin_output") << "\n"
|
}
|
||||||
<< "\t" << "long_plugin_output=" << attrs->Get("long_plugin_output") << "\n"
|
|
||||||
<< "\t" << "performance_data=" << attrs->Get("performance_data") << "\n"
|
fp << "\t" << "current_state=" << CompatUtility::GetServiceCurrentState(service) << "\n"
|
||||||
<< "\t" << "check_source=" << attrs->Get("check_source") << "\n"
|
<< "\t" << "state_type=" << service->GetStateType() << "\n"
|
||||||
<< "\t" << "last_check=" << static_cast<long>(attrs->Get("last_check")) << "\n"
|
<< "\t" << "plugin_output=" << CompatUtility::GetCheckResultOutput(cr) << "\n"
|
||||||
<< "\t" << "next_check=" << static_cast<long>(attrs->Get("next_check")) << "\n"
|
<< "\t" << "long_plugin_output=" << CompatUtility::GetCheckResultLongOutput(cr) << "\n"
|
||||||
<< "\t" << "current_attempt=" << attrs->Get("current_attempt") << "\n"
|
<< "\t" << "performance_data=" << CompatUtility::GetCheckResultPerfdata(cr) << "\n";
|
||||||
<< "\t" << "max_attempts=" << attrs->Get("max_attempts") << "\n"
|
|
||||||
<< "\t" << "last_state_change=" << static_cast<long>(attrs->Get("last_state_change")) << "\n"
|
if (cr) {
|
||||||
<< "\t" << "last_hard_state_change=" << static_cast<long>(attrs->Get("last_hard_state_change")) << "\n"
|
fp << "\t" << "check_source=" << cr->GetCheckSource() << "\n"
|
||||||
<< "\t" << "last_time_ok=" << static_cast<long>(attrs->Get("last_time_ok")) << "\n"
|
<< "\t" << "last_check=" << static_cast<long>(cr->GetScheduleEnd()) << "\n";
|
||||||
<< "\t" << "last_time_warn=" << static_cast<long>(attrs->Get("last_time_warn")) << "\n"
|
}
|
||||||
<< "\t" << "last_time_critical=" << static_cast<long>(attrs->Get("last_time_critical")) << "\n"
|
|
||||||
<< "\t" << "last_time_unknown=" << static_cast<long>(attrs->Get("last_time_unknown")) << "\n"
|
fp << "\t" << "next_check=" << static_cast<long>(service->GetNextCheck()) << "\n"
|
||||||
<< "\t" << "last_update=" << static_cast<long>(attrs->Get("last_update")) << "\n"
|
<< "\t" << "current_attempt=" << service->GetCheckAttempt() << "\n"
|
||||||
<< "\t" << "notifications_enabled=" << attrs->Get("notifications_enabled") << "\n"
|
<< "\t" << "max_attempts=" << service->GetMaxCheckAttempts() << "\n"
|
||||||
<< "\t" << "active_checks_enabled=" << attrs->Get("active_checks_enabled") << "\n"
|
<< "\t" << "last_state_change=" << static_cast<long>(service->GetLastStateChange()) << "\n"
|
||||||
<< "\t" << "passive_checks_enabled=" << attrs->Get("passive_checks_enabled") << "\n"
|
<< "\t" << "last_hard_state_change=" << static_cast<long>(service->GetLastHardStateChange()) << "\n"
|
||||||
<< "\t" << "flap_detection_enabled=" << attrs->Get("flap_detection_enabled") << "\n"
|
<< "\t" << "last_time_ok=" << static_cast<int>(service->GetLastStateOK()) << "\n"
|
||||||
<< "\t" << "is_flapping=" << attrs->Get("is_flapping") << "\n"
|
<< "\t" << "last_time_warn=" << static_cast<int>(service->GetLastStateWarning()) << "\n"
|
||||||
<< "\t" << "percent_state_change=" << attrs->Get("percent_state_change") << "\n"
|
<< "\t" << "last_time_critical=" << static_cast<int>(service->GetLastStateCritical()) << "\n"
|
||||||
<< "\t" << "problem_has_been_acknowledged=" << attrs->Get("problem_has_been_acknowledged") << "\n"
|
<< "\t" << "last_time_unknown=" << static_cast<int>(service->GetLastStateUnknown()) << "\n"
|
||||||
<< "\t" << "acknowledgement_type=" << attrs->Get("acknowledgement_type") << "\n"
|
<< "\t" << "last_update=" << static_cast<long>(time(NULL)) << "\n"
|
||||||
<< "\t" << "acknowledgement_end_time=" << attrs->Get("acknowledgement_end_time") << "\n"
|
<< "\t" << "notifications_enabled=" << CompatUtility::GetServiceNotificationsEnabled(service) << "\n"
|
||||||
<< "\t" << "scheduled_downtime_depth=" << attrs->Get("scheduled_downtime_depth") << "\n"
|
<< "\t" << "active_checks_enabled=" << CompatUtility::GetServiceActiveChecksEnabled(service) << "\n"
|
||||||
<< "\t" << "last_notification=" << static_cast<long>(attrs->Get("last_notification")) << "\n"
|
<< "\t" << "passive_checks_enabled=" << CompatUtility::GetServicePassiveChecksEnabled(service) << "\n"
|
||||||
<< "\t" << "next_notification=" << static_cast<long>(attrs->Get("next_notification")) << "\n"
|
<< "\t" << "flap_detection_enabled=" << CompatUtility::GetServiceFlapDetectionEnabled(service) << "\n"
|
||||||
<< "\t" << "current_notification_number=" << attrs->Get("current_notification_number") << "\n"
|
<< "\t" << "is_flapping=" << CompatUtility::GetServiceIsFlapping(service) << "\n"
|
||||||
<< "\t" << "modified_attributes=" << attrs->Get("modified_attributes") << "\n";
|
<< "\t" << "percent_state_change=" << CompatUtility::GetServicePercentStateChange(service) << "\n"
|
||||||
|
<< "\t" << "problem_has_been_acknowledged=" << CompatUtility::GetServiceProblemHasBeenAcknowledged(service) << "\n"
|
||||||
|
<< "\t" << "acknowledgement_type=" << CompatUtility::GetServiceAcknowledgementType(service) << "\n"
|
||||||
|
<< "\t" << "acknowledgement_end_time=" << service->GetAcknowledgementExpiry() << "\n"
|
||||||
|
<< "\t" << "scheduled_downtime_depth=" << service->GetDowntimeDepth() << "\n"
|
||||||
|
<< "\t" << "last_notification=" << CompatUtility::GetServiceNotificationLastNotification(service) << "\n"
|
||||||
|
<< "\t" << "next_notification=" << CompatUtility::GetServiceNotificationNextNotification(service) << "\n"
|
||||||
|
<< "\t" << "current_notification_number=" << CompatUtility::GetServiceNotificationNotificationNumber(service) << "\n"
|
||||||
|
<< "\t" << "modified_attributes=" << service->GetModifiedAttributes() << "\n";
|
||||||
}
|
}
|
||||||
|
|
||||||
void StatusDataWriter::DumpServiceStatus(std::ostream& fp, const Service::Ptr& service)
|
void StatusDataWriter::DumpServiceStatus(std::ostream& fp, const Service::Ptr& service)
|
||||||
|
@ -399,22 +406,6 @@ void StatusDataWriter::DumpServiceObject(std::ostream& fp, const Service::Ptr& s
|
||||||
{
|
{
|
||||||
Host::Ptr host = service->GetHost();
|
Host::Ptr host = service->GetHost();
|
||||||
|
|
||||||
String check_period_str;
|
|
||||||
TimePeriod::Ptr check_period = service->GetCheckPeriod();
|
|
||||||
if (check_period)
|
|
||||||
check_period_str = check_period->GetName();
|
|
||||||
else
|
|
||||||
check_period_str = "24x7";
|
|
||||||
|
|
||||||
double notification_interval = -1;
|
|
||||||
BOOST_FOREACH(const Notification::Ptr& notification, service->GetNotifications()) {
|
|
||||||
if (notification_interval == -1 || notification->GetNotificationInterval() < notification_interval)
|
|
||||||
notification_interval = notification->GetNotificationInterval();
|
|
||||||
}
|
|
||||||
|
|
||||||
if (notification_interval == -1)
|
|
||||||
notification_interval = 60;
|
|
||||||
|
|
||||||
{
|
{
|
||||||
ObjectLock olock(service);
|
ObjectLock olock(service);
|
||||||
|
|
||||||
|
@ -422,17 +413,18 @@ void StatusDataWriter::DumpServiceObject(std::ostream& fp, const Service::Ptr& s
|
||||||
<< "\t" << "host_name" << "\t" << host->GetName() << "\n"
|
<< "\t" << "host_name" << "\t" << host->GetName() << "\n"
|
||||||
<< "\t" << "service_description" << "\t" << service->GetShortName() << "\n"
|
<< "\t" << "service_description" << "\t" << service->GetShortName() << "\n"
|
||||||
<< "\t" << "display_name" << "\t" << service->GetDisplayName() << "\n"
|
<< "\t" << "display_name" << "\t" << service->GetDisplayName() << "\n"
|
||||||
<< "\t" << "check_period" << "\t" << check_period_str << "\n"
|
<< "\t" << "check_period" << "\t" << CompatUtility::GetServiceCheckPeriod(service) << "\n"
|
||||||
<< "\t" << "check_interval" << "\t" << service->GetCheckInterval() / 60.0 << "\n"
|
<< "\t" << "check_interval" << "\t" << CompatUtility::GetServiceCheckInterval(service) << "\n"
|
||||||
<< "\t" << "retry_interval" << "\t" << service->GetRetryInterval() / 60.0 << "\n"
|
<< "\t" << "retry_interval" << "\t" << CompatUtility::GetServiceRetryInterval(service) << "\n"
|
||||||
<< "\t" << "max_check_attempts" << "\t" << service->GetMaxCheckAttempts() << "\n"
|
<< "\t" << "max_check_attempts" << "\t" << service->GetMaxCheckAttempts() << "\n"
|
||||||
<< "\t" << "active_checks_enabled" << "\t" << (service->GetEnableActiveChecks() ? 1 : 0) << "\n"
|
<< "\t" << "active_checks_enabled" << "\t" << (service->GetEnableActiveChecks() ? 1 : 0) << "\n"
|
||||||
<< "\t" << "passive_checks_enabled" << "\t" << (service->GetEnablePassiveChecks() ? 1 : 0) << "\n"
|
<< "\t" << "passive_checks_enabled" << "\t" << (service->GetEnablePassiveChecks() ? 1 : 0) << "\n"
|
||||||
<< "\t" << "flap_detection_enabled" << "\t" << (service->GetEnableFlapping() ? 1 : 0) << "\n"
|
<< "\t" << "flap_detection_enabled" << "\t" << (service->GetEnableFlapping() ? 1 : 0) << "\n"
|
||||||
<< "\t" << "is_volatile" << "\t" << (service->GetVolatile() ? 1 : 0) << "\n"
|
<< "\t" << "is_volatile" << "\t" << (service->GetVolatile() ? 1 : 0) << "\n"
|
||||||
<< "\t" << "notifications_enabled" << "\t" << (service->GetEnableNotifications() ? 1 : 0) << "\n"
|
<< "\t" << "notifications_enabled" << "\t" << (service->GetEnableNotifications() ? 1 : 0) << "\n"
|
||||||
<< "\t" << "notification_options" << "\t" << "u,w,c,r" << "\n"
|
<< "\t" << "notification_options" << "\t" << CompatUtility::GetServiceNotificationNotificationOptions(service) << "\n"
|
||||||
<< "\t" << "notification_interval" << "\t" << notification_interval / 60.0 << "\n"
|
<< "\t" << "notification_interval" << "\t" << CompatUtility::GetServiceNotificationNotificationInterval(service) << "\n"
|
||||||
|
<< "\t" << "notification_period" << "\t" << CompatUtility::GetServiceNotificationNotificationPeriod(service) << "\n"
|
||||||
<< "\t" << "event_handler_enabled" << "\t" << (service->GetEnableEventHandler() ? 1 : 0) << "\n";
|
<< "\t" << "event_handler_enabled" << "\t" << (service->GetEnableEventHandler() ? 1 : 0) << "\n";
|
||||||
|
|
||||||
CheckCommand::Ptr checkcommand = service->GetCheckCommand();
|
CheckCommand::Ptr checkcommand = service->GetCheckCommand();
|
||||||
|
@ -443,10 +435,6 @@ void StatusDataWriter::DumpServiceObject(std::ostream& fp, const Service::Ptr& s
|
||||||
if (eventcommand)
|
if (eventcommand)
|
||||||
fp << "\t" << "event_handler" << "\t" << "event_" << eventcommand->GetName() << "\n";
|
fp << "\t" << "event_handler" << "\t" << "event_" << eventcommand->GetName() << "\n";
|
||||||
|
|
||||||
TimePeriod::Ptr check_period = service->GetCheckPeriod();
|
|
||||||
if (check_period)
|
|
||||||
fp << "\t" << "check_period" << "\t" << check_period->GetName() << "\n";
|
|
||||||
|
|
||||||
fp << "\t" << "contacts" << "\t";
|
fp << "\t" << "contacts" << "\t";
|
||||||
DumpNameList(fp, CompatUtility::GetServiceNotificationUsers(service));
|
DumpNameList(fp, CompatUtility::GetServiceNotificationUsers(service));
|
||||||
fp << "\n";
|
fp << "\n";
|
||||||
|
@ -459,7 +447,12 @@ void StatusDataWriter::DumpServiceObject(std::ostream& fp, const Service::Ptr& s
|
||||||
<< "\t" << "low_flap_threshold" << "\t" << service->GetFlappingThreshold() << "\n"
|
<< "\t" << "low_flap_threshold" << "\t" << service->GetFlappingThreshold() << "\n"
|
||||||
<< "\t" << "high_flap_threshold" << "\t" << service->GetFlappingThreshold() << "\n"
|
<< "\t" << "high_flap_threshold" << "\t" << service->GetFlappingThreshold() << "\n"
|
||||||
<< "\t" << "process_perf_data" << "\t" << 1 << "\n"
|
<< "\t" << "process_perf_data" << "\t" << 1 << "\n"
|
||||||
<< "\t" << "check_freshness" << "\t" << 1 << "\n";
|
<< "\t" << "check_freshness" << "\t" << 1 << "\n"
|
||||||
|
<< "\t" << "notes" << "\t" << CompatUtility::GetCustomAttributeConfig(service, "notes") << "\n"
|
||||||
|
<< "\t" << "notes_url" << "\t" << CompatUtility::GetCustomAttributeConfig(service, "notes_url") << "\n"
|
||||||
|
<< "\t" << "action_url" << "\t" << CompatUtility::GetCustomAttributeConfig(service, "action_url") << "\n"
|
||||||
|
<< "\t" << "icon_image" << "\t" << CompatUtility::GetCustomAttributeConfig(service, "icon_image") << "\n"
|
||||||
|
<< "\t" << "icon_image_alt" << "\t" << CompatUtility::GetCustomAttributeConfig(service, "icon_image_alt") << "\n";
|
||||||
}
|
}
|
||||||
|
|
||||||
fp << "\t" << "service_groups" << "\t";
|
fp << "\t" << "service_groups" << "\t";
|
||||||
|
|
File diff suppressed because it is too large
Load Diff
|
@ -233,10 +233,8 @@ Value ServicesTable::PluginOutputAccessor(const Value& row)
|
||||||
String output;
|
String output;
|
||||||
CheckResult::Ptr cr = service->GetLastCheckResult();
|
CheckResult::Ptr cr = service->GetLastCheckResult();
|
||||||
|
|
||||||
if (cr) {
|
if (cr)
|
||||||
std::pair<String, String> output_bag = CompatUtility::GetCheckResultOutput(cr);
|
output = CompatUtility::GetCheckResultOutput(cr);
|
||||||
output = output_bag.first;
|
|
||||||
}
|
|
||||||
|
|
||||||
return output;
|
return output;
|
||||||
}
|
}
|
||||||
|
@ -251,10 +249,8 @@ Value ServicesTable::LongPluginOutputAccessor(const Value& row)
|
||||||
String long_output;
|
String long_output;
|
||||||
CheckResult::Ptr cr = service->GetLastCheckResult();
|
CheckResult::Ptr cr = service->GetLastCheckResult();
|
||||||
|
|
||||||
if (cr) {
|
if (cr)
|
||||||
std::pair<String, String> output_bag = CompatUtility::GetCheckResultOutput(cr);
|
long_output = CompatUtility::GetCheckResultLongOutput(cr);
|
||||||
long_output = output_bag.second;
|
|
||||||
}
|
|
||||||
|
|
||||||
return long_output;
|
return long_output;
|
||||||
}
|
}
|
||||||
|
@ -282,17 +278,7 @@ Value ServicesTable::NotificationPeriodAccessor(const Value& row)
|
||||||
if (!service)
|
if (!service)
|
||||||
return Empty;
|
return Empty;
|
||||||
|
|
||||||
BOOST_FOREACH(const Notification::Ptr& notification, service->GetNotifications()) {
|
return CompatUtility::GetServiceNotificationNotificationPeriod(service);
|
||||||
ObjectLock olock(notification);
|
|
||||||
|
|
||||||
TimePeriod::Ptr timeperiod = notification->GetNotificationPeriod();
|
|
||||||
|
|
||||||
/* XXX first notification wins */
|
|
||||||
if (timeperiod)
|
|
||||||
return timeperiod->GetName();
|
|
||||||
}
|
|
||||||
|
|
||||||
return Empty;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
Value ServicesTable::CheckPeriodAccessor(const Value& row)
|
Value ServicesTable::CheckPeriodAccessor(const Value& row)
|
||||||
|
@ -302,12 +288,7 @@ Value ServicesTable::CheckPeriodAccessor(const Value& row)
|
||||||
if (!service)
|
if (!service)
|
||||||
return Empty;
|
return Empty;
|
||||||
|
|
||||||
TimePeriod::Ptr timeperiod = service->GetCheckPeriod();
|
return CompatUtility::GetServiceCheckPeriod(service);
|
||||||
|
|
||||||
if (!timeperiod)
|
|
||||||
return Empty;
|
|
||||||
|
|
||||||
return timeperiod->GetName();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
Value ServicesTable::NotesAccessor(const Value& row)
|
Value ServicesTable::NotesAccessor(const Value& row)
|
||||||
|
@ -317,12 +298,7 @@ Value ServicesTable::NotesAccessor(const Value& row)
|
||||||
if (!service)
|
if (!service)
|
||||||
return Empty;
|
return Empty;
|
||||||
|
|
||||||
Dictionary::Ptr custom = service->GetCustom();
|
return CompatUtility::GetCustomAttributeConfig(service, "notes");
|
||||||
|
|
||||||
if (!custom)
|
|
||||||
return Empty;
|
|
||||||
|
|
||||||
return custom->Get("notes");
|
|
||||||
}
|
}
|
||||||
|
|
||||||
Value ServicesTable::NotesExpandedAccessor(const Value& row)
|
Value ServicesTable::NotesExpandedAccessor(const Value& row)
|
||||||
|
@ -332,17 +308,12 @@ Value ServicesTable::NotesExpandedAccessor(const Value& row)
|
||||||
if (!service)
|
if (!service)
|
||||||
return Empty;
|
return Empty;
|
||||||
|
|
||||||
Dictionary::Ptr custom = service->GetCustom();
|
|
||||||
|
|
||||||
if (!custom)
|
|
||||||
return Empty;
|
|
||||||
|
|
||||||
std::vector<MacroResolver::Ptr> resolvers;
|
std::vector<MacroResolver::Ptr> resolvers;
|
||||||
resolvers.push_back(service);
|
resolvers.push_back(service);
|
||||||
resolvers.push_back(service->GetHost());
|
resolvers.push_back(service->GetHost());
|
||||||
resolvers.push_back(IcingaApplication::GetInstance());
|
resolvers.push_back(IcingaApplication::GetInstance());
|
||||||
|
|
||||||
Value value = custom->Get("notes");
|
Value value = CompatUtility::GetCustomAttributeConfig(service, "notes");
|
||||||
|
|
||||||
return MacroProcessor::ResolveMacros(value, resolvers, CheckResult::Ptr(), Utility::EscapeShellCmd);
|
return MacroProcessor::ResolveMacros(value, resolvers, CheckResult::Ptr(), Utility::EscapeShellCmd);
|
||||||
}
|
}
|
||||||
|
@ -354,12 +325,7 @@ Value ServicesTable::NotesUrlAccessor(const Value& row)
|
||||||
if (!service)
|
if (!service)
|
||||||
return Empty;
|
return Empty;
|
||||||
|
|
||||||
Dictionary::Ptr custom = service->GetCustom();
|
return CompatUtility::GetCustomAttributeConfig(service, "notes_url");
|
||||||
|
|
||||||
if (!custom)
|
|
||||||
return Empty;
|
|
||||||
|
|
||||||
return custom->Get("notes_url");
|
|
||||||
}
|
}
|
||||||
|
|
||||||
Value ServicesTable::NotesUrlExpandedAccessor(const Value& row)
|
Value ServicesTable::NotesUrlExpandedAccessor(const Value& row)
|
||||||
|
@ -369,17 +335,12 @@ Value ServicesTable::NotesUrlExpandedAccessor(const Value& row)
|
||||||
if (!service)
|
if (!service)
|
||||||
return Empty;
|
return Empty;
|
||||||
|
|
||||||
Dictionary::Ptr custom = service->GetCustom();
|
|
||||||
|
|
||||||
if (!custom)
|
|
||||||
return Empty;
|
|
||||||
|
|
||||||
std::vector<MacroResolver::Ptr> resolvers;
|
std::vector<MacroResolver::Ptr> resolvers;
|
||||||
resolvers.push_back(service);
|
resolvers.push_back(service);
|
||||||
resolvers.push_back(service->GetHost());
|
resolvers.push_back(service->GetHost());
|
||||||
resolvers.push_back(IcingaApplication::GetInstance());
|
resolvers.push_back(IcingaApplication::GetInstance());
|
||||||
|
|
||||||
Value value = custom->Get("notes_url");
|
Value value = CompatUtility::GetCustomAttributeConfig(service, "notes_url");
|
||||||
|
|
||||||
return MacroProcessor::ResolveMacros(value, resolvers, CheckResult::Ptr(), Utility::EscapeShellCmd);
|
return MacroProcessor::ResolveMacros(value, resolvers, CheckResult::Ptr(), Utility::EscapeShellCmd);
|
||||||
}
|
}
|
||||||
|
@ -391,12 +352,7 @@ Value ServicesTable::ActionUrlAccessor(const Value& row)
|
||||||
if (!service)
|
if (!service)
|
||||||
return Empty;
|
return Empty;
|
||||||
|
|
||||||
Dictionary::Ptr custom = service->GetCustom();
|
return CompatUtility::GetCustomAttributeConfig(service, "action_url");
|
||||||
|
|
||||||
if (!custom)
|
|
||||||
return Empty;
|
|
||||||
|
|
||||||
return custom->Get("action_url");
|
|
||||||
}
|
}
|
||||||
|
|
||||||
Value ServicesTable::ActionUrlExpandedAccessor(const Value& row)
|
Value ServicesTable::ActionUrlExpandedAccessor(const Value& row)
|
||||||
|
@ -406,17 +362,12 @@ Value ServicesTable::ActionUrlExpandedAccessor(const Value& row)
|
||||||
if (!service)
|
if (!service)
|
||||||
return Empty;
|
return Empty;
|
||||||
|
|
||||||
Dictionary::Ptr custom = service->GetCustom();
|
|
||||||
|
|
||||||
if (!custom)
|
|
||||||
return Empty;
|
|
||||||
|
|
||||||
std::vector<MacroResolver::Ptr> resolvers;
|
std::vector<MacroResolver::Ptr> resolvers;
|
||||||
resolvers.push_back(service);
|
resolvers.push_back(service);
|
||||||
resolvers.push_back(service->GetHost());
|
resolvers.push_back(service->GetHost());
|
||||||
resolvers.push_back(IcingaApplication::GetInstance());
|
resolvers.push_back(IcingaApplication::GetInstance());
|
||||||
|
|
||||||
Value value = custom->Get("action_url");
|
Value value = CompatUtility::GetCustomAttributeConfig(service, "action_url");
|
||||||
|
|
||||||
return MacroProcessor::ResolveMacros(value, resolvers, CheckResult::Ptr(), Utility::EscapeShellCmd);
|
return MacroProcessor::ResolveMacros(value, resolvers, CheckResult::Ptr(), Utility::EscapeShellCmd);
|
||||||
}
|
}
|
||||||
|
@ -428,12 +379,7 @@ Value ServicesTable::IconImageAccessor(const Value& row)
|
||||||
if (!service)
|
if (!service)
|
||||||
return Empty;
|
return Empty;
|
||||||
|
|
||||||
Dictionary::Ptr custom = service->GetCustom();
|
return CompatUtility::GetCustomAttributeConfig(service, "icon_image");
|
||||||
|
|
||||||
if (!custom)
|
|
||||||
return Empty;
|
|
||||||
|
|
||||||
return custom->Get("icon_image");
|
|
||||||
}
|
}
|
||||||
|
|
||||||
Value ServicesTable::IconImageExpandedAccessor(const Value& row)
|
Value ServicesTable::IconImageExpandedAccessor(const Value& row)
|
||||||
|
@ -443,17 +389,12 @@ Value ServicesTable::IconImageExpandedAccessor(const Value& row)
|
||||||
if (!service)
|
if (!service)
|
||||||
return Empty;
|
return Empty;
|
||||||
|
|
||||||
Dictionary::Ptr custom = service->GetCustom();
|
|
||||||
|
|
||||||
if (!custom)
|
|
||||||
return Empty;
|
|
||||||
|
|
||||||
std::vector<MacroResolver::Ptr> resolvers;
|
std::vector<MacroResolver::Ptr> resolvers;
|
||||||
resolvers.push_back(service);
|
resolvers.push_back(service);
|
||||||
resolvers.push_back(service->GetHost());
|
resolvers.push_back(service->GetHost());
|
||||||
resolvers.push_back(IcingaApplication::GetInstance());
|
resolvers.push_back(IcingaApplication::GetInstance());
|
||||||
|
|
||||||
Value value = custom->Get("icon_image");
|
Value value = CompatUtility::GetCustomAttributeConfig(service, "icon_image");
|
||||||
|
|
||||||
return MacroProcessor::ResolveMacros(value, resolvers, CheckResult::Ptr(), Utility::EscapeShellCmd);
|
return MacroProcessor::ResolveMacros(value, resolvers, CheckResult::Ptr(), Utility::EscapeShellCmd);
|
||||||
}
|
}
|
||||||
|
@ -465,12 +406,7 @@ Value ServicesTable::IconImageAltAccessor(const Value& row)
|
||||||
if (!service)
|
if (!service)
|
||||||
return Empty;
|
return Empty;
|
||||||
|
|
||||||
Dictionary::Ptr custom = service->GetCustom();
|
return CompatUtility::GetCustomAttributeConfig(service, "icon_image_alt");
|
||||||
|
|
||||||
if (!custom)
|
|
||||||
return Empty;
|
|
||||||
|
|
||||||
return custom->Get("icon_image_alt");
|
|
||||||
}
|
}
|
||||||
|
|
||||||
Value ServicesTable::MaxCheckAttemptsAccessor(const Value& row)
|
Value ServicesTable::MaxCheckAttemptsAccessor(const Value& row)
|
||||||
|
@ -500,7 +436,7 @@ Value ServicesTable::StateAccessor(const Value& row)
|
||||||
if (!service)
|
if (!service)
|
||||||
return Empty;
|
return Empty;
|
||||||
|
|
||||||
return service->GetState();
|
return CompatUtility::GetServiceCurrentState(service);
|
||||||
}
|
}
|
||||||
|
|
||||||
Value ServicesTable::HasBeenCheckedAccessor(const Value& row)
|
Value ServicesTable::HasBeenCheckedAccessor(const Value& row)
|
||||||
|
@ -510,7 +446,7 @@ Value ServicesTable::HasBeenCheckedAccessor(const Value& row)
|
||||||
if (!service)
|
if (!service)
|
||||||
return Empty;
|
return Empty;
|
||||||
|
|
||||||
return (service->HasBeenChecked() ? 1 : 0);
|
return CompatUtility::GetServiceHasBeenChecked(service);
|
||||||
}
|
}
|
||||||
|
|
||||||
Value ServicesTable::LastStateAccessor(const Value& row)
|
Value ServicesTable::LastStateAccessor(const Value& row)
|
||||||
|
@ -550,7 +486,7 @@ Value ServicesTable::CheckTypeAccessor(const Value& row)
|
||||||
if (!service)
|
if (!service)
|
||||||
return Empty;
|
return Empty;
|
||||||
|
|
||||||
return (service->GetEnableActiveChecks() ? 0 : 1);
|
return CompatUtility::GetServiceCheckType(service);
|
||||||
}
|
}
|
||||||
|
|
||||||
Value ServicesTable::AcknowledgedAccessor(const Value& row)
|
Value ServicesTable::AcknowledgedAccessor(const Value& row)
|
||||||
|
@ -560,10 +496,8 @@ Value ServicesTable::AcknowledgedAccessor(const Value& row)
|
||||||
if (!service)
|
if (!service)
|
||||||
return Empty;
|
return Empty;
|
||||||
|
|
||||||
/* important: lock acknowledgements */
|
|
||||||
ObjectLock olock(service);
|
|
||||||
|
|
||||||
return (service->IsAcknowledged() ? 1 : 0);
|
return CompatUtility::GetServiceIsAcknowledged(service);
|
||||||
}
|
}
|
||||||
|
|
||||||
Value ServicesTable::AcknowledgementTypeAccessor(const Value& row)
|
Value ServicesTable::AcknowledgementTypeAccessor(const Value& row)
|
||||||
|
@ -586,17 +520,7 @@ Value ServicesTable::NoMoreNotificationsAccessor(const Value& row)
|
||||||
if (!service)
|
if (!service)
|
||||||
return Empty;
|
return Empty;
|
||||||
|
|
||||||
/* XXX take the smallest notification_interval */
|
return CompatUtility::GetServiceNoMoreNotifications(service);
|
||||||
double notification_interval = -1;
|
|
||||||
BOOST_FOREACH(const Notification::Ptr& notification, service->GetNotifications()) {
|
|
||||||
if (notification_interval == -1 || notification->GetNotificationInterval() < notification_interval)
|
|
||||||
notification_interval = notification->GetNotificationInterval();
|
|
||||||
}
|
|
||||||
|
|
||||||
if (notification_interval == 0 && !service->GetVolatile())
|
|
||||||
return 1;
|
|
||||||
|
|
||||||
return 0;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
Value ServicesTable::LastTimeOkAccessor(const Value& row)
|
Value ServicesTable::LastTimeOkAccessor(const Value& row)
|
||||||
|
@ -666,14 +590,7 @@ Value ServicesTable::LastNotificationAccessor(const Value& row)
|
||||||
if (!service)
|
if (!service)
|
||||||
return Empty;
|
return Empty;
|
||||||
|
|
||||||
/* XXX Service -> Notifications, latest wins */
|
return CompatUtility::GetServiceNotificationLastNotification(service);
|
||||||
double last_notification = 0;
|
|
||||||
BOOST_FOREACH(const Notification::Ptr& notification, service->GetNotifications()) {
|
|
||||||
if (notification->GetLastNotification() > last_notification)
|
|
||||||
last_notification = notification->GetLastNotification();
|
|
||||||
}
|
|
||||||
|
|
||||||
return static_cast<int>(last_notification);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
Value ServicesTable::NextNotificationAccessor(const Value& row)
|
Value ServicesTable::NextNotificationAccessor(const Value& row)
|
||||||
|
@ -683,14 +600,7 @@ Value ServicesTable::NextNotificationAccessor(const Value& row)
|
||||||
if (!service)
|
if (!service)
|
||||||
return Empty;
|
return Empty;
|
||||||
|
|
||||||
/* XXX Service -> Notifications, latest wins */
|
return CompatUtility::GetServiceNotificationNextNotification(service);
|
||||||
double next_notification = 0;
|
|
||||||
BOOST_FOREACH(const Notification::Ptr& notification, service->GetNotifications()) {
|
|
||||||
if (notification->GetNextNotification() < next_notification)
|
|
||||||
next_notification = notification->GetNextNotification();
|
|
||||||
}
|
|
||||||
|
|
||||||
return static_cast<int>(next_notification);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
Value ServicesTable::CurrentNotificationNumberAccessor(const Value& row)
|
Value ServicesTable::CurrentNotificationNumberAccessor(const Value& row)
|
||||||
|
@ -700,14 +610,7 @@ Value ServicesTable::CurrentNotificationNumberAccessor(const Value& row)
|
||||||
if (!service)
|
if (!service)
|
||||||
return Empty;
|
return Empty;
|
||||||
|
|
||||||
/* XXX Service -> Notifications, biggest wins */
|
return CompatUtility::GetServiceNotificationNotificationNumber(service);
|
||||||
int notification_number = 0;
|
|
||||||
BOOST_FOREACH(const Notification::Ptr& notification, service->GetNotifications()) {
|
|
||||||
if (notification->GetNotificationNumber() > notification_number)
|
|
||||||
notification_number = notification->GetNotificationNumber();
|
|
||||||
}
|
|
||||||
|
|
||||||
return notification_number;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
Value ServicesTable::LastStateChangeAccessor(const Value& row)
|
Value ServicesTable::LastStateChangeAccessor(const Value& row)
|
||||||
|
@ -757,7 +660,7 @@ Value ServicesTable::ChecksEnabledAccessor(const Value& row)
|
||||||
if (!service)
|
if (!service)
|
||||||
return Empty;
|
return Empty;
|
||||||
|
|
||||||
return (service->GetEnableActiveChecks() ? 1 : 0);
|
return CompatUtility::GetServiceActiveChecksEnabled(service);
|
||||||
}
|
}
|
||||||
|
|
||||||
Value ServicesTable::AcceptPassiveChecksAccessor(const Value& row)
|
Value ServicesTable::AcceptPassiveChecksAccessor(const Value& row)
|
||||||
|
@ -767,7 +670,7 @@ Value ServicesTable::AcceptPassiveChecksAccessor(const Value& row)
|
||||||
if (!service)
|
if (!service)
|
||||||
return Empty;
|
return Empty;
|
||||||
|
|
||||||
return (service->GetEnablePassiveChecks() ? 1 : 0);
|
return CompatUtility::GetServicePassiveChecksEnabled(service);
|
||||||
}
|
}
|
||||||
|
|
||||||
Value ServicesTable::EventHandlerEnabledAccessor(const Value& row)
|
Value ServicesTable::EventHandlerEnabledAccessor(const Value& row)
|
||||||
|
@ -777,12 +680,7 @@ Value ServicesTable::EventHandlerEnabledAccessor(const Value& row)
|
||||||
if (!service)
|
if (!service)
|
||||||
return Empty;
|
return Empty;
|
||||||
|
|
||||||
EventCommand::Ptr eventcommand = service->GetEventCommand();
|
return CompatUtility::GetServiceEventHandlerEnabled(service);
|
||||||
|
|
||||||
if (eventcommand)
|
|
||||||
return 1;
|
|
||||||
|
|
||||||
return 0;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
Value ServicesTable::NotificationsEnabledAccessor(const Value& row)
|
Value ServicesTable::NotificationsEnabledAccessor(const Value& row)
|
||||||
|
@ -792,7 +690,7 @@ Value ServicesTable::NotificationsEnabledAccessor(const Value& row)
|
||||||
if (!service)
|
if (!service)
|
||||||
return Empty;
|
return Empty;
|
||||||
|
|
||||||
return (service->GetEnableNotifications() ? 1 : 0);
|
return CompatUtility::GetServiceNotificationsEnabled(service);
|
||||||
}
|
}
|
||||||
|
|
||||||
Value ServicesTable::ActiveChecksEnabledAccessor(const Value& row)
|
Value ServicesTable::ActiveChecksEnabledAccessor(const Value& row)
|
||||||
|
@ -802,7 +700,7 @@ Value ServicesTable::ActiveChecksEnabledAccessor(const Value& row)
|
||||||
if (!service)
|
if (!service)
|
||||||
return Empty;
|
return Empty;
|
||||||
|
|
||||||
return (service->GetEnableActiveChecks() ? 1 : 0);
|
return CompatUtility::GetServiceActiveChecksEnabled(service);
|
||||||
}
|
}
|
||||||
|
|
||||||
Value ServicesTable::CheckOptionsAccessor(const Value& row)
|
Value ServicesTable::CheckOptionsAccessor(const Value& row)
|
||||||
|
@ -818,13 +716,17 @@ Value ServicesTable::FlapDetectionEnabledAccessor(const Value& row)
|
||||||
if (!service)
|
if (!service)
|
||||||
return Empty;
|
return Empty;
|
||||||
|
|
||||||
return (service->GetEnableFlapping() ? 1 : 0);
|
return CompatUtility::GetServiceFlapDetectionEnabled(service);
|
||||||
}
|
}
|
||||||
|
|
||||||
Value ServicesTable::CheckFreshnessAccessor(const Value& row)
|
Value ServicesTable::CheckFreshnessAccessor(const Value& row)
|
||||||
{
|
{
|
||||||
/* always enabled */
|
Service::Ptr service = static_cast<Service::Ptr>(row);
|
||||||
return 1;
|
|
||||||
|
if (!service)
|
||||||
|
return Empty;
|
||||||
|
|
||||||
|
return CompatUtility::GetServiceFreshnessChecksEnabled(service);
|
||||||
}
|
}
|
||||||
|
|
||||||
Value ServicesTable::ModifiedAttributesAccessor(const Value& row)
|
Value ServicesTable::ModifiedAttributesAccessor(const Value& row)
|
||||||
|
@ -850,10 +752,7 @@ Value ServicesTable::StalenessAccessor(const Value& row)
|
||||||
if (!service)
|
if (!service)
|
||||||
return Empty;
|
return Empty;
|
||||||
|
|
||||||
if (service->HasBeenChecked() && service->GetLastCheck() > 0)
|
return CompatUtility::GetServiceStaleness(service);
|
||||||
return (Utility::GetTime() - service->GetLastCheck()) / (service->GetCheckInterval() * 3600);
|
|
||||||
|
|
||||||
return Empty;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
Value ServicesTable::CheckIntervalAccessor(const Value& row)
|
Value ServicesTable::CheckIntervalAccessor(const Value& row)
|
||||||
|
@ -863,7 +762,7 @@ Value ServicesTable::CheckIntervalAccessor(const Value& row)
|
||||||
if (!service)
|
if (!service)
|
||||||
return Empty;
|
return Empty;
|
||||||
|
|
||||||
return (service->GetCheckInterval() / 60.0);
|
return CompatUtility::GetServiceCheckInterval(service);
|
||||||
}
|
}
|
||||||
|
|
||||||
Value ServicesTable::RetryIntervalAccessor(const Value& row)
|
Value ServicesTable::RetryIntervalAccessor(const Value& row)
|
||||||
|
@ -873,7 +772,7 @@ Value ServicesTable::RetryIntervalAccessor(const Value& row)
|
||||||
if (!service)
|
if (!service)
|
||||||
return Empty;
|
return Empty;
|
||||||
|
|
||||||
return (service->GetRetryInterval() / 60.0);
|
return CompatUtility::GetServiceRetryInterval(service);
|
||||||
}
|
}
|
||||||
|
|
||||||
Value ServicesTable::NotificationIntervalAccessor(const Value& row)
|
Value ServicesTable::NotificationIntervalAccessor(const Value& row)
|
||||||
|
@ -883,17 +782,7 @@ Value ServicesTable::NotificationIntervalAccessor(const Value& row)
|
||||||
if (!service)
|
if (!service)
|
||||||
return Empty;
|
return Empty;
|
||||||
|
|
||||||
/* XXX take the smallest notification_interval */
|
return CompatUtility::GetServiceNotificationNotificationInterval(service);
|
||||||
double notification_interval = -1;
|
|
||||||
BOOST_FOREACH(const Notification::Ptr& notification, service->GetNotifications()) {
|
|
||||||
if (notification_interval == -1 || notification->GetNotificationInterval() < notification_interval)
|
|
||||||
notification_interval = notification->GetNotificationInterval();
|
|
||||||
}
|
|
||||||
|
|
||||||
if (notification_interval == -1)
|
|
||||||
notification_interval = 60;
|
|
||||||
|
|
||||||
return (notification_interval / 60.0);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
Value ServicesTable::LowFlapThresholdAccessor(const Value& row)
|
Value ServicesTable::LowFlapThresholdAccessor(const Value& row)
|
||||||
|
@ -903,7 +792,7 @@ Value ServicesTable::LowFlapThresholdAccessor(const Value& row)
|
||||||
if (!service)
|
if (!service)
|
||||||
return Empty;
|
return Empty;
|
||||||
|
|
||||||
return service->GetFlappingThreshold();
|
return CompatUtility::GetServiceLowFlapThreshold(service);
|
||||||
}
|
}
|
||||||
|
|
||||||
Value ServicesTable::HighFlapThresholdAccessor(const Value& row)
|
Value ServicesTable::HighFlapThresholdAccessor(const Value& row)
|
||||||
|
@ -913,7 +802,7 @@ Value ServicesTable::HighFlapThresholdAccessor(const Value& row)
|
||||||
if (!service)
|
if (!service)
|
||||||
return Empty;
|
return Empty;
|
||||||
|
|
||||||
return service->GetFlappingThreshold();
|
return CompatUtility::GetServiceHighFlapThreshold(service);
|
||||||
}
|
}
|
||||||
|
|
||||||
Value ServicesTable::LatencyAccessor(const Value& row)
|
Value ServicesTable::LatencyAccessor(const Value& row)
|
||||||
|
@ -943,7 +832,7 @@ Value ServicesTable::PercentStateChangeAccessor(const Value& row)
|
||||||
if (!service)
|
if (!service)
|
||||||
return Empty;
|
return Empty;
|
||||||
|
|
||||||
return service->GetFlappingCurrent();
|
return CompatUtility::GetServicePercentStateChange(service);
|
||||||
}
|
}
|
||||||
|
|
||||||
Value ServicesTable::InCheckPeriodAccessor(const Value& row)
|
Value ServicesTable::InCheckPeriodAccessor(const Value& row)
|
||||||
|
@ -953,13 +842,7 @@ Value ServicesTable::InCheckPeriodAccessor(const Value& row)
|
||||||
if (!service)
|
if (!service)
|
||||||
return Empty;
|
return Empty;
|
||||||
|
|
||||||
TimePeriod::Ptr timeperiod = service->GetCheckPeriod();
|
return CompatUtility::GetServiceInCheckPeriod(service);
|
||||||
|
|
||||||
/* none set means always checked */
|
|
||||||
if (!timeperiod)
|
|
||||||
return 1;
|
|
||||||
|
|
||||||
return (timeperiod->IsInside(Utility::GetTime()) ? 1 : 0);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
Value ServicesTable::InNotificationPeriodAccessor(const Value& row)
|
Value ServicesTable::InNotificationPeriodAccessor(const Value& row)
|
||||||
|
@ -969,18 +852,7 @@ Value ServicesTable::InNotificationPeriodAccessor(const Value& row)
|
||||||
if (!service)
|
if (!service)
|
||||||
return Empty;
|
return Empty;
|
||||||
|
|
||||||
BOOST_FOREACH(const Notification::Ptr& notification, service->GetNotifications()) {
|
return CompatUtility::GetServiceInNotificationPeriod(service);
|
||||||
ObjectLock olock(notification);
|
|
||||||
|
|
||||||
TimePeriod::Ptr timeperiod = notification->GetNotificationPeriod();
|
|
||||||
|
|
||||||
/* XXX first notification wins */
|
|
||||||
if (timeperiod)
|
|
||||||
return (timeperiod->IsInside(Utility::GetTime()) ? 1 : 0);
|
|
||||||
}
|
|
||||||
|
|
||||||
/* none set means always notified */
|
|
||||||
return 1;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
Value ServicesTable::ContactsAccessor(const Value& row)
|
Value ServicesTable::ContactsAccessor(const Value& row)
|
||||||
|
|
|
@ -40,11 +40,7 @@ Dictionary::Ptr CommandDbObject::GetConfigFields(void) const
|
||||||
Dictionary::Ptr fields = make_shared<Dictionary>();
|
Dictionary::Ptr fields = make_shared<Dictionary>();
|
||||||
Command::Ptr command = static_pointer_cast<Command>(GetObject());
|
Command::Ptr command = static_pointer_cast<Command>(GetObject());
|
||||||
|
|
||||||
Dictionary::Ptr attrs;
|
fields->Set("command_line", CompatUtility::GetCommandLine(command));
|
||||||
|
|
||||||
attrs = CompatUtility::GetCommandConfigAttributes(command);
|
|
||||||
|
|
||||||
fields->Set("command_line", attrs->Get("command_line"));
|
|
||||||
|
|
||||||
return fields;
|
return fields;
|
||||||
}
|
}
|
||||||
|
|
|
@ -45,76 +45,81 @@ Dictionary::Ptr HostDbObject::GetConfigFields(void) const
|
||||||
|
|
||||||
Service::Ptr service = host->GetCheckService();
|
Service::Ptr service = host->GetCheckService();
|
||||||
|
|
||||||
Dictionary::Ptr attrs;
|
fields->Set("alias", CompatUtility::GetHostAlias(host));
|
||||||
|
|
||||||
{
|
|
||||||
ObjectLock olock(host);
|
|
||||||
attrs = CompatUtility::GetHostConfigAttributes(host);
|
|
||||||
}
|
|
||||||
|
|
||||||
fields->Set("alias", attrs->Get("alias"));
|
|
||||||
fields->Set("display_name", host->GetDisplayName());
|
fields->Set("display_name", host->GetDisplayName());
|
||||||
|
fields->Set("address", CompatUtility::GetHostAddress(host));
|
||||||
fields->Set("address", attrs->Get("address"));
|
fields->Set("address6", CompatUtility::GetHostAddress6(host));
|
||||||
fields->Set("address6", attrs->Get("address6"));
|
|
||||||
|
|
||||||
if (service) {
|
if (service) {
|
||||||
fields->Set("check_command_object_id", service->GetCheckCommand());
|
fields->Set("check_command_object_id", service->GetCheckCommand());
|
||||||
fields->Set("check_command_args", Empty);
|
fields->Set("check_command_args", Empty);
|
||||||
fields->Set("eventhandler_command_object_id", service->GetEventCommand());
|
fields->Set("eventhandler_command_object_id", service->GetEventCommand());
|
||||||
fields->Set("eventhandler_command_args", Empty);
|
fields->Set("eventhandler_command_args", Empty);
|
||||||
|
fields->Set("notification_timeperiod_object_id", Notification::GetByName(CompatUtility::GetServiceNotificationNotificationPeriod(service)));
|
||||||
|
fields->Set("check_timeperiod_object_id", service->GetCheckPeriod());
|
||||||
|
fields->Set("failure_prediction_options", Empty);
|
||||||
|
fields->Set("check_interval", CompatUtility::GetServiceCheckInterval(service));
|
||||||
|
fields->Set("retry_interval", CompatUtility::GetServiceRetryInterval(service));
|
||||||
|
fields->Set("max_check_attempts", service->GetMaxCheckAttempts());
|
||||||
|
|
||||||
|
fields->Set("first_notification_delay", Empty);
|
||||||
|
|
||||||
|
fields->Set("notification_interval", CompatUtility::GetServiceNotificationNotificationInterval(service));
|
||||||
|
/* requires host check service */
|
||||||
|
fields->Set("notify_on_down", CompatUtility::GetHostNotifyOnDown(host));
|
||||||
|
fields->Set("notify_on_unreachable", CompatUtility::GetHostNotifyOnDown(host));
|
||||||
|
|
||||||
|
fields->Set("notify_on_recovery", CompatUtility::GetServiceNotifyOnRecovery(service));
|
||||||
|
fields->Set("notify_on_flapping", CompatUtility::GetServiceNotifyOnFlapping(service));
|
||||||
|
fields->Set("notify_on_downtime", CompatUtility::GetServiceNotifyOnDowntime(service));
|
||||||
|
|
||||||
|
fields->Set("stalk_on_up", Empty);
|
||||||
|
fields->Set("stalk_on_down", Empty);
|
||||||
|
fields->Set("stalk_on_unreachable", Empty);
|
||||||
|
|
||||||
|
fields->Set("flap_detection_enabled", CompatUtility::GetServiceFlapDetectionEnabled(service));
|
||||||
|
fields->Set("flap_detection_on_up", Empty);
|
||||||
|
fields->Set("flap_detection_on_down", Empty);
|
||||||
|
fields->Set("flap_detection_on_unreachable", Empty);
|
||||||
|
fields->Set("low_flap_threshold", CompatUtility::GetServiceLowFlapThreshold(service));
|
||||||
|
fields->Set("high_flap_threshold", CompatUtility::GetServiceHighFlapThreshold(service));
|
||||||
}
|
}
|
||||||
|
|
||||||
fields->Set("notification_timeperiod_object_id", Notification::GetByName(attrs->Get("notification_period")));
|
fields->Set("process_performance_data", 0);
|
||||||
|
|
||||||
if (service)
|
if (service) {
|
||||||
fields->Set("check_timeperiod_object_id", service->GetCheckPeriod());
|
fields->Set("freshness_checks_enabled", CompatUtility::GetServiceFreshnessChecksEnabled(service));
|
||||||
|
fields->Set("freshness_threshold", CompatUtility::GetServiceFreshnessThreshold(service));
|
||||||
|
fields->Set("passive_checks_enabled", CompatUtility::GetServicePassiveChecksEnabled(service));
|
||||||
|
fields->Set("event_handler_enabled", CompatUtility::GetServiceEventHandlerEnabled(service));
|
||||||
|
fields->Set("active_checks_enabled", CompatUtility::GetServiceActiveChecksEnabled(service));
|
||||||
|
}
|
||||||
|
|
||||||
fields->Set("failure_prediction_options", Empty);
|
|
||||||
|
|
||||||
fields->Set("check_interval", attrs->Get("check_interval"));
|
|
||||||
fields->Set("retry_interval", attrs->Get("retry_interval"));
|
|
||||||
fields->Set("max_check_attempts", attrs->Get("max_check_attempts"));
|
|
||||||
|
|
||||||
fields->Set("first_notification_delay", Empty);
|
|
||||||
fields->Set("notification_interval", attrs->Get("notification_interval"));
|
|
||||||
fields->Set("notify_on_down", attrs->Get("notify_on_down"));
|
|
||||||
fields->Set("notify_on_unreachable", attrs->Get("notify_on_unreachable"));
|
|
||||||
fields->Set("notify_on_recovery", attrs->Get("notify_on_recovery"));
|
|
||||||
fields->Set("notify_on_flapping", attrs->Get("notify_on_flapping"));
|
|
||||||
fields->Set("notify_on_downtime", attrs->Get("notify_on_downtime"));
|
|
||||||
|
|
||||||
fields->Set("stalk_on_up", Empty);
|
|
||||||
fields->Set("stalk_on_down", Empty);
|
|
||||||
fields->Set("stalk_on_unreachable", Empty);
|
|
||||||
|
|
||||||
fields->Set("flap_detection_enabled", attrs->Get("flap_detection_enabled"));
|
|
||||||
fields->Set("flap_detection_on_up", Empty);
|
|
||||||
fields->Set("flap_detection_on_down", Empty);
|
|
||||||
fields->Set("flap_detection_on_unreachable", Empty);
|
|
||||||
fields->Set("low_flap_threshold", attrs->Get("low_flap_threshold"));
|
|
||||||
fields->Set("high_flap_threshold", attrs->Get("high_flap_threshold"));
|
|
||||||
fields->Set("process_performance_data", attrs->Get("process_performance_data"));
|
|
||||||
fields->Set("freshness_checks_enabled", attrs->Get("check_freshness"));
|
|
||||||
fields->Set("freshness_threshold", Empty);
|
|
||||||
fields->Set("passive_checks_enabled", attrs->Get("passive_checks_enabled"));
|
|
||||||
fields->Set("event_handler_enabled", attrs->Get("event_handler_enabled"));
|
|
||||||
fields->Set("active_checks_enabled", attrs->Get("active_checks_enabled"));
|
|
||||||
fields->Set("retain_status_information", 1);
|
fields->Set("retain_status_information", 1);
|
||||||
fields->Set("retain_nonstatus_information", 1);
|
fields->Set("retain_nonstatus_information", 1);
|
||||||
fields->Set("notifications_enabled", attrs->Get("notifications_enabled"));
|
|
||||||
|
if (service)
|
||||||
|
fields->Set("notifications_enabled", CompatUtility::GetServiceNotificationsEnabled(service));
|
||||||
|
|
||||||
fields->Set("obsess_over_host", 0);
|
fields->Set("obsess_over_host", 0);
|
||||||
fields->Set("failure_prediction_enabled", 0);
|
fields->Set("failure_prediction_enabled", 0);
|
||||||
|
|
||||||
fields->Set("notes", attrs->Get("notes"));
|
fields->Set("notes", CompatUtility::GetCustomAttributeConfig(host, "notes"));
|
||||||
fields->Set("notes_url", attrs->Get("notes_url"));
|
fields->Set("notes_url", CompatUtility::GetCustomAttributeConfig(host, "notes_url"));
|
||||||
fields->Set("action_url", attrs->Get("action_url"));
|
fields->Set("action_url", CompatUtility::GetCustomAttributeConfig(host, "action_url"));
|
||||||
fields->Set("icon_image", attrs->Get("icon_image"));
|
fields->Set("icon_image", CompatUtility::GetCustomAttributeConfig(host, "icon_image"));
|
||||||
fields->Set("icon_image_alt", attrs->Get("icon_image_alt"));
|
fields->Set("icon_image_alt", CompatUtility::GetCustomAttributeConfig(host, "icon_image_alt"));
|
||||||
fields->Set("statusmap_image", attrs->Get("statusmap_image"));
|
fields->Set("statusmap_image", CompatUtility::GetCustomAttributeConfig(host, "statusmap_image"));
|
||||||
fields->Set("have_2d_coords", attrs->Get("have_2d_coords"));
|
|
||||||
fields->Set("x_2d", attrs->Get("x_2d"));
|
Host2dCoords coords = CompatUtility::GetHost2dCoords(host);
|
||||||
fields->Set("y_2d", attrs->Get("y_2d"));
|
|
||||||
|
fields->Set("have_2d_coords", coords.have_2d_coords);
|
||||||
|
|
||||||
|
if (coords.have_2d_coords) {
|
||||||
|
fields->Set("x_2d", coords.x_2d);
|
||||||
|
fields->Set("y_2d", coords.y_2d);
|
||||||
|
}
|
||||||
|
|
||||||
/* deprecated in 1.x */
|
/* deprecated in 1.x */
|
||||||
fields->Set("have_3d_coords", 0);
|
fields->Set("have_3d_coords", 0);
|
||||||
|
|
||||||
|
@ -127,55 +132,61 @@ Dictionary::Ptr HostDbObject::GetStatusFields(void) const
|
||||||
Host::Ptr host = static_pointer_cast<Host>(GetObject());
|
Host::Ptr host = static_pointer_cast<Host>(GetObject());
|
||||||
Service::Ptr service = host->GetCheckService();
|
Service::Ptr service = host->GetCheckService();
|
||||||
|
|
||||||
Dictionary::Ptr attrs;
|
|
||||||
|
|
||||||
/* fetch service status, or dump a pending hoststatus */
|
/* fetch service status, or dump a pending hoststatus */
|
||||||
if (service) {
|
if (service) {
|
||||||
ObjectLock olock(service);
|
CheckResult::Ptr cr = service->GetLastCheckResult();
|
||||||
attrs = CompatUtility::GetServiceStatusAttributes(service, CompatTypeHost);
|
|
||||||
|
|
||||||
fields->Set("output", attrs->Get("plugin_output"));
|
if (cr) {
|
||||||
fields->Set("long_output", attrs->Get("long_plugin_output"));
|
fields->Set("output", CompatUtility::GetCheckResultOutput(cr));
|
||||||
fields->Set("perfdata", attrs->Get("performance_data"));
|
fields->Set("long_output", CompatUtility::GetCheckResultLongOutput(cr));
|
||||||
fields->Set("check_source", attrs->Get("check_source"));
|
fields->Set("perfdata", CompatUtility::GetCheckResultPerfdata(cr));
|
||||||
fields->Set("current_state", attrs->Get("current_state"));
|
fields->Set("check_source", cr->GetCheckSource());
|
||||||
fields->Set("has_been_checked", attrs->Get("has_been_checked"));
|
}
|
||||||
fields->Set("should_be_scheduled", attrs->Get("should_be_scheduled"));
|
|
||||||
fields->Set("current_check_attempt", attrs->Get("current_attempt"));
|
fields->Set("current_state", host->GetState());
|
||||||
fields->Set("max_check_attempts", attrs->Get("max_attempts"));
|
fields->Set("has_been_checked", CompatUtility::GetServiceHasBeenChecked(service));
|
||||||
fields->Set("last_check", DbValue::FromTimestamp(attrs->Get("last_check")));
|
fields->Set("should_be_scheduled", CompatUtility::GetServiceShouldBeScheduled(service));
|
||||||
fields->Set("next_check", DbValue::FromTimestamp(attrs->Get("next_check")));
|
fields->Set("current_check_attempt", service->GetCheckAttempt());
|
||||||
fields->Set("check_type", attrs->Get("check_type"));
|
fields->Set("max_check_attempts", service->GetMaxCheckAttempts());
|
||||||
fields->Set("last_state_change", DbValue::FromTimestamp(attrs->Get("last_state_change")));
|
|
||||||
fields->Set("last_hard_state_change", DbValue::FromTimestamp(attrs->Get("last_hard_state_change")));
|
if (cr)
|
||||||
fields->Set("last_time_up", DbValue::FromTimestamp(attrs->Get("last_time_up")));
|
fields->Set("last_check", DbValue::FromTimestamp(cr->GetScheduleEnd()));
|
||||||
fields->Set("last_time_down", DbValue::FromTimestamp(attrs->Get("last_time_down")));
|
|
||||||
fields->Set("last_time_unreachable", DbValue::FromTimestamp(attrs->Get("last_time_unreachable")));
|
fields->Set("next_check", DbValue::FromTimestamp(service->GetNextCheck()));
|
||||||
fields->Set("state_type", attrs->Get("state_type"));
|
fields->Set("check_type", CompatUtility::GetServiceCheckType(service));
|
||||||
fields->Set("last_notification", DbValue::FromTimestamp(attrs->Get("last_notification")));
|
fields->Set("last_state_change", DbValue::FromTimestamp(service->GetLastStateChange()));
|
||||||
fields->Set("next_notification", DbValue::FromTimestamp(attrs->Get("next_notification")));
|
fields->Set("last_hard_state_change", DbValue::FromTimestamp(service->GetLastHardStateChange()));
|
||||||
|
fields->Set("last_time_up", DbValue::FromTimestamp(static_cast<int>(host->GetLastStateUp())));
|
||||||
|
fields->Set("last_time_down", DbValue::FromTimestamp(static_cast<int>(host->GetLastStateDown())));
|
||||||
|
fields->Set("last_time_unreachable", DbValue::FromTimestamp(static_cast<int>(host->GetLastStateUnreachable())));
|
||||||
|
fields->Set("state_type", service->GetStateType());
|
||||||
|
fields->Set("last_notification", DbValue::FromTimestamp(CompatUtility::GetServiceNotificationLastNotification(service)));
|
||||||
|
fields->Set("next_notification", DbValue::FromTimestamp(CompatUtility::GetServiceNotificationNextNotification(service)));
|
||||||
fields->Set("no_more_notifications", Empty);
|
fields->Set("no_more_notifications", Empty);
|
||||||
fields->Set("notifications_enabled", attrs->Get("notifications_enabled"));
|
fields->Set("notifications_enabled", CompatUtility::GetServiceNotificationsEnabled(service));
|
||||||
fields->Set("problem_has_been_acknowledged", attrs->Get("problem_has_been_acknowledged"));
|
fields->Set("problem_has_been_acknowledged", CompatUtility::GetServiceProblemHasBeenAcknowledged(service));
|
||||||
fields->Set("acknowledgement_type", attrs->Get("acknowledgement_type"));
|
fields->Set("acknowledgement_type", CompatUtility::GetServiceAcknowledgementType(service));
|
||||||
fields->Set("current_notification_number", attrs->Get("current_notification_number"));
|
fields->Set("current_notification_number", CompatUtility::GetServiceNotificationNotificationNumber(service));
|
||||||
fields->Set("passive_checks_enabled", attrs->Get("passive_checks_enabled"));
|
fields->Set("passive_checks_enabled", CompatUtility::GetServicePassiveChecksEnabled(service));
|
||||||
fields->Set("active_checks_enabled", attrs->Get("active_checks_enabled"));
|
fields->Set("active_checks_enabled", CompatUtility::GetServiceActiveChecksEnabled(service));
|
||||||
fields->Set("eventhandler_enabled", attrs->Get("eventhandler_enabled"));
|
fields->Set("event_handler_enabled", CompatUtility::GetServiceEventHandlerEnabled(service));
|
||||||
fields->Set("flap_detection_enabled", attrs->Get("flap_detection_enabled"));
|
fields->Set("flap_detection_enabled", CompatUtility::GetServiceFlapDetectionEnabled(service));
|
||||||
fields->Set("is_flapping", attrs->Get("is_flapping"));
|
fields->Set("is_flapping", CompatUtility::GetServiceIsFlapping(service));
|
||||||
fields->Set("percent_state_change", attrs->Get("percent_state_change"));
|
fields->Set("percent_state_change", CompatUtility::GetServicePercentStateChange(service));
|
||||||
fields->Set("latency", attrs->Get("check_latency"));
|
|
||||||
fields->Set("execution_time", attrs->Get("check_execution_time"));
|
if (cr) {
|
||||||
fields->Set("scheduled_downtime_depth", attrs->Get("scheduled_downtime_depth"));
|
fields->Set("latency", Service::CalculateLatency(cr));
|
||||||
|
fields->Set("execution_time", Service::CalculateExecutionTime(cr));
|
||||||
|
}
|
||||||
|
fields->Set("scheduled_downtime_depth", service->GetDowntimeDepth());
|
||||||
fields->Set("failure_prediction_enabled", Empty);
|
fields->Set("failure_prediction_enabled", Empty);
|
||||||
fields->Set("process_performance_data", attrs->Get("process_performance_data"));
|
fields->Set("process_performance_data", 0); /* this is a host which does not process any perf data */
|
||||||
fields->Set("obsess_over_host", Empty);
|
fields->Set("obsess_over_host", Empty);
|
||||||
fields->Set("modified_host_attributes", attrs->Get("modified_attributes"));
|
fields->Set("modified_host_attributes", service->GetModifiedAttributes());
|
||||||
fields->Set("event_handler", attrs->Get("event_handler"));
|
fields->Set("event_handler", CompatUtility::GetServiceEventHandler(service));
|
||||||
fields->Set("check_command", attrs->Get("check_command"));
|
fields->Set("check_command", CompatUtility::GetServiceCheckCommand(service));
|
||||||
fields->Set("normal_check_interval", attrs->Get("check_interval"));
|
fields->Set("normal_check_interval", CompatUtility::GetServiceCheckInterval(service));
|
||||||
fields->Set("retry_check_interval", attrs->Get("retry_interval"));
|
fields->Set("retry_check_interval", CompatUtility::GetServiceRetryInterval(service));
|
||||||
fields->Set("check_timeperiod_object_id", service->GetCheckPeriod());
|
fields->Set("check_timeperiod_object_id", service->GetCheckPeriod());
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
|
|
|
@ -79,64 +79,56 @@ Dictionary::Ptr ServiceDbObject::GetConfigFields(void) const
|
||||||
{
|
{
|
||||||
Dictionary::Ptr fields = make_shared<Dictionary>();
|
Dictionary::Ptr fields = make_shared<Dictionary>();
|
||||||
Service::Ptr service = static_pointer_cast<Service>(GetObject());
|
Service::Ptr service = static_pointer_cast<Service>(GetObject());
|
||||||
|
|
||||||
Host::Ptr host = service->GetHost();
|
Host::Ptr host = service->GetHost();
|
||||||
|
|
||||||
Dictionary::Ptr attrs;
|
|
||||||
|
|
||||||
{
|
|
||||||
ObjectLock olock(service);
|
|
||||||
attrs = CompatUtility::GetServiceConfigAttributes(service);
|
|
||||||
}
|
|
||||||
|
|
||||||
fields->Set("host_object_id", host);
|
fields->Set("host_object_id", host);
|
||||||
fields->Set("display_name", service->GetDisplayName());
|
fields->Set("display_name", service->GetDisplayName());
|
||||||
fields->Set("check_command_object_id", service->GetCheckCommand());
|
fields->Set("check_command_object_id", service->GetCheckCommand());
|
||||||
fields->Set("check_command_args", Empty);
|
fields->Set("check_command_args", Empty);
|
||||||
fields->Set("eventhandler_command_object_id", service->GetEventCommand());
|
fields->Set("eventhandler_command_object_id", service->GetEventCommand());
|
||||||
fields->Set("eventhandler_command_args", Empty);
|
fields->Set("eventhandler_command_args", Empty);
|
||||||
fields->Set("notification_timeperiod_object_id", Notification::GetByName(attrs->Get("notification_period")));
|
fields->Set("notification_timeperiod_object_id", Notification::GetByName(CompatUtility::GetServiceNotificationNotificationPeriod(service)));
|
||||||
fields->Set("check_timeperiod_object_id", service->GetCheckPeriod());
|
fields->Set("check_timeperiod_object_id", service->GetCheckPeriod());
|
||||||
fields->Set("failure_prediction_options", Empty);
|
fields->Set("failure_prediction_options", Empty);
|
||||||
fields->Set("check_interval", attrs->Get("check_interval"));
|
fields->Set("check_interval", CompatUtility::GetServiceCheckInterval(service));
|
||||||
fields->Set("retry_interval", attrs->Get("retry_interval"));
|
fields->Set("retry_interval", CompatUtility::GetServiceRetryInterval(service));
|
||||||
fields->Set("max_check_attempts", attrs->Get("max_check_attempts"));
|
fields->Set("max_check_attempts", service->GetMaxCheckAttempts());
|
||||||
fields->Set("first_notification_delay", Empty);
|
fields->Set("first_notification_delay", Empty);
|
||||||
fields->Set("notification_interval", attrs->Get("notification_interval"));
|
fields->Set("notification_interval", CompatUtility::GetServiceNotificationNotificationInterval(service));
|
||||||
fields->Set("notify_on_warning", attrs->Get("notify_on_warning"));
|
fields->Set("notify_on_warning", CompatUtility::GetServiceNotifyOnWarning(service));
|
||||||
fields->Set("notify_on_unknown", attrs->Get("notify_on_unknown"));
|
fields->Set("notify_on_unknown", CompatUtility::GetServiceNotifyOnUnknown(service));
|
||||||
fields->Set("notify_on_critical", attrs->Get("notify_on_critical"));
|
fields->Set("notify_on_critical", CompatUtility::GetServiceNotifyOnCritical(service));
|
||||||
fields->Set("notify_on_recovery", attrs->Get("notify_on_recovery"));
|
fields->Set("notify_on_recovery", CompatUtility::GetServiceNotifyOnRecovery(service));
|
||||||
fields->Set("notify_on_flapping", attrs->Get("notify_on_flapping"));
|
fields->Set("notify_on_flapping", CompatUtility::GetServiceNotifyOnFlapping(service));
|
||||||
fields->Set("notify_on_downtime", attrs->Get("notify_on_downtime"));
|
fields->Set("notify_on_downtime", CompatUtility::GetServiceNotifyOnDowntime(service));
|
||||||
fields->Set("stalk_on_ok", 0);
|
fields->Set("stalk_on_ok", 0);
|
||||||
fields->Set("stalk_on_warning", 0);
|
fields->Set("stalk_on_warning", 0);
|
||||||
fields->Set("stalk_on_unknown", 0);
|
fields->Set("stalk_on_unknown", 0);
|
||||||
fields->Set("stalk_on_critical", 0);
|
fields->Set("stalk_on_critical", 0);
|
||||||
fields->Set("is_volatile", attrs->Get("is_volatile"));
|
fields->Set("is_volatile", CompatUtility::GetServiceIsVolatile(service));
|
||||||
fields->Set("flap_detection_enabled", attrs->Get("flap_detection_enabled"));
|
fields->Set("flap_detection_enabled", CompatUtility::GetServiceFlapDetectionEnabled(service));
|
||||||
fields->Set("flap_detection_on_ok", Empty);
|
fields->Set("flap_detection_on_ok", Empty);
|
||||||
fields->Set("flap_detection_on_warning", Empty);
|
fields->Set("flap_detection_on_warning", Empty);
|
||||||
fields->Set("flap_detection_on_unknown", Empty);
|
fields->Set("flap_detection_on_unknown", Empty);
|
||||||
fields->Set("flap_detection_on_critical", Empty);
|
fields->Set("flap_detection_on_critical", Empty);
|
||||||
fields->Set("low_flap_threshold", attrs->Get("low_flap_threshold"));
|
fields->Set("low_flap_threshold", CompatUtility::GetServiceLowFlapThreshold(service));
|
||||||
fields->Set("high_flap_threshold", attrs->Get("high_flap_threshold"));
|
fields->Set("high_flap_threshold", CompatUtility::GetServiceHighFlapThreshold(service));
|
||||||
fields->Set("process_performance_data", attrs->Get("process_performance_data"));
|
fields->Set("process_performance_data", CompatUtility::GetServiceProcessPerformanceData(service));
|
||||||
fields->Set("freshness_checks_enabled", attrs->Get("freshness_checks_enabled"));
|
fields->Set("freshness_checks_enabled", CompatUtility::GetServiceFreshnessChecksEnabled(service));
|
||||||
fields->Set("freshness_threshold", Empty);
|
fields->Set("freshness_threshold", CompatUtility::GetServiceFreshnessThreshold(service));
|
||||||
fields->Set("passive_checks_enabled", attrs->Get("passive_checks_enabled"));
|
fields->Set("passive_checks_enabled", CompatUtility::GetServicePassiveChecksEnabled(service));
|
||||||
fields->Set("event_handler_enabled", attrs->Get("event_handler_enabled"));
|
fields->Set("event_handler_enabled", CompatUtility::GetServiceEventHandlerEnabled(service));
|
||||||
fields->Set("active_checks_enabled", attrs->Get("active_checks_enabled"));
|
fields->Set("active_checks_enabled", CompatUtility::GetServiceActiveChecksEnabled(service));
|
||||||
fields->Set("retain_status_information", Empty);
|
fields->Set("retain_status_information", Empty);
|
||||||
fields->Set("retain_nonstatus_information", Empty);
|
fields->Set("retain_nonstatus_information", Empty);
|
||||||
fields->Set("notifications_enabled", attrs->Get("notifications_enabled"));
|
fields->Set("notifications_enabled", CompatUtility::GetServiceNotificationsEnabled(service));
|
||||||
fields->Set("obsess_over_service", Empty);
|
fields->Set("obsess_over_service", Empty);
|
||||||
fields->Set("failure_prediction_enabled", Empty);
|
fields->Set("failure_prediction_enabled", Empty);
|
||||||
fields->Set("notes", attrs->Get("notes"));
|
fields->Set("notes", CompatUtility::GetCustomAttributeConfig(service, "notes"));
|
||||||
fields->Set("notes_url", attrs->Get("notes_url"));
|
fields->Set("notes_url", CompatUtility::GetCustomAttributeConfig(service, "notes_url"));
|
||||||
fields->Set("action_url", attrs->Get("action_url"));
|
fields->Set("action_url", CompatUtility::GetCustomAttributeConfig(service, "action_url"));
|
||||||
fields->Set("icon_image", attrs->Get("icon_image"));
|
fields->Set("icon_image", CompatUtility::GetCustomAttributeConfig(service, "icon_image"));
|
||||||
fields->Set("icon_image_alt", attrs->Get("icon_image_alt"));
|
fields->Set("icon_image_alt", CompatUtility::GetCustomAttributeConfig(service, "icon_image_alt"));
|
||||||
|
|
||||||
return fields;
|
return fields;
|
||||||
}
|
}
|
||||||
|
@ -145,55 +137,60 @@ Dictionary::Ptr ServiceDbObject::GetStatusFields(void) const
|
||||||
{
|
{
|
||||||
Dictionary::Ptr fields = make_shared<Dictionary>();
|
Dictionary::Ptr fields = make_shared<Dictionary>();
|
||||||
Service::Ptr service = static_pointer_cast<Service>(GetObject());
|
Service::Ptr service = static_pointer_cast<Service>(GetObject());
|
||||||
Dictionary::Ptr attrs;
|
CheckResult::Ptr cr = service->GetLastCheckResult();
|
||||||
|
|
||||||
{
|
if (cr) {
|
||||||
ObjectLock olock(service);
|
fields->Set("output", CompatUtility::GetCheckResultOutput(cr));
|
||||||
attrs = CompatUtility::GetServiceStatusAttributes(service, CompatTypeService);
|
fields->Set("long_output", CompatUtility::GetCheckResultLongOutput(cr));
|
||||||
|
fields->Set("perfdata", CompatUtility::GetCheckResultPerfdata(cr));
|
||||||
|
fields->Set("check_source", cr->GetCheckSource());
|
||||||
}
|
}
|
||||||
|
|
||||||
fields->Set("output", attrs->Get("plugin_output"));
|
fields->Set("current_state", CompatUtility::GetServiceCurrentState(service));
|
||||||
fields->Set("long_output", attrs->Get("long_plugin_output"));
|
fields->Set("has_been_checked", CompatUtility::GetServiceHasBeenChecked(service));
|
||||||
fields->Set("perfdata", attrs->Get("performance_data"));
|
fields->Set("should_be_scheduled", CompatUtility::GetServiceShouldBeScheduled(service));
|
||||||
fields->Set("check_source", attrs->Get("check_source"));
|
fields->Set("current_check_attempt", service->GetCheckAttempt());
|
||||||
fields->Set("current_state", attrs->Get("current_state"));
|
fields->Set("max_check_attempts", service->GetMaxCheckAttempts());
|
||||||
fields->Set("has_been_checked", attrs->Get("has_been_checked"));
|
|
||||||
fields->Set("should_be_scheduled", attrs->Get("should_be_scheduled"));
|
if (cr)
|
||||||
fields->Set("current_check_attempt", attrs->Get("current_attempt"));
|
fields->Set("last_check", DbValue::FromTimestamp(cr->GetScheduleEnd()));
|
||||||
fields->Set("max_check_attempts", attrs->Get("max_attempts"));
|
|
||||||
fields->Set("last_check", DbValue::FromTimestamp(attrs->Get("last_check")));
|
fields->Set("next_check", DbValue::FromTimestamp(service->GetNextCheck()));
|
||||||
fields->Set("next_check", DbValue::FromTimestamp(attrs->Get("next_check")));
|
fields->Set("check_type", CompatUtility::GetServiceCheckType(service));
|
||||||
fields->Set("check_type", attrs->Get("check_type"));
|
fields->Set("last_state_change", DbValue::FromTimestamp(service->GetLastStateChange()));
|
||||||
fields->Set("last_state_change", DbValue::FromTimestamp(attrs->Get("last_state_change")));
|
fields->Set("last_hard_state_change", DbValue::FromTimestamp(service->GetLastHardStateChange()));
|
||||||
fields->Set("last_hard_state_change", DbValue::FromTimestamp(attrs->Get("last_hard_state_change")));
|
fields->Set("last_time_ok", DbValue::FromTimestamp(static_cast<int>(service->GetLastStateOK())));
|
||||||
fields->Set("last_time_ok", DbValue::FromTimestamp(attrs->Get("last_time_ok")));
|
fields->Set("last_time_warning", DbValue::FromTimestamp(static_cast<int>(service->GetLastStateWarning())));
|
||||||
fields->Set("last_time_warning", DbValue::FromTimestamp(attrs->Get("last_time_warn")));
|
fields->Set("last_time_critical", DbValue::FromTimestamp(static_cast<int>(service->GetLastStateCritical())));
|
||||||
fields->Set("last_time_critical", DbValue::FromTimestamp(attrs->Get("last_time_critical")));
|
fields->Set("last_time_unknown", DbValue::FromTimestamp(static_cast<int>(service->GetLastStateUnknown())));
|
||||||
fields->Set("last_time_unknown", DbValue::FromTimestamp(attrs->Get("last_time_unknown")));
|
fields->Set("state_type", service->GetStateType());
|
||||||
fields->Set("state_type", attrs->Get("state_type"));
|
fields->Set("last_notification", DbValue::FromTimestamp(CompatUtility::GetServiceNotificationLastNotification(service)));
|
||||||
fields->Set("last_notification", DbValue::FromTimestamp(attrs->Get("last_notification")));
|
fields->Set("next_notification", DbValue::FromTimestamp(CompatUtility::GetServiceNotificationNextNotification(service)));
|
||||||
fields->Set("next_notification", DbValue::FromTimestamp(attrs->Get("next_notification")));
|
|
||||||
fields->Set("no_more_notifications", Empty);
|
fields->Set("no_more_notifications", Empty);
|
||||||
fields->Set("notifications_enabled", attrs->Get("notifications_enabled"));
|
fields->Set("notifications_enabled", CompatUtility::GetServiceNotificationsEnabled(service));
|
||||||
fields->Set("problem_has_been_acknowledged", attrs->Get("problem_has_been_acknowledged"));
|
fields->Set("problem_has_been_acknowledged", CompatUtility::GetServiceProblemHasBeenAcknowledged(service));
|
||||||
fields->Set("acknowledgement_type", attrs->Get("acknowledgement_type"));
|
fields->Set("acknowledgement_type", CompatUtility::GetServiceAcknowledgementType(service));
|
||||||
fields->Set("current_notification_number", attrs->Get("current_notification_number"));
|
fields->Set("current_notification_number", CompatUtility::GetServiceNotificationNotificationNumber(service));
|
||||||
fields->Set("passive_checks_enabled", attrs->Get("passive_checks_enabled"));
|
fields->Set("passive_checks_enabled", CompatUtility::GetServicePassiveChecksEnabled(service));
|
||||||
fields->Set("active_checks_enabled", attrs->Get("active_checks_enabled"));
|
fields->Set("active_checks_enabled", CompatUtility::GetServiceActiveChecksEnabled(service));
|
||||||
fields->Set("event_handler_enabled", attrs->Get("event_handler_enabled"));
|
fields->Set("event_handler_enabled", CompatUtility::GetServiceEventHandlerEnabled(service));
|
||||||
fields->Set("flap_detection_enabled", attrs->Get("flap_detection_enabled"));
|
fields->Set("flap_detection_enabled", CompatUtility::GetServiceFlapDetectionEnabled(service));
|
||||||
fields->Set("is_flapping", attrs->Get("is_flapping"));
|
fields->Set("is_flapping", CompatUtility::GetServiceIsFlapping(service));
|
||||||
fields->Set("percent_state_change", attrs->Get("percent_state_change"));
|
fields->Set("percent_state_change", CompatUtility::GetServicePercentStateChange(service));
|
||||||
fields->Set("latency", attrs->Get("check_latency"));
|
|
||||||
fields->Set("execution_time", attrs->Get("check_execution_time"));
|
if (cr) {
|
||||||
fields->Set("scheduled_downtime_depth", attrs->Get("scheduled_downtime_depth"));
|
fields->Set("latency", Service::CalculateLatency(cr));
|
||||||
fields->Set("process_performance_data", attrs->Get("process_performance_data"));
|
fields->Set("execution_time", Service::CalculateExecutionTime(cr));
|
||||||
fields->Set("event_handler", attrs->Get("event_handler"));
|
}
|
||||||
fields->Set("check_command", attrs->Get("check_command"));
|
|
||||||
fields->Set("normal_check_interval", attrs->Get("check_interval"));
|
fields->Set("scheduled_downtime_depth", service->GetDowntimeDepth());
|
||||||
fields->Set("retry_check_interval", attrs->Get("retry_interval"));
|
fields->Set("process_performance_data", CompatUtility::GetServiceProcessPerformanceData(service));
|
||||||
|
fields->Set("event_handler", CompatUtility::GetServiceEventHandler(service));
|
||||||
|
fields->Set("check_command", CompatUtility::GetServiceCheckCommand(service));
|
||||||
|
fields->Set("normal_check_interval", CompatUtility::GetServiceCheckInterval(service));
|
||||||
|
fields->Set("retry_check_interval", CompatUtility::GetServiceRetryInterval(service));
|
||||||
fields->Set("check_timeperiod_object_id", service->GetCheckPeriod());
|
fields->Set("check_timeperiod_object_id", service->GetCheckPeriod());
|
||||||
fields->Set("modified_service_attributes", attrs->Get("modified_attributes"));
|
fields->Set("modified_service_attributes", service->GetModifiedAttributes());
|
||||||
|
|
||||||
return fields;
|
return fields;
|
||||||
}
|
}
|
||||||
|
@ -739,7 +736,7 @@ void ServiceDbObject::AddAcknowledgementHistory(const Service::Ptr& service, con
|
||||||
fields1->Set("entry_time_usec", time_bag.second);
|
fields1->Set("entry_time_usec", time_bag.second);
|
||||||
fields1->Set("acknowledgement_type", type);
|
fields1->Set("acknowledgement_type", type);
|
||||||
fields1->Set("object_id", service);
|
fields1->Set("object_id", service);
|
||||||
fields1->Set("state", service->GetState());
|
fields1->Set("state", CompatUtility::GetServiceCurrentState(service));
|
||||||
fields1->Set("author_name", author);
|
fields1->Set("author_name", author);
|
||||||
fields1->Set("comment_data", comment);
|
fields1->Set("comment_data", comment);
|
||||||
fields1->Set("is_sticky", type == AcknowledgementSticky ? 1 : 0);
|
fields1->Set("is_sticky", type == AcknowledgementSticky ? 1 : 0);
|
||||||
|
@ -813,12 +810,11 @@ void ServiceDbObject::AddNotificationHistory(const Service::Ptr& service, const
|
||||||
fields1->Set("start_time_usec", time_bag.second);
|
fields1->Set("start_time_usec", time_bag.second);
|
||||||
fields1->Set("end_time", DbValue::FromTimestamp(time_bag.first));
|
fields1->Set("end_time", DbValue::FromTimestamp(time_bag.first));
|
||||||
fields1->Set("end_time_usec", time_bag.second);
|
fields1->Set("end_time_usec", time_bag.second);
|
||||||
fields1->Set("state", service->GetState());
|
fields1->Set("state", CompatUtility::GetServiceCurrentState(service));
|
||||||
|
|
||||||
if (cr) {
|
if (cr) {
|
||||||
std::pair<String, String> output_bag = CompatUtility::GetCheckResultOutput(cr);
|
fields1->Set("output", CompatUtility::GetCheckResultOutput(cr));
|
||||||
fields1->Set("output", output_bag.first);
|
fields1->Set("long_output", CompatUtility::GetCheckResultLongOutput(cr));
|
||||||
fields1->Set("long_output", output_bag.second);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
fields1->Set("escalated", 0);
|
fields1->Set("escalated", 0);
|
||||||
|
@ -858,7 +854,7 @@ void ServiceDbObject::AddStateChangeHistory(const Service::Ptr& service, const C
|
||||||
fields1->Set("state_time_usec", time_bag.second);
|
fields1->Set("state_time_usec", time_bag.second);
|
||||||
fields1->Set("object_id", service);
|
fields1->Set("object_id", service);
|
||||||
fields1->Set("state_change", 1); /* service */
|
fields1->Set("state_change", 1); /* service */
|
||||||
fields1->Set("state", service->GetState());
|
fields1->Set("state", CompatUtility::GetServiceCurrentState(service));
|
||||||
fields1->Set("state_type", service->GetStateType());
|
fields1->Set("state_type", service->GetStateType());
|
||||||
fields1->Set("current_check_attempt", service->GetCheckAttempt());
|
fields1->Set("current_check_attempt", service->GetCheckAttempt());
|
||||||
fields1->Set("max_check_attempts", service->GetMaxCheckAttempts());
|
fields1->Set("max_check_attempts", service->GetMaxCheckAttempts());
|
||||||
|
@ -866,9 +862,8 @@ void ServiceDbObject::AddStateChangeHistory(const Service::Ptr& service, const C
|
||||||
fields1->Set("last_hard_state", service->GetLastHardState());
|
fields1->Set("last_hard_state", service->GetLastHardState());
|
||||||
|
|
||||||
if (cr) {
|
if (cr) {
|
||||||
std::pair<String, String> output_bag = CompatUtility::GetCheckResultOutput(cr);
|
fields1->Set("output", CompatUtility::GetCheckResultOutput(cr));
|
||||||
fields1->Set("output", output_bag.first);
|
fields1->Set("long_output", CompatUtility::GetCheckResultLongOutput(cr));
|
||||||
fields1->Set("long_output", output_bag.second);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
fields1->Set("instance_id", 0); /* DbConnection class fills in real ID */
|
fields1->Set("instance_id", 0); /* DbConnection class fills in real ID */
|
||||||
|
@ -937,10 +932,8 @@ void ServiceDbObject::AddCheckResultLogHistory(const Service::Ptr& service, cons
|
||||||
|
|
||||||
String output;
|
String output;
|
||||||
|
|
||||||
if (cr) {
|
if (cr)
|
||||||
std::pair<String, String> output_bag = CompatUtility::GetCheckResultOutput(cr);
|
output = CompatUtility::GetCheckResultOutput(cr);
|
||||||
output = output_bag.first;
|
|
||||||
}
|
|
||||||
|
|
||||||
std::ostringstream msgbuf;
|
std::ostringstream msgbuf;
|
||||||
msgbuf << "SERVICE ALERT: "
|
msgbuf << "SERVICE ALERT: "
|
||||||
|
@ -1076,10 +1069,8 @@ void ServiceDbObject::AddNotificationSentLogHistory(const Service::Ptr& service,
|
||||||
|
|
||||||
String output;
|
String output;
|
||||||
|
|
||||||
if (cr) {
|
if (cr)
|
||||||
std::pair<String, String> output_bag = CompatUtility::GetCheckResultOutput(cr);
|
output = CompatUtility::GetCheckResultOutput(cr);
|
||||||
output = output_bag.first;
|
|
||||||
}
|
|
||||||
|
|
||||||
std::ostringstream msgbuf;
|
std::ostringstream msgbuf;
|
||||||
msgbuf << "SERVICE NOTIFICATION: "
|
msgbuf << "SERVICE NOTIFICATION: "
|
||||||
|
@ -1251,6 +1242,9 @@ void ServiceDbObject::AddFlappingHistory(const Service::Ptr& service, FlappingSt
|
||||||
/* servicechecks */
|
/* servicechecks */
|
||||||
void ServiceDbObject::AddServiceCheckHistory(const Service::Ptr& service, const CheckResult::Ptr &cr)
|
void ServiceDbObject::AddServiceCheckHistory(const Service::Ptr& service, const CheckResult::Ptr &cr)
|
||||||
{
|
{
|
||||||
|
if (!cr)
|
||||||
|
return;
|
||||||
|
|
||||||
Host::Ptr host = service->GetHost();
|
Host::Ptr host = service->GetHost();
|
||||||
|
|
||||||
Log(LogDebug, "db_ido", "add service check history for '" + service->GetName() + "'");
|
Log(LogDebug, "db_ido", "add service check history for '" + service->GetName() + "'");
|
||||||
|
@ -1261,38 +1255,33 @@ void ServiceDbObject::AddServiceCheckHistory(const Service::Ptr& service, const
|
||||||
query1.Category = DbCatCheck;
|
query1.Category = DbCatCheck;
|
||||||
|
|
||||||
Dictionary::Ptr fields1 = make_shared<Dictionary>();
|
Dictionary::Ptr fields1 = make_shared<Dictionary>();
|
||||||
Dictionary::Ptr attrs;
|
double execution_time = Service::CalculateExecutionTime(cr);
|
||||||
|
|
||||||
{
|
fields1->Set("check_type", CompatUtility::GetServiceCheckType(service));
|
||||||
ObjectLock olock(service);
|
fields1->Set("current_check_attempt", service->GetCheckAttempt());
|
||||||
attrs = CompatUtility::GetServiceStatusAttributes(service, CompatTypeService);
|
fields1->Set("max_check_attempts", service->GetMaxCheckAttempts());
|
||||||
}
|
fields1->Set("state", CompatUtility::GetServiceCurrentState(service));
|
||||||
|
fields1->Set("state_type", service->GetStateType());
|
||||||
fields1->Set("check_type", attrs->Get("check_type"));
|
|
||||||
fields1->Set("current_check_attempt", attrs->Get("current_attempt"));
|
|
||||||
fields1->Set("max_check_attempts", attrs->Get("max_attempts"));
|
|
||||||
fields1->Set("state", attrs->Get("current_state"));
|
|
||||||
fields1->Set("state_type", attrs->Get("state_type"));
|
|
||||||
|
|
||||||
double now = Utility::GetTime();
|
double now = Utility::GetTime();
|
||||||
std::pair<unsigned long, unsigned long> time_bag = CompatUtility::ConvertTimestamp(now);
|
std::pair<unsigned long, unsigned long> time_bag = CompatUtility::ConvertTimestamp(now);
|
||||||
|
|
||||||
double end = now + attrs->Get("check_execution_time");
|
double end = now + execution_time;
|
||||||
std::pair<unsigned long, unsigned long> time_bag_end = CompatUtility::ConvertTimestamp(now);
|
std::pair<unsigned long, unsigned long> time_bag_end = CompatUtility::ConvertTimestamp(end);
|
||||||
|
|
||||||
fields1->Set("start_time", DbValue::FromTimestamp(time_bag.first));
|
fields1->Set("start_time", DbValue::FromTimestamp(time_bag.first));
|
||||||
fields1->Set("start_time_usec", time_bag.second);
|
fields1->Set("start_time_usec", time_bag.second);
|
||||||
fields1->Set("end_time", DbValue::FromTimestamp(time_bag.first));
|
fields1->Set("end_time", DbValue::FromTimestamp(time_bag_end.first));
|
||||||
fields1->Set("end_time_usec", time_bag.second);
|
fields1->Set("end_time_usec", time_bag_end.second);
|
||||||
fields1->Set("command_object_id", service->GetCheckCommand());
|
fields1->Set("command_object_id", service->GetCheckCommand());
|
||||||
fields1->Set("command_args", Empty);
|
fields1->Set("command_args", Empty);
|
||||||
fields1->Set("command_line", cr->GetCommand());
|
fields1->Set("command_line", cr->GetCommand());
|
||||||
fields1->Set("execution_time", attrs->Get("check_execution_time"));
|
fields1->Set("execution_time", execution_time);
|
||||||
fields1->Set("latency", attrs->Get("check_latency"));
|
fields1->Set("latency", Service::CalculateLatency(cr));
|
||||||
fields1->Set("return_code", cr->GetExitStatus());
|
fields1->Set("return_code", cr->GetExitStatus());
|
||||||
fields1->Set("output", attrs->Get("plugin_output"));
|
fields1->Set("output", CompatUtility::GetCheckResultOutput(cr));
|
||||||
fields1->Set("long_output", attrs->Get("long_plugin_output"));
|
fields1->Set("long_output", CompatUtility::GetCheckResultLongOutput(cr));
|
||||||
fields1->Set("perfdata", attrs->Get("performance_data"));
|
fields1->Set("perfdata", CompatUtility::GetCheckResultPerfdata(cr));
|
||||||
|
|
||||||
fields1->Set("instance_id", 0); /* DbConnection class fills in real ID */
|
fields1->Set("instance_id", 0); /* DbConnection class fills in real ID */
|
||||||
|
|
||||||
|
@ -1331,7 +1320,7 @@ void ServiceDbObject::AddEventHandlerHistory(const Service::Ptr& service)
|
||||||
|
|
||||||
fields1->Set("eventhandler_type", 1); /* service */
|
fields1->Set("eventhandler_type", 1); /* service */
|
||||||
fields1->Set("object_id", service);
|
fields1->Set("object_id", service);
|
||||||
fields1->Set("state", service->GetState());
|
fields1->Set("state", CompatUtility::GetServiceCurrentState(service));
|
||||||
fields1->Set("state_type", service->GetStateType());
|
fields1->Set("state_type", service->GetStateType());
|
||||||
|
|
||||||
fields1->Set("start_time", DbValue::FromTimestamp(time_bag.first));
|
fields1->Set("start_time", DbValue::FromTimestamp(time_bag.first));
|
||||||
|
|
File diff suppressed because it is too large
Load Diff
|
@ -39,6 +39,12 @@ enum CompatObjectType
|
||||||
CompatTypeHost
|
CompatTypeHost
|
||||||
};
|
};
|
||||||
|
|
||||||
|
typedef struct {
|
||||||
|
int have_2d_coords;
|
||||||
|
String x_2d;
|
||||||
|
String y_2d;
|
||||||
|
} Host2dCoords;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Compatibility utility functions.
|
* Compatibility utility functions.
|
||||||
*
|
*
|
||||||
|
@ -47,21 +53,80 @@ enum CompatObjectType
|
||||||
class I2_ICINGA_API CompatUtility
|
class I2_ICINGA_API CompatUtility
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
static Dictionary::Ptr GetHostConfigAttributes(const Host::Ptr& host);
|
|
||||||
|
|
||||||
static Dictionary::Ptr GetServiceStatusAttributes(const Service::Ptr& service, CompatObjectType type);
|
/* host */
|
||||||
static Dictionary::Ptr GetServiceConfigAttributes(const Service::Ptr& service);
|
static String GetHostAlias(const Host::Ptr& host);
|
||||||
|
static String GetHostAddress(const Host::Ptr& host);
|
||||||
|
static String GetHostAddress6(const Host::Ptr& host);
|
||||||
|
static Host2dCoords GetHost2dCoords(const Host::Ptr& host);
|
||||||
|
static int GetHostNotifyOnDown(const Host::Ptr& host);
|
||||||
|
static int GetHostNotifyOnUnreachable(const Host::Ptr& host);
|
||||||
|
|
||||||
static Dictionary::Ptr GetCommandConfigAttributes(const Command::Ptr& command);
|
/* service */
|
||||||
|
static int GetServiceCurrentState(const Service::Ptr& service);
|
||||||
|
static int GetServiceShouldBeScheduled(const Service::Ptr& service);
|
||||||
|
static int GetServiceCheckType(const Service::Ptr& service);
|
||||||
|
static double GetServiceCheckInterval(const Service::Ptr& service);
|
||||||
|
static double GetServiceRetryInterval(const Service::Ptr& service);
|
||||||
|
static String GetServiceCheckPeriod(const Service::Ptr& service);
|
||||||
|
static int GetServiceHasBeenChecked(const Service::Ptr& service);
|
||||||
|
static int GetServiceProblemHasBeenAcknowledged(const Service::Ptr& service);
|
||||||
|
static int GetServiceAcknowledgementType(const Service::Ptr& service);
|
||||||
|
static int GetServicePassiveChecksEnabled(const Service::Ptr& service);
|
||||||
|
static int GetServiceActiveChecksEnabled(const Service::Ptr& service);
|
||||||
|
static int GetServiceEventHandlerEnabled(const Service::Ptr& service);
|
||||||
|
static int GetServiceFlapDetectionEnabled(const Service::Ptr& service);
|
||||||
|
static int GetServiceIsFlapping(const Service::Ptr& service);
|
||||||
|
static String GetServicePercentStateChange(const Service::Ptr& service);
|
||||||
|
static int GetServiceProcessPerformanceData(const Service::Ptr& service);
|
||||||
|
|
||||||
static Dictionary::Ptr GetCustomVariableConfig(const DynamicObject::Ptr& object);
|
static String GetServiceEventHandler(const Service::Ptr& service);
|
||||||
|
static String GetServiceCheckCommand(const Service::Ptr& service);
|
||||||
|
|
||||||
|
static int GetServiceIsVolatile(const Service::Ptr& service);
|
||||||
|
static double GetServiceLowFlapThreshold(const Service::Ptr& service);
|
||||||
|
static double GetServiceHighFlapThreshold(const Service::Ptr& service);
|
||||||
|
static int GetServiceFreshnessChecksEnabled(const Service::Ptr& service);
|
||||||
|
static int GetServiceFreshnessThreshold(const Service::Ptr& service);
|
||||||
|
static double GetServiceStaleness(const Service::Ptr& service);
|
||||||
|
static int GetServiceIsAcknowledged(const Service::Ptr& service);
|
||||||
|
static int GetServiceNoMoreNotifications(const Service::Ptr& service);
|
||||||
|
static int GetServiceInCheckPeriod(const Service::Ptr& service);
|
||||||
|
static int GetServiceInNotificationPeriod(const Service::Ptr& service);
|
||||||
|
|
||||||
|
/* notification */
|
||||||
|
static int GetServiceNotificationsEnabled(const Service::Ptr& service);
|
||||||
|
static int GetServiceNotificationLastNotification(const Service::Ptr& service);
|
||||||
|
static int GetServiceNotificationNextNotification(const Service::Ptr& service);
|
||||||
|
static int GetServiceNotificationNotificationNumber(const Service::Ptr& service);
|
||||||
|
static double GetServiceNotificationNotificationInterval(const Service::Ptr& service);
|
||||||
|
static String GetServiceNotificationNotificationPeriod(const Service::Ptr& service);
|
||||||
|
static String GetServiceNotificationNotificationOptions(const Service::Ptr& service);
|
||||||
|
static int GetServiceNotificationTypeFilter(const Service::Ptr& service);
|
||||||
|
static int GetServiceNotificationStateFilter(const Service::Ptr& service);
|
||||||
|
static int GetServiceNotifyOnWarning(const Service::Ptr& service);
|
||||||
|
static int GetServiceNotifyOnCritical(const Service::Ptr& service);
|
||||||
|
static int GetServiceNotifyOnUnknown(const Service::Ptr& service);
|
||||||
|
static int GetServiceNotifyOnRecovery(const Service::Ptr& service);
|
||||||
|
static int GetServiceNotifyOnFlapping(const Service::Ptr& service);
|
||||||
|
static int GetServiceNotifyOnDowntime(const Service::Ptr& service);
|
||||||
|
|
||||||
static std::set<User::Ptr> GetServiceNotificationUsers(const Service::Ptr& service);
|
static std::set<User::Ptr> GetServiceNotificationUsers(const Service::Ptr& service);
|
||||||
static std::set<UserGroup::Ptr> GetServiceNotificationUserGroups(const Service::Ptr& service);
|
static std::set<UserGroup::Ptr> GetServiceNotificationUserGroups(const Service::Ptr& service);
|
||||||
|
|
||||||
static std::pair<String, String> GetCheckResultOutput(const CheckResult::Ptr& cr);
|
/* command */
|
||||||
|
static String GetCommandLine(const Command::Ptr& command);
|
||||||
|
|
||||||
|
/* custom attribute */
|
||||||
|
static String GetCustomAttributeConfig(const DynamicObject::Ptr& object, const String& name);
|
||||||
|
static Dictionary::Ptr GetCustomVariableConfig(const DynamicObject::Ptr& object);
|
||||||
|
|
||||||
|
/* check result */
|
||||||
|
static String GetCheckResultOutput(const CheckResult::Ptr& cr);
|
||||||
|
static String GetCheckResultLongOutput(const CheckResult::Ptr& cr);
|
||||||
static String GetCheckResultPerfdata(const CheckResult::Ptr& cr);
|
static String GetCheckResultPerfdata(const CheckResult::Ptr& cr);
|
||||||
|
|
||||||
|
/* misc */
|
||||||
static std::pair<unsigned long, unsigned long> ConvertTimestamp(double time);
|
static std::pair<unsigned long, unsigned long> ConvertTimestamp(double time);
|
||||||
|
|
||||||
static int MapNotificationReasonType(NotificationType type);
|
static int MapNotificationReasonType(NotificationType type);
|
||||||
|
|
Loading…
Reference in New Issue