]> granicus.if.org Git - icinga2/blob - lib/icinga/compatutility.hpp
Merge pull request #6704 from efuss/fix/scheduleddowntime1
[icinga2] / lib / icinga / compatutility.hpp
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 #ifndef COMPATUTILITY_H
21 #define COMPATUTILITY_H
22
23 #include "icinga/i2-icinga.hpp"
24 #include "icinga/host.hpp"
25 #include "icinga/command.hpp"
26
27 namespace icinga
28 {
29
30 /**
31  * Compatibility utility functions.
32  *
33  * @ingroup icinga
34  */
35 class CompatUtility
36 {
37 public:
38         /* command */
39         static String GetCommandLine(const Command::Ptr& command);
40         static String GetCommandName(const Command::Ptr& command);
41
42         /* service */
43         static String GetCheckableCommandArgs(const Checkable::Ptr& checkable);
44
45         /* notification */
46         static int GetCheckableNotificationsEnabled(const Checkable::Ptr& checkable);
47         static int GetCheckableNotificationLastNotification(const Checkable::Ptr& checkable);
48         static int GetCheckableNotificationNextNotification(const Checkable::Ptr& checkable);
49         static int GetCheckableNotificationNotificationNumber(const Checkable::Ptr& checkable);
50         static double GetCheckableNotificationNotificationInterval(const Checkable::Ptr& checkable);
51         static int GetCheckableNotificationTypeFilter(const Checkable::Ptr& checkable);
52         static int GetCheckableNotificationStateFilter(const Checkable::Ptr& checkable);
53
54         static std::set<User::Ptr> GetCheckableNotificationUsers(const Checkable::Ptr& checkable);
55         static std::set<UserGroup::Ptr> GetCheckableNotificationUserGroups(const Checkable::Ptr& checkable);
56
57         /* check result */
58         static String GetCheckResultOutput(const CheckResult::Ptr& cr);
59         static String GetCheckResultLongOutput(const CheckResult::Ptr& cr);
60
61         /* misc */
62         static String EscapeString(const String& str);
63         static String UnEscapeString(const String& str);
64
65 private:
66         CompatUtility();
67
68         static String GetCommandNamePrefix(const Command::Ptr& command);
69 };
70
71 }
72
73 #endif /* COMPATUTILITY_H */