]> granicus.if.org Git - icinga2/blob - lib/livestatus/statehisttable.hpp
Merge pull request #7002 from Icinga/bugfix/check_network-percent-6155
[icinga2] / lib / livestatus / statehisttable.hpp
1 /* Icinga 2 | (c) 2012 Icinga GmbH | GPLv2+ */
2
3 #ifndef STATEHISTTABLE_H
4 #define STATEHISTTABLE_H
5
6 #include "icinga/service.hpp"
7 #include "livestatus/historytable.hpp"
8 #include <boost/thread/mutex.hpp>
9
10 using namespace icinga;
11
12 namespace icinga
13 {
14
15 /**
16  * @ingroup livestatus
17  */
18 class StateHistTable final : public HistoryTable
19 {
20 public:
21         DECLARE_PTR_TYPEDEFS(StateHistTable);
22
23         StateHistTable(const String& compat_log_path, time_t from, time_t until);
24
25         static void AddColumns(Table *table, const String& prefix = String(),
26                 const Column::ObjectAccessor& objectAccessor = Column::ObjectAccessor());
27
28         String GetName() const override;
29         String GetPrefix() const override;
30
31         void UpdateLogEntries(const Dictionary::Ptr& log_entry_attrs, int line_count, int lineno, const AddRowFunction& addRowFn) override;
32
33 protected:
34         void FetchRows(const AddRowFunction& addRowFn) override;
35
36         static Object::Ptr HostAccessor(const Value& row, const Column::ObjectAccessor& parentObjectAccessor);
37         static Object::Ptr ServiceAccessor(const Value& row, const Column::ObjectAccessor& parentObjectAccessor);
38
39         static Value TimeAccessor(const Value& row);
40         static Value LinenoAccessor(const Value& row);
41         static Value FromAccessor(const Value& row);
42         static Value UntilAccessor(const Value& row);
43         static Value DurationAccessor(const Value& row);
44         static Value DurationPartAccessor(const Value& row);
45         static Value StateAccessor(const Value& row);
46         static Value HostDownAccessor(const Value& row);
47         static Value InDowntimeAccessor(const Value& row);
48         static Value InHostDowntimeAccessor(const Value& row);
49         static Value IsFlappingAccessor(const Value& row);
50         static Value InNotificationPeriodAccessor(const Value& row);
51         static Value NotificationPeriodAccessor(const Value& row);
52         static Value HostNameAccessor(const Value& row);
53         static Value ServiceDescriptionAccessor(const Value& row);
54         static Value LogOutputAccessor(const Value& row);
55         static Value DurationOkAccessor(const Value& row);
56         static Value DurationPartOkAccessor(const Value& row);
57         static Value DurationWarningAccessor(const Value& row);
58         static Value DurationPartWarningAccessor(const Value& row);
59         static Value DurationCriticalAccessor(const Value& row);
60         static Value DurationPartCriticalAccessor(const Value& row);
61         static Value DurationUnknownAccessor(const Value& row);
62         static Value DurationPartUnknownAccessor(const Value& row);
63         static Value DurationUnmonitoredAccessor(const Value& row);
64         static Value DurationPartUnmonitoredAccessor(const Value& row);
65
66 private:
67         std::map<time_t, String> m_LogFileIndex;
68         std::map<Checkable::Ptr, Array::Ptr> m_CheckablesCache;
69         time_t m_TimeFrom;
70         time_t m_TimeUntil;
71         String m_CompatLogPath;
72 };
73
74 }
75
76 #endif /* STATEHISTTABLE_H */