]> granicus.if.org Git - icinga2/blob - lib/icinga/service.ti
Merge pull request #6480 from ajaffie/feature/win-check-update-4720
[icinga2] / lib / icinga / service.ti
1 /******************************************************************************
2  * Icinga 2                                                                   *
3  * Copyright (C) 2012-2018 Icinga Development Team (https://icinga.com/)      *
4  *                                                                            *
5  * This program is free software; you can redistribute it and/or              *
6  * modify it under the terms of the GNU General Public License                *
7  * as published by the Free Software Foundation; either version 2             *
8  * of the License, or (at your option) any later version.                     *
9  *                                                                            *
10  * This program is distributed in the hope that it will be useful,            *
11  * but WITHOUT ANY WARRANTY; without even the implied warranty of             *
12  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the              *
13  * GNU General Public License for more details.                               *
14  *                                                                            *
15  * You should have received a copy of the GNU General Public License          *
16  * along with this program; if not, write to the Free Software Foundation     *
17  * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA.             *
18  ******************************************************************************/
19
20 #include "icinga/checkable.hpp"
21 #include "icinga/host.hpp"
22 #include "icinga/icingaapplication.hpp"
23 #include "icinga/customvarobject.hpp"
24 #impl_include "icinga/servicegroup.hpp"
25
26 library icinga;
27
28 namespace icinga
29 {
30
31 code {{{
32 class ServiceNameComposer : public NameComposer
33 {
34 public:
35         virtual String MakeName(const String& shortName, const Object::Ptr& context) const;
36         virtual Dictionary::Ptr ParseName(const String& name) const;
37 };
38 }}}
39
40 class Service : Checkable < ServiceNameComposer
41 {
42         load_after ApiListener;
43         load_after Endpoint;
44         load_after Host;
45         load_after Zone;
46
47         [config, no_user_modify, required] array(name(ServiceGroup)) groups {
48                 default {{{ return new Array(); }}}
49         };
50
51         [config] String display_name {
52                 get {{{
53                         if (m_DisplayName.IsEmpty())
54                                 return GetShortName();
55                         else
56                                 return m_DisplayName;
57                 }}}
58         };
59         [config, required] name(Host) host_name;
60         [no_storage, navigation] Host::Ptr host {
61                 get;
62                 navigate {{{
63                         return GetHost();
64                 }}}
65         };
66         [enum, no_storage] ServiceState "state" {
67                 get {{{
68                         return GetStateRaw();
69                 }}}
70         };
71         [enum, no_storage] ServiceState last_state {
72                 get {{{
73                         return GetLastStateRaw();
74                 }}}
75         };
76         [enum, no_storage] ServiceState last_hard_state {
77                 get {{{
78                         return GetLastHardStateRaw();
79                 }}}
80         };
81         [state] Timestamp last_state_ok (LastStateOK);
82         [state] Timestamp last_state_warning;
83         [state] Timestamp last_state_critical;
84         [state] Timestamp last_state_unknown;
85 };
86
87 }