mirror of
https://github.com/Icinga/icinga2.git
synced 2025-07-28 16:14:09 +02:00
compat: Refactor check_command/event_handler code.
This commit is contained in:
parent
acc2bdb875
commit
1179d37fa0
@ -385,6 +385,14 @@ void CompatComponent::DumpHostObject(std::ostream& fp, const Host::Ptr& host)
|
|||||||
<< "\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" << 1 << "\n";
|
||||||
|
|
||||||
|
CheckCommand::Ptr checkcommand = hc->GetCheckCommand();
|
||||||
|
if (checkcommand)
|
||||||
|
fp << "\t" << "check_command" << "\t" << "check_" << checkcommand->GetName() << "\n";
|
||||||
|
|
||||||
|
EventCommand::Ptr eventcommand = hc->GetEventCommand();
|
||||||
|
if (eventcommand)
|
||||||
|
fp << "\t" << "event_handler" << "\t" << "event_" << eventcommand->GetName() << "\n";
|
||||||
} else {
|
} else {
|
||||||
fp << "\t" << "check_interval" << "\t" << 60 << "\n"
|
fp << "\t" << "check_interval" << "\t" << 60 << "\n"
|
||||||
<< "\t" << "retry_interval" << "\t" << 60 << "\n"
|
<< "\t" << "retry_interval" << "\t" << 60 << "\n"
|
||||||
@ -416,18 +424,8 @@ void CompatComponent::DumpServiceStatusAttrs(std::ostream& fp, const Service::Pt
|
|||||||
String output;
|
String output;
|
||||||
String long_output;
|
String long_output;
|
||||||
String perfdata;
|
String perfdata;
|
||||||
String check_command;
|
|
||||||
String event_command;
|
|
||||||
double schedule_end = -1;
|
double schedule_end = -1;
|
||||||
|
|
||||||
CheckCommand::Ptr checkcommand = service->GetCheckCommand();
|
|
||||||
if (checkcommand)
|
|
||||||
check_command = checkcommand->GetName();
|
|
||||||
|
|
||||||
EventCommand::Ptr eventcommand = service->GetEventCommand();
|
|
||||||
if (eventcommand)
|
|
||||||
event_command = eventcommand->GetName();
|
|
||||||
|
|
||||||
String check_period_str;
|
String check_period_str;
|
||||||
TimePeriod::Ptr check_period = service->GetCheckPeriod();
|
TimePeriod::Ptr check_period = service->GetCheckPeriod();
|
||||||
if (check_period)
|
if (check_period)
|
||||||
@ -482,9 +480,15 @@ void CompatComponent::DumpServiceStatusAttrs(std::ostream& fp, const Service::Pt
|
|||||||
last_notification = notification->GetLastNotification();
|
last_notification = notification->GetLastNotification();
|
||||||
}
|
}
|
||||||
|
|
||||||
fp << "\t" << "check_command=check_" << check_command << "\n"
|
CheckCommand::Ptr checkcommand = service->GetCheckCommand();
|
||||||
<< "\t" << "check_period=" << check_period_str << "\n"
|
if (checkcommand)
|
||||||
<< "\t" << "event_handler=event_" << event_command << "\n"
|
fp << "\t" << "check_command=check_" << checkcommand->GetName() << "\n";
|
||||||
|
|
||||||
|
EventCommand::Ptr eventcommand = service->GetEventCommand();
|
||||||
|
if (eventcommand)
|
||||||
|
fp << "\t" << "event_handler=event_" << eventcommand->GetName() << "\n";
|
||||||
|
|
||||||
|
fp << "\t" << "check_period=" << check_period_str << "\n"
|
||||||
<< "\t" << "check_interval=" << service->GetCheckInterval() / 60.0 << "\n"
|
<< "\t" << "check_interval=" << service->GetCheckInterval() / 60.0 << "\n"
|
||||||
<< "\t" << "retry_interval=" << service->GetRetryInterval() / 60.0 << "\n"
|
<< "\t" << "retry_interval=" << service->GetRetryInterval() / 60.0 << "\n"
|
||||||
<< "\t" << "has_been_checked=" << (service->GetLastCheckResult() ? 1 : 0) << "\n"
|
<< "\t" << "has_been_checked=" << (service->GetLastCheckResult() ? 1 : 0) << "\n"
|
||||||
@ -546,18 +550,6 @@ void CompatComponent::DumpServiceObject(std::ostream& fp, const Service::Ptr& se
|
|||||||
if (!host)
|
if (!host)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
String check_command;
|
|
||||||
|
|
||||||
CheckCommand::Ptr checkcommand = service->GetCheckCommand();
|
|
||||||
if (checkcommand)
|
|
||||||
check_command = checkcommand->GetName();
|
|
||||||
|
|
||||||
String event_command;
|
|
||||||
|
|
||||||
EventCommand::Ptr eventcommand = service->GetEventCommand();
|
|
||||||
if (eventcommand)
|
|
||||||
event_command = eventcommand->GetName();
|
|
||||||
|
|
||||||
String check_period_str;
|
String check_period_str;
|
||||||
TimePeriod::Ptr check_period = service->GetCheckPeriod();
|
TimePeriod::Ptr check_period = service->GetCheckPeriod();
|
||||||
if (check_period)
|
if (check_period)
|
||||||
@ -582,7 +574,6 @@ void CompatComponent::DumpServiceObject(std::ostream& fp, const Service::Ptr& se
|
|||||||
<< "\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" << check_period_str << "\n"
|
||||||
<< "\t" << "check_command" << "\t" << "check_" << check_command << "\n"
|
|
||||||
<< "\t" << "check_interval" << "\t" << service->GetCheckInterval() / 60.0 << "\n"
|
<< "\t" << "check_interval" << "\t" << service->GetCheckInterval() / 60.0 << "\n"
|
||||||
<< "\t" << "retry_interval" << "\t" << service->GetRetryInterval() / 60.0 << "\n"
|
<< "\t" << "retry_interval" << "\t" << service->GetRetryInterval() / 60.0 << "\n"
|
||||||
<< "\t" << "max_check_attempts" << "\t" << service->GetMaxCheckAttempts() << "\n"
|
<< "\t" << "max_check_attempts" << "\t" << service->GetMaxCheckAttempts() << "\n"
|
||||||
@ -594,8 +585,13 @@ void CompatComponent::DumpServiceObject(std::ostream& fp, const Service::Ptr& se
|
|||||||
<< "\t" << "notification_options" << "\t" << "u,w,c,r" << "\n"
|
<< "\t" << "notification_options" << "\t" << "u,w,c,r" << "\n"
|
||||||
<< "\t" << "notification_interval" << "\t" << notification_interval / 60.0 << "\n";
|
<< "\t" << "notification_interval" << "\t" << notification_interval / 60.0 << "\n";
|
||||||
|
|
||||||
if (!event_command.IsEmpty())
|
CheckCommand::Ptr checkcommand = service->GetCheckCommand();
|
||||||
fp << "\t" << "event_handler" << "\t" << "event_" << event_command << "\n";
|
if (checkcommand)
|
||||||
|
fp << "\t" << "check_command" << "\t" << "check_" << checkcommand->GetName() << "\n";
|
||||||
|
|
||||||
|
EventCommand::Ptr eventcommand = service->GetEventCommand();
|
||||||
|
if (eventcommand)
|
||||||
|
fp << "\t" << "event_handler" << "\t" << "event_" << eventcommand->GetName() << "\n";
|
||||||
}
|
}
|
||||||
|
|
||||||
DumpCustomAttributes(fp, service);
|
DumpCustomAttributes(fp, service);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user