1/* Icinga 2 | (c) 2012 Icinga GmbH | GPLv2+ */ 2 3#include "icinga/customvarobject.hpp" 4#impl_include "icinga/notificationcommand.hpp" 5#impl_include "icinga/service.hpp" 6 7library icinga; 8 9namespace icinga 10{ 11 12code {{{ 13class NotificationNameComposer : public NameComposer 14{ 15public: 16 virtual String MakeName(const String& shortName, const Object::Ptr& context) const; 17 virtual Dictionary::Ptr ParseName(const String& name) const; 18}; 19}}} 20 21class Notification : CustomVarObject < NotificationNameComposer 22{ 23 load_after Host; 24 load_after Service; 25 26 [config, protected, required, navigation] name(NotificationCommand) command (CommandRaw) { 27 navigate {{{ 28 return NotificationCommand::GetByName(GetCommandRaw()); 29 }}} 30 }; 31 [config] double interval { 32 default {{{ return 1800; }}} 33 }; 34 [config, navigation] name(TimePeriod) period (PeriodRaw) { 35 navigate {{{ 36 return TimePeriod::GetByName(GetPeriodRaw()); 37 }}} 38 }; 39 [config, signal_with_old_value] array(name(User)) users (UsersRaw); 40 [config, signal_with_old_value] array(name(UserGroup)) user_groups (UserGroupsRaw); 41 [config] Dictionary::Ptr times; 42 [config] array(Value) types; 43 [no_user_view, no_user_modify] int type_filter_real (TypeFilter); 44 [config] array(Value) states; 45 [no_user_view, no_user_modify] int state_filter_real (StateFilter); 46 [config, protected, required, navigation(host)] name(Host) host_name { 47 navigate {{{ 48 return Host::GetByName(GetHostName()); 49 }}} 50 }; 51 [config, protected, navigation(service)] String service_name { 52 track {{{ 53 if (!oldValue.IsEmpty()) { 54 Service::Ptr service = Service::GetByNamePair(GetHostName(), oldValue); 55 DependencyGraph::RemoveDependency(this, service.get()); 56 } 57 58 if (!newValue.IsEmpty()) { 59 Service::Ptr service = Service::GetByNamePair(GetHostName(), newValue); 60 DependencyGraph::AddDependency(this, service.get()); 61 } 62 }}} 63 navigate {{{ 64 if (GetServiceName().IsEmpty()) 65 return nullptr; 66 67 Host::Ptr host = Host::GetByName(GetHostName()); 68 return host->GetServiceByShortName(GetServiceName()); 69 }}} 70 }; 71 72 [state, no_user_modify] Array::Ptr notified_problem_users { 73 default {{{ return new Array(); }}} 74 }; 75 76 [state, no_user_modify] bool no_more_notifications { 77 default {{{ return false; }}} 78 }; 79 80 [state, no_user_view, no_user_modify] Array::Ptr stashed_notifications { 81 default {{{ return new Array(); }}} 82 }; 83 84 [state] Timestamp last_notification; 85 [state] Timestamp next_notification; 86 [state] int notification_number; 87 [state] Timestamp last_problem_notification; 88 89 [state, no_user_view, no_user_modify] int suppressed_notifications { 90 default {{{ return 0; }}} 91 }; 92 93 [config, navigation] name(Endpoint) command_endpoint (CommandEndpointRaw) { 94 navigate {{{ 95 return Endpoint::GetByName(GetCommandEndpointRaw()); 96 }}} 97 }; 98}; 99 100validator Notification { 101 Dictionary times { 102 Number begin; 103 Number end; 104 }; 105}; 106 107} 108