icinga2/lib/icinga/notification.ti
Yonas Habteab 186571ec99 Refresh the states & types bitsets whenever states & types attrs change
Since the types and states attributes are user configurable and allowed to change at
runtime, we need to update the actual filter bitsets whenever these attributes change.
Otherwise, the filter bitsets would be stale and not reflect their current state.
2025-06-06 13:31:44 +02:00

120 lines
3.1 KiB
Plaintext

/* Icinga 2 | (c) 2012 Icinga GmbH | GPLv2+ */
#include "icinga/customvarobject.hpp"
#impl_include "icinga/notificationcommand.hpp"
#impl_include "icinga/service.hpp"
library icinga;
namespace icinga
{
code {{{
class NotificationNameComposer : public NameComposer
{
public:
virtual String MakeName(const String& shortName, const Object::Ptr& context) const override;
virtual Dictionary::Ptr ParseName(const String& name) const override;
};
}}}
class Notification : CustomVarObject < NotificationNameComposer
{
load_after Host;
load_after Service;
load_after User;
load_after UserGroup;
[config, protected, required, navigation] name(NotificationCommand) command (CommandRaw) {
navigate {{{
return NotificationCommand::GetByName(GetCommandRaw());
}}}
};
[config] double interval {
default {{{ return 1800; }}}
};
[config, navigation] name(TimePeriod) period (PeriodRaw) {
navigate {{{
return TimePeriod::GetByName(GetPeriodRaw());
}}}
};
[config, signal_with_old_value] array(name(User)) users (UsersRaw);
[config, signal_with_old_value] array(name(UserGroup)) user_groups (UserGroupsRaw);
[config] Dictionary::Ptr times;
[config, no_storage] array(Value) types {
get;
set;
};
[no_user_view, no_user_modify] int type_filter_real (TypeFilter);
[config, no_storage] array(Value) states {
get;
set;
};
[no_user_view, no_user_modify] int state_filter_real (StateFilter);
[config, no_user_modify, protected, required, navigation(host)] name(Host) host_name {
navigate {{{
return Host::GetByName(GetHostName());
}}}
};
[config, protected, no_user_modify, navigation(service)] String service_name {
track {{{
if (!oldValue.IsEmpty()) {
Service::Ptr service = Service::GetByNamePair(GetHostName(), oldValue);
DependencyGraph::RemoveDependency(this, service.get());
}
if (!newValue.IsEmpty()) {
Service::Ptr service = Service::GetByNamePair(GetHostName(), newValue);
DependencyGraph::AddDependency(this, service.get());
}
}}}
navigate {{{
if (GetServiceName().IsEmpty())
return nullptr;
Host::Ptr host = Host::GetByName(GetHostName());
return host->GetServiceByShortName(GetServiceName());
}}}
};
[state, no_user_modify] Array::Ptr notified_problem_users {
default {{{ return new Array(); }}}
};
[state, no_user_modify] bool no_more_notifications {
default {{{ return false; }}}
};
[state, no_user_view, no_user_modify] Array::Ptr stashed_notifications {
default {{{ return new Array(); }}}
};
[state] Timestamp last_notification;
[state] Timestamp next_notification;
[state] int notification_number;
[state] Timestamp last_problem_notification;
[state, no_user_view, no_user_modify] int suppressed_notifications {
default {{{ return 0; }}}
};
[state, no_user_view, no_user_modify] Dictionary::Ptr last_notified_state_per_user {
default {{{ return new Dictionary(); }}}
};
[config, navigation] name(Endpoint) command_endpoint (CommandEndpointRaw) {
navigate {{{
return Endpoint::GetByName(GetCommandEndpointRaw());
}}}
};
};
validator Notification {
Dictionary times {
Number begin;
Number end;
};
};
}