]> granicus.if.org Git - icinga2/blobdiff - lib/livestatus/logtable.cpp
Merge pull request #7204 from episodeiv/master
[icinga2] / lib / livestatus / logtable.cpp
index 664dab5c51e0ca814ab65413e1297dcbbfe9b8a4..ed21b722eaf469977045b070c7b25d8e8b9c52bb 100644 (file)
@@ -1,21 +1,4 @@
-/******************************************************************************
- * Icinga 2                                                                   *
- * Copyright (C) 2012-2015 Icinga Development Team (http://www.icinga.org)    *
- *                                                                            *
- * This program is free software; you can redistribute it and/or              *
- * modify it under the terms of the GNU General Public License                *
- * as published by the Free Software Foundation; either version 2             *
- * of the License, or (at your option) any later version.                     *
- *                                                                            *
- * This program is distributed in the hope that it will be useful,            *
- * but WITHOUT ANY WARRANTY; without even the implied warranty of             *
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the              *
- * GNU General Public License for more details.                               *
- *                                                                            *
- * You should have received a copy of the GNU General Public License          *
- * along with this program; if not, write to the Free Software Foundation     *
- * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA.             *
- ******************************************************************************/
+/* Icinga 2 | (c) 2012 Icinga GmbH | GPLv2+ */
 
 #include "livestatus/logtable.hpp"
 #include "livestatus/livestatuslogutility.hpp"
 #include "base/logger.hpp"
 #include "base/application.hpp"
 #include "base/objectlock.hpp"
-#include <boost/foreach.hpp>
-#include <boost/tuple/tuple.hpp>
 #include <boost/algorithm/string.hpp>
-#include <boost/algorithm/string/split.hpp>
-#include <boost/algorithm/string/classification.hpp>
 #include <boost/algorithm/string/replace.hpp>
 #include <boost/algorithm/string/predicate.hpp>
 #include <fstream>
@@ -58,7 +37,7 @@ LogTable::LogTable(const String& compat_log_path, time_t from, time_t until)
 }
 
 void LogTable::AddColumns(Table *table, const String& prefix,
-    const Column::ObjectAccessor& objectAccessor)
+       const Column::ObjectAccessor& objectAccessor)
 {
        table->AddColumn(prefix + "time", Column(&LogTable::TimeAccessor, objectAccessor));
        table->AddColumn(prefix + "lineno", Column(&LogTable::LinenoAccessor, objectAccessor));
@@ -76,18 +55,18 @@ void LogTable::AddColumns(Table *table, const String& prefix,
        table->AddColumn(prefix + "contact_name", Column(&LogTable::ContactNameAccessor, objectAccessor));
        table->AddColumn(prefix + "command_name", Column(&LogTable::CommandNameAccessor, objectAccessor));
 
-       HostsTable::AddColumns(table, "current_host_", boost::bind(&LogTable::HostAccessor, _1, objectAccessor));
-       ServicesTable::AddColumns(table, "current_service_", boost::bind(&LogTable::ServiceAccessor, _1, objectAccessor));
-       ContactsTable::AddColumns(table, "current_contact_", boost::bind(&LogTable::ContactAccessor, _1, objectAccessor));
-       CommandsTable::AddColumns(table, "current_command_", boost::bind(&LogTable::CommandAccessor, _1, objectAccessor));
+       HostsTable::AddColumns(table, "current_host_", std::bind(&LogTable::HostAccessor, _1, objectAccessor));
+       ServicesTable::AddColumns(table, "current_service_", std::bind(&LogTable::ServiceAccessor, _1, objectAccessor));
+       ContactsTable::AddColumns(table, "current_contact_", std::bind(&LogTable::ContactAccessor, _1, objectAccessor));
+       CommandsTable::AddColumns(table, "current_command_", std::bind(&LogTable::CommandAccessor, _1, objectAccessor));
 }
 
-String LogTable::GetName(void) const
+String LogTable::GetName() const
 {
        return "log";
 }
 
-String LogTable::GetPrefix(void) const
+String LogTable::GetPrefix() const
 {
        return "log";
 }
@@ -95,7 +74,7 @@ String LogTable::GetPrefix(void) const
 void LogTable::FetchRows(const AddRowFunction& addRowFn)
 {
        Log(LogDebug, "LogTable")
-           << "Pre-selecting log file from " << m_TimeFrom << " until " << m_TimeUntil;
+               << "Pre-selecting log file from " << m_TimeFrom << " until " << m_TimeUntil;
 
        /* create log file index */
        LivestatusLogUtility::CreateLogIndex(m_CompatLogPath, m_LogFileIndex);
@@ -118,7 +97,7 @@ Object::Ptr LogTable::HostAccessor(const Value& row, const Column::ObjectAccesso
        String host_name = static_cast<Dictionary::Ptr>(row)->Get("host_name");
 
        if (host_name.IsEmpty())
-               return Object::Ptr();
+               return nullptr;
 
        return Host::GetByName(host_name);
 }
@@ -129,7 +108,7 @@ Object::Ptr LogTable::ServiceAccessor(const Value& row, const Column::ObjectAcce
        String service_description = static_cast<Dictionary::Ptr>(row)->Get("service_description");
 
        if (service_description.IsEmpty() || host_name.IsEmpty())
-               return Object::Ptr();
+               return nullptr;
 
        return Service::GetByNamePair(host_name, service_description);
 }
@@ -139,7 +118,7 @@ Object::Ptr LogTable::ContactAccessor(const Value& row, const Column::ObjectAcce
        String contact_name = static_cast<Dictionary::Ptr>(row)->Get("contact_name");
 
        if (contact_name.IsEmpty())
-               return Object::Ptr();
+               return nullptr;
 
        return User::GetByName(contact_name);
 }
@@ -149,7 +128,7 @@ Object::Ptr LogTable::CommandAccessor(const Value& row, const Column::ObjectAcce
        String command_name = static_cast<Dictionary::Ptr>(row)->Get("command_name");
 
        if (command_name.IsEmpty())
-               return Object::Ptr();
+               return nullptr;
 
        CheckCommand::Ptr check_command = CheckCommand::GetByName(command_name);
        if (!check_command) {
@@ -157,7 +136,7 @@ Object::Ptr LogTable::CommandAccessor(const Value& row, const Column::ObjectAcce
                if (!event_command) {
                        NotificationCommand::Ptr notification_command = NotificationCommand::GetByName(command_name);
                        if (!notification_command)
-                               return Object::Ptr();
+                               return nullptr;
                        else
                                return notification_command;
                } else