]> granicus.if.org Git - icinga2/blob - lib/livestatus/statehisttable.hpp
Remove more redundant wrappers from CompatUtility class
[icinga2] / lib / livestatus / statehisttable.hpp
1 /******************************************************************************
2  * Icinga 2                                                                   *
3  * Copyright (C) 2012-2018 Icinga Development Team (https://www.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 STATEHISTTABLE_H
21 #define STATEHISTTABLE_H
22
23 #include "icinga/service.hpp"
24 #include "livestatus/historytable.hpp"
25 #include <boost/thread/mutex.hpp>
26
27 using namespace icinga;
28
29 namespace icinga
30 {
31
32 /**
33  * @ingroup livestatus
34  */
35 class StateHistTable final : public HistoryTable
36 {
37 public:
38         DECLARE_PTR_TYPEDEFS(StateHistTable);
39
40         StateHistTable(const String& compat_log_path, time_t from, time_t until);
41
42         static void AddColumns(Table *table, const String& prefix = String(),
43                 const Column::ObjectAccessor& objectAccessor = Column::ObjectAccessor());
44
45         String GetName() const override;
46         String GetPrefix() const override;
47
48         void UpdateLogEntries(const Dictionary::Ptr& log_entry_attrs, int line_count, int lineno, const AddRowFunction& addRowFn) override;
49
50 protected:
51         void FetchRows(const AddRowFunction& addRowFn) override;
52
53         static Object::Ptr HostAccessor(const Value& row, const Column::ObjectAccessor& parentObjectAccessor);
54         static Object::Ptr ServiceAccessor(const Value& row, const Column::ObjectAccessor& parentObjectAccessor);
55
56         static Value TimeAccessor(const Value& row);
57         static Value LinenoAccessor(const Value& row);
58         static Value FromAccessor(const Value& row);
59         static Value UntilAccessor(const Value& row);
60         static Value DurationAccessor(const Value& row);
61         static Value DurationPartAccessor(const Value& row);
62         static Value StateAccessor(const Value& row);
63         static Value HostDownAccessor(const Value& row);
64         static Value InDowntimeAccessor(const Value& row);
65         static Value InHostDowntimeAccessor(const Value& row);
66         static Value IsFlappingAccessor(const Value& row);
67         static Value InNotificationPeriodAccessor(const Value& row);
68         static Value NotificationPeriodAccessor(const Value& row);
69         static Value HostNameAccessor(const Value& row);
70         static Value ServiceDescriptionAccessor(const Value& row);
71         static Value LogOutputAccessor(const Value& row);
72         static Value DurationOkAccessor(const Value& row);
73         static Value DurationPartOkAccessor(const Value& row);
74         static Value DurationWarningAccessor(const Value& row);
75         static Value DurationPartWarningAccessor(const Value& row);
76         static Value DurationCriticalAccessor(const Value& row);
77         static Value DurationPartCriticalAccessor(const Value& row);
78         static Value DurationUnknownAccessor(const Value& row);
79         static Value DurationPartUnknownAccessor(const Value& row);
80         static Value DurationUnmonitoredAccessor(const Value& row);
81         static Value DurationPartUnmonitoredAccessor(const Value& row);
82
83 private:
84         std::map<time_t, String> m_LogFileIndex;
85         std::map<Checkable::Ptr, Array::Ptr> m_CheckablesCache;
86         time_t m_TimeFrom;
87         time_t m_TimeUntil;
88         String m_CompatLogPath;
89 };
90
91 }
92
93 #endif /* STATEHISTTABLE_H */