1 /* Icinga 2 | (c) 2012 Icinga GmbH | GPLv2+ */
6 #include "db_ido/dbobject.hpp"
7 #include "base/configobject.hpp"
8 #include "icinga/service.hpp"
15 LogEntryTypeRuntimeError = 1,
16 LogEntryTypeRuntimeWarning = 2,
17 LogEntryTypeVerificationError = 4,
18 LogEntryTypeVerificationWarning = 8,
19 LogEntryTypeConfigError = 16,
20 LogEntryTypeConfigWarning = 32,
21 LogEntryTypeProcessInfo = 64,
22 LogEntryTypeEventHandler = 128,
23 LogEntryTypeExternalCommand = 512,
24 LogEntryTypeHostUp = 1024,
25 LogEntryTypeHostDown = 2048,
26 LogEntryTypeHostUnreachable = 4096,
27 LogEntryTypeServiceOk = 8192,
28 LogEntryTypeServiceUnknown = 16384,
29 LogEntryTypeServiceWarning = 32768,
30 LogEntryTypeServiceCritical = 65536,
31 LogEntryTypePassiveCheck = 1231072,
32 LogEntryTypeInfoMessage = 262144,
33 LogEntryTypeHostNotification = 524288,
34 LogEntryTypeServiceNotification = 1048576
45 static void StaticInitialize();
47 static void AddComments(const Checkable::Ptr& checkable);
49 static void AddDowntimes(const Checkable::Ptr& checkable);
50 static void RemoveDowntimes(const Checkable::Ptr& checkable);
52 static void AddLogHistory(const Checkable::Ptr& checkable, const String& buffer, LogEntryType type);
55 static void NextCheckUpdatedHandler(const Checkable::Ptr& checkable);
56 static void FlappingChangedHandler(const Checkable::Ptr& checkable);
57 static void LastNotificationChangedHandler(const Notification::Ptr& notification, const Checkable::Ptr& checkable);
59 static void EnableActiveChecksChangedHandler(const Checkable::Ptr& checkable);
60 static void EnablePassiveChecksChangedHandler(const Checkable::Ptr& checkable);
61 static void EnableNotificationsChangedHandler(const Checkable::Ptr& checkable);
62 static void EnablePerfdataChangedHandler(const Checkable::Ptr& checkable);
63 static void EnableFlappingChangedHandler(const Checkable::Ptr& checkable);
65 static void AddComment(const Comment::Ptr& comment);
66 static void RemoveComment(const Comment::Ptr& comment);
68 static void AddDowntime(const Downtime::Ptr& downtime);
69 static void RemoveDowntime(const Downtime::Ptr& downtime);
70 static void TriggerDowntime(const Downtime::Ptr& downtime);
72 static void AddAcknowledgement(const Checkable::Ptr& checkable, AcknowledgementType type);
73 static void RemoveAcknowledgement(const Checkable::Ptr& checkable);
74 static void AddAcknowledgementInternal(const Checkable::Ptr& checkable, AcknowledgementType type, bool add);
76 static void ReachabilityChangedHandler(const Checkable::Ptr& checkable, const CheckResult::Ptr& cr, std::set<Checkable::Ptr> children);
78 /* comment, downtime, acknowledgement history */
79 static void AddCommentHistory(const Comment::Ptr& comment);
80 static void AddDowntimeHistory(const Downtime::Ptr& downtime);
81 static void AddAcknowledgementHistory(const Checkable::Ptr& checkable, const String& author, const String& comment,
82 AcknowledgementType type, bool notify, double expiry);
84 /* notification & contactnotification history */
85 static void AddNotificationHistory(const Notification::Ptr& notification, const Checkable::Ptr& checkable,
86 const std::set<User::Ptr>& users, NotificationType type, const CheckResult::Ptr& cr, const String& author,
90 static void AddStateChangeHistory(const Checkable::Ptr& checkable, const CheckResult::Ptr& cr, StateType type);
93 static void AddCheckResultLogHistory(const Checkable::Ptr& checkable, const CheckResult::Ptr &cr);
94 static void AddTriggerDowntimeLogHistory(const Downtime::Ptr& downtime);
95 static void AddRemoveDowntimeLogHistory(const Downtime::Ptr& downtime);
96 static void AddNotificationSentLogHistory(const Notification::Ptr& notification, const Checkable::Ptr& checkable,
97 const User::Ptr& user, NotificationType notification_type, const CheckResult::Ptr& cr, const NotificationResult::Ptr& nr,
98 const String& author, const String& comment_text);
100 static void AddFlappingChangedLogHistory(const Checkable::Ptr& checkable);
101 static void AddEnableFlappingChangedLogHistory(const Checkable::Ptr& checkable);
104 static void AddFlappingChangedHistory(const Checkable::Ptr& checkable);
105 static void AddEnableFlappingChangedHistory(const Checkable::Ptr& checkable);
106 static void AddCheckableCheckHistory(const Checkable::Ptr& checkable, const CheckResult::Ptr &cr);
107 static void AddEventHandlerHistory(const Checkable::Ptr& checkable);
108 static void AddExternalCommandHistory(double time, const String& command, const std::vector<String>& arguments);
113 static void AddCommentInternal(std::vector<DbQuery>& queries, const Comment::Ptr& comment, bool historical);
114 static void RemoveCommentInternal(std::vector<DbQuery>& queries, const Comment::Ptr& comment);
115 static void AddDowntimeInternal(std::vector<DbQuery>& queries, const Downtime::Ptr& downtime, bool historical);
116 static void RemoveDowntimeInternal(std::vector<DbQuery>& queries, const Downtime::Ptr& downtime);
117 static void EnableChangedHandlerInternal(const Checkable::Ptr& checkable, const String& fieldName, bool enabled);
119 static int GetHostState(const Host::Ptr& host);
120 static String GetHostStateString(const Host::Ptr& host);
121 static std::pair<unsigned long, unsigned long> ConvertTimestamp(double time);
122 static int MapNotificationReasonType(NotificationType type);
123 static int MapExternalCommandType(const String& name);
128 #endif /* DBEVENTS_H */