本文整理汇总了C++中servicegroup::Ptr类的典型用法代码示例。如果您正苦于以下问题:C++ Ptr类的具体用法?C++ Ptr怎么用?C++ Ptr使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了Ptr类的14个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: EvaluateObjectRule
bool ServiceGroup::EvaluateObjectRule(const Service::Ptr service, const ObjectRule& rule)
{
DebugInfo di = rule.GetDebugInfo();
std::ostringstream msgbuf;
msgbuf << "Evaluating 'object' rule (" << di << ")";
CONTEXT(msgbuf.str());
Host::Ptr host = service->GetHost();
Dictionary::Ptr locals = make_shared<Dictionary>();
locals->Set("host", host);
locals->Set("service", service);
if (!rule.EvaluateFilter(locals))
return false;
std::ostringstream msgbuf2;
msgbuf2 << "Assigning membership for group '" << rule.GetName() << "' to service '" << service->GetName() << "' for rule " << di;
Log(LogDebug, "icinga", msgbuf2.str());
String group_name = rule.GetName();
ServiceGroup::Ptr group = ServiceGroup::GetByName(group_name);
if (!group) {
Log(LogCritical, "icinga", "Invalid membership assignment. Group '" + group_name + "' does not exist.");
return false;
}
/* assign service group membership */
group->ResolveGroupMembership(service, true);
return true;
}
示例2: ResolveGroupMembership
bool ServiceGroup::ResolveGroupMembership(const Service::Ptr& service, bool add, int rstack) {
if (add && rstack > 20) {
Log(LogWarning, "ServiceGroup")
<< "Too many nested groups for group '" << GetName() << "': Service '"
<< service->GetName() << "' membership assignment failed.";
return false;
}
Array::Ptr groups = GetGroups();
if (groups && groups->GetLength() > 0) {
ObjectLock olock(groups);
for (const String& name : groups) {
ServiceGroup::Ptr group = ServiceGroup::GetByName(name);
if (group && !group->ResolveGroupMembership(service, add, rstack + 1))
return false;
}
}
if (add)
AddMember(service);
else
RemoveMember(service);
return true;
}
示例3: NotesAccessor
Value ServiceGroupsTable::NotesAccessor(const Value& row)
{
ServiceGroup::Ptr sg = static_cast<ServiceGroup::Ptr>(row);
if (!sg)
return Empty;
return sg->GetNotes();
}
示例4: AliasAccessor
Value ServiceGroupsTable::AliasAccessor(const Value& row)
{
ServiceGroup::Ptr sg = static_cast<ServiceGroup::Ptr>(row);
if (!sg)
return Empty;
return sg->GetDisplayName();
}
示例5: ActionUrlAccessor
Value ServiceGroupsTable::ActionUrlAccessor(const Value& row)
{
ServiceGroup::Ptr sg = static_cast<ServiceGroup::Ptr>(row);
if (!sg)
return Empty;
return sg->GetActionUrl();
}
示例6: GetConfigFields
Dictionary::Ptr ServiceGroupDbObject::GetConfigFields(void) const
{
Dictionary::Ptr fields = make_shared<Dictionary>();
ServiceGroup::Ptr group = static_pointer_cast<ServiceGroup>(GetObject());
fields->Set("alias", group->GetDisplayName());
return fields;
}
示例7: GetConfigFields
Dictionary::Ptr ServiceGroupDbObject::GetConfigFields(void) const
{
Dictionary::Ptr fields = new Dictionary();
ServiceGroup::Ptr group = static_pointer_cast<ServiceGroup>(GetObject());
fields->Set("alias", group->GetDisplayName());
fields->Set("notes", group->GetNotes());
fields->Set("notes_url", group->GetNotesUrl());
fields->Set("action_url", group->GetActionUrl());
return fields;
}
示例8: NumServicesHardUnknownAccessor
Value ServiceGroupsTable::NumServicesHardUnknownAccessor(const Value& row)
{
ServiceGroup::Ptr sg = static_cast<ServiceGroup::Ptr>(row);
if (!sg)
return Empty;
int num_services = 0;
for (const Service::Ptr& service : sg->GetMembers()) {
if (service->GetStateType() == StateTypeHard && service->GetState() == ServiceUnknown)
num_services++;
}
return num_services;
}
示例9: NumServicesPendingAccessor
Value ServiceGroupsTable::NumServicesPendingAccessor(const Value& row)
{
ServiceGroup::Ptr sg = static_cast<ServiceGroup::Ptr>(row);
if (!sg)
return Empty;
int num_services = 0;
for (const Service::Ptr& service : sg->GetMembers()) {
if (!service->GetLastCheckResult())
num_services++;
}
return num_services;
}
示例10: NumServicesCritAccessor
Value ServiceGroupsTable::NumServicesCritAccessor(const Value& row)
{
ServiceGroup::Ptr sg = static_cast<ServiceGroup::Ptr>(row);
if (!sg)
return Empty;
int num_services = 0;
for (const Service::Ptr& service : sg->GetMembers()) {
if (service->GetState() == ServiceCritical)
num_services++;
}
return num_services;
}
示例11: WorstServiceStateAccessor
Value ServiceGroupsTable::WorstServiceStateAccessor(const Value& row)
{
ServiceGroup::Ptr sg = static_cast<ServiceGroup::Ptr>(row);
if (!sg)
return Empty;
Value worst_service = ServiceOK;
for (const Service::Ptr& service : sg->GetMembers()) {
if (service->GetState() > worst_service)
worst_service = service->GetState();
}
return worst_service;
}
示例12: OnConfigUpdate
void ServiceGroupDbObject::OnConfigUpdate(void)
{
ServiceGroup::Ptr group = static_pointer_cast<ServiceGroup>(GetObject());
BOOST_FOREACH(const Service::Ptr& service, group->GetMembers()) {
DbQuery query1;
query1.Table = DbType::GetByName("ServiceGroup")->GetTable() + "_members";
query1.Type = DbQueryInsert;
query1.Category = DbCatConfig;
query1.Fields = make_shared<Dictionary>();
query1.Fields->Set("instance_id", 0); /* DbConnection class fills in real ID */
query1.Fields->Set("servicegroup_id", DbValue::FromObjectInsertID(group));
query1.Fields->Set("service_object_id", service);
OnQuery(query1);
}
}
示例13: MembersAccessor
Value ServiceGroupsTable::MembersAccessor(const Value& row)
{
ServiceGroup::Ptr sg = static_cast<ServiceGroup::Ptr>(row);
if (!sg)
return Empty;
ArrayData result;
for (const Service::Ptr& service : sg->GetMembers()) {
result.push_back(new Array({
service->GetHost()->GetName(),
service->GetShortName()
}));
}
return new Array(std::move(result));
}
示例14: DumpServiceObject
void StatusDataWriter::DumpServiceObject(std::ostream& fp, const Service::Ptr& service)
{
Host::Ptr host = service->GetHost();
{
ObjectLock olock(service);
fp << "define service {" "\n"
"\t" "host_name" "\t" << host->GetName() << "\n"
"\t" "service_description" "\t" << service->GetShortName() << "\n"
"\t" "display_name" "\t" << service->GetDisplayName() << "\n"
"\t" "check_interval" "\t" << (service->GetCheckInterval() / 60.0) << "\n"
"\t" "retry_interval" "\t" << (service->GetRetryInterval() / 60.0) << "\n"
"\t" "max_check_attempts" "\t" << service->GetMaxCheckAttempts() << "\n"
"\t" "active_checks_enabled" "\t" << Convert::ToLong(service->GetEnableActiveChecks()) << "\n"
"\t" "passive_checks_enabled" "\t" << Convert::ToLong(service->GetEnablePassiveChecks()) << "\n"
"\t" "flap_detection_enabled" "\t" << Convert::ToLong(service->GetEnableFlapping()) << "\n"
"\t" "is_volatile" "\t" << Convert::ToLong(service->GetVolatile()) << "\n"
"\t" "notifications_enabled" "\t" << Convert::ToLong(service->GetEnableNotifications()) << "\n"
"\t" "notification_options" "\t" << GetNotificationOptions(service) << "\n"
"\t" "notification_interval" "\t" << CompatUtility::GetCheckableNotificationNotificationInterval(service) << "\n"
"\t" "notification_period" "\t" << "" << "\n"
"\t" "event_handler_enabled" "\t" << Convert::ToLong(service->GetEnableEventHandler()) << "\n";
CheckCommand::Ptr checkcommand = service->GetCheckCommand();
if (checkcommand)
fp << "\t" "check_command" "\t" << CompatUtility::GetCommandName(checkcommand) << "!" << CompatUtility::GetCheckableCommandArgs(service)<< "\n";
EventCommand::Ptr eventcommand = service->GetEventCommand();
if (eventcommand && service->GetEnableEventHandler())
fp << "\t" "event_handler" "\t" << CompatUtility::GetCommandName(eventcommand) << "\n";
TimePeriod::Ptr checkPeriod = service->GetCheckPeriod();
if (checkPeriod)
fp << "\t" "check_period" "\t" << checkPeriod->GetName() << "\n";
fp << "\t" "contacts" "\t";
DumpNameList(fp, CompatUtility::GetCheckableNotificationUsers(service));
fp << "\n";
fp << "\t" "contact_groups" "\t";
DumpNameList(fp, CompatUtility::GetCheckableNotificationUserGroups(service));
fp << "\n";
String notes = service->GetNotes();
String notes_url = service->GetNotesUrl();
String action_url = service->GetActionUrl();
String icon_image = service->GetIconImage();
String icon_image_alt = service->GetIconImageAlt();
fp << "\t" "initial_state" "\t" "o" "\n"
"\t" "low_flap_threshold" "\t" << service->GetFlappingThresholdLow() << "\n"
"\t" "high_flap_threshold" "\t" << service->GetFlappingThresholdHigh() << "\n"
"\t" "process_perf_data" "\t" << Convert::ToLong(service->GetEnablePerfdata()) << "\n"
"\t" "check_freshness" << "\t" "1" "\n";
if (!notes.IsEmpty())
fp << "\t" "notes" "\t" << notes << "\n";
if (!notes_url.IsEmpty())
fp << "\t" "notes_url" "\t" << notes_url << "\n";
if (!action_url.IsEmpty())
fp << "\t" "action_url" "\t" << action_url << "\n";
if (!icon_image.IsEmpty())
fp << "\t" "icon_image" "\t" << icon_image << "\n";
if (!icon_image_alt.IsEmpty())
fp << "\t" "icon_image_alt" "\t" << icon_image_alt << "\n";
}
fp << "\t" "service_groups" "\t";
bool first = true;
Array::Ptr groups = service->GetGroups();
if (groups) {
ObjectLock olock(groups);
for (const String& name : groups) {
ServiceGroup::Ptr sg = ServiceGroup::GetByName(name);
if (sg) {
if (!first)
fp << ",";
else
first = false;
fp << sg->GetName();
}
}
}
fp << "\n";
DumpCustomAttributes(fp, service);
fp << "\t" "}" "\n" "\n";
}