1 /******************************************************************************
3 * Copyright (C) 2012-2018 Icinga Development Team (https://icinga.com/) *
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. *
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. *
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 ******************************************************************************/
20 #ifndef STATEHISTTABLE_H
21 #define STATEHISTTABLE_H
23 #include "icinga/service.hpp"
24 #include "livestatus/historytable.hpp"
25 #include <boost/thread/mutex.hpp>
27 using namespace icinga;
35 class StateHistTable final : public HistoryTable
38 DECLARE_PTR_TYPEDEFS(StateHistTable);
40 StateHistTable(const String& compat_log_path, time_t from, time_t until);
42 static void AddColumns(Table *table, const String& prefix = String(),
43 const Column::ObjectAccessor& objectAccessor = Column::ObjectAccessor());
45 String GetName() const override;
46 String GetPrefix() const override;
48 void UpdateLogEntries(const Dictionary::Ptr& log_entry_attrs, int line_count, int lineno, const AddRowFunction& addRowFn) override;
51 void FetchRows(const AddRowFunction& addRowFn) override;
53 static Object::Ptr HostAccessor(const Value& row, const Column::ObjectAccessor& parentObjectAccessor);
54 static Object::Ptr ServiceAccessor(const Value& row, const Column::ObjectAccessor& parentObjectAccessor);
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);
84 std::map<time_t, String> m_LogFileIndex;
85 std::map<Checkable::Ptr, Array::Ptr> m_CheckablesCache;
88 String m_CompatLogPath;
93 #endif /* STATEHISTTABLE_H */