diff --git a/CMakeLists.txt b/CMakeLists.txt index 04349e75a..8e1b016d1 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -204,6 +204,9 @@ if(HAVE_SYSTEMD) list(APPEND base_DEPS systemd) endif() +if(ICINGA2_WITH_REDIS) + list(APPEND base_OBJS $) +endif() if(EDITLINE_FOUND) list(APPEND base_DEPS ${EDITLINE_LIBRARIES}) diff --git a/icinga-app/CMakeLists.txt b/icinga-app/CMakeLists.txt index ee3443b28..0ba780316 100644 --- a/icinga-app/CMakeLists.txt +++ b/icinga-app/CMakeLists.txt @@ -53,6 +53,10 @@ if(ICINGA2_WITH_PERFDATA) list(APPEND icinga_app_SOURCES $) endif() +if(ICINGA2_WITH_REDIS) + list(APPEND icinga_app_SOURCES $) +endif() + add_executable(icinga-app $ ${base_OBJS} diff --git a/lib/redis/CMakeLists.txt b/lib/redis/CMakeLists.txt index 540fffa06..b12fd0229 100644 --- a/lib/redis/CMakeLists.txt +++ b/lib/redis/CMakeLists.txt @@ -1,5 +1,5 @@ # Icinga 2 -# Copyright (C) 2012-2017 Icinga Development Team (https://www.icinga.com/) +# Copyright (C) 2012-2018 Icinga Development Team (https://www.icinga.com/) # # This program is free software; you can redistribute it and/or # modify it under the terms of the GNU General Public License @@ -15,29 +15,27 @@ # along with this program; if not, write to the Free Software Foundation # Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA. -mkclass_target(rediswriter.ti rediswriter.tcpp rediswriter.thpp) +mkclass_target(rediswriter.ti rediswriter-ti.cpp rediswriter-ti.hpp) set(redis_SOURCES - rediswriter.cpp rediswriter-status.cpp rediswriter-utility.cpp rediswriter.thpp + rediswriter.cpp rediswriter-status.cpp rediswriter-utility.cpp rediswriter-ti.hpp ) if(ICINGA2_UNITY_BUILD) mkunity_target(redis redis redis_SOURCES) endif() -add_library(redis SHARED ${redis_SOURCES}) - -target_link_libraries(redis ${Boost_LIBRARIES} base config icinga remote hiredis) +add_library(redis OBJECT ${redis_SOURCES}) include_directories(${icinga2_SOURCE_DIR}/third-party) + +add_dependencies(redis base config icinga remote) + link_directories(${icinga2_BINARY_DIR}/third-party/hiredis) set_target_properties ( redis PROPERTIES - INSTALL_RPATH ${CMAKE_INSTALL_FULL_LIBDIR}/icinga2 - DEFINE_SYMBOL I2_REDIS_BUILD FOLDER Components - VERSION ${SPEC_VERSION} ) install_if_not_exists( @@ -45,9 +43,4 @@ install_if_not_exists( ${CMAKE_INSTALL_SYSCONFDIR}/icinga2/features-available ) -install( - TARGETS redis - RUNTIME DESTINATION ${CMAKE_INSTALL_SBINDIR} - LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR}/icinga2 -) - +set(CPACK_NSIS_EXTRA_INSTALL_COMMANDS "${CPACK_NSIS_EXTRA_INSTALL_COMMANDS}" PARENT_SCOPE) diff --git a/lib/redis/rediswriter-status.cpp b/lib/redis/rediswriter-status.cpp index b8562e2f6..a6d44d1e1 100644 --- a/lib/redis/rediswriter-status.cpp +++ b/lib/redis/rediswriter-status.cpp @@ -1,6 +1,6 @@ /****************************************************************************** * Icinga 2 * - * Copyright (C) 2012-2017 Icinga Development Team (https://www.icinga.com/) * + * Copyright (C) 2012-2018 Icinga Development Team (https://www.icinga.com/) * * * * This program is free software; you can redistribute it and/or * * modify it under the terms of the GNU General Public License * diff --git a/lib/redis/rediswriter.cpp b/lib/redis/rediswriter.cpp index b9169a6e7..04dd20f55 100644 --- a/lib/redis/rediswriter.cpp +++ b/lib/redis/rediswriter.cpp @@ -1,6 +1,6 @@ /****************************************************************************** * Icinga 2 * - * Copyright (C) 2012-2017 Icinga Development Team (https://www.icinga.com/) * + * Copyright (C) 2012-2018 Icinga Development Team (https://www.icinga.com/) * * * * This program is free software; you can redistribute it and/or * * modify it under the terms of the GNU General Public License * @@ -18,7 +18,7 @@ ******************************************************************************/ #include "redis/rediswriter.hpp" -#include "redis/rediswriter.tcpp" +#include "redis/rediswriter-ti.cpp" #include "remote/eventqueue.hpp" #include "base/json.hpp" #include "base/statsfunction.hpp" @@ -147,7 +147,6 @@ void RedisWriter::TryToReconnect() m_ConfigDumpInProgress = false; } -/* void RedisWriter::UpdateSubscriptionsTimerHandler() { m_WorkQueue.Enqueue(std::bind(&RedisWriter::UpdateSubscriptions, this)); @@ -218,7 +217,6 @@ int RedisWriter::GetSubscriptionTypes(String key, RedisSubscriptionInfo& rsi) << "Invalid Redis subscriber info for subscriber '" << key << "': " << DiagnosticInformation(ex); } } -*/ void RedisWriter::PublishStatsTimerHandler(void) { @@ -233,10 +231,18 @@ void RedisWriter::PublishStats() return; //TODO: Figure out if more stats can be useful here. - StatsFunction::Ptr func = StatsFunctionRegistry::GetInstance()->GetItem("CIB"); + Dictionary::Ptr statsFunctions = ScriptGlobal::Get("StatsFunctions", &Empty); + + if (!statsFunctions) + return; + + Function::Ptr func = statsFunctions->Get("CIB"); + Dictionary::Ptr status = new Dictionary(); Array::Ptr perfdata = new Array(); - func->Invoke(status, perfdata); + + func->Invoke({ status, perfdata }); + String jsonStats = JsonEncode(status); ExecuteQuery({ "PUBLISH", "icinga:stats", jsonStats }); @@ -278,7 +284,6 @@ void RedisWriter::HandleEvents() EventQueue::UnregisterIfUnused(queueName, queue); } -/* void RedisWriter::HandleEvent(const Dictionary::Ptr& event) { AssertOnWorkQueue(); @@ -313,9 +318,8 @@ void RedisWriter::HandleEvent(const Dictionary::Ptr& event) ExecuteQuery({ "EXEC" }); } } -*/ -void RedisWriter::HandleEvent(const Dictionary::Ptr& event) +void RedisWriter::SendEvent(const Dictionary::Ptr& event) { AssertOnWorkQueue(); @@ -412,7 +416,7 @@ std::vector > RedisWriter::ExecuteQueries(const std: ); } - boost::shared_ptr reply(rawReply, freeReplyObject); + std::shared_ptr reply(rawReply, freeReplyObject); replies.push_back(reply); } diff --git a/lib/redis/rediswriter.hpp b/lib/redis/rediswriter.hpp index 20a82f0c6..4124b4b64 100644 --- a/lib/redis/rediswriter.hpp +++ b/lib/redis/rediswriter.hpp @@ -1,6 +1,6 @@ /****************************************************************************** * Icinga 2 * - * Copyright (C) 2012-2017 Icinga Development Team (https://www.icinga.com/) * + * Copyright (C) 2012-2018 Icinga Development Team (https://www.icinga.com/) * * * * This program is free software; you can redistribute it and/or * * modify it under the terms of the GNU General Public License * @@ -20,7 +20,7 @@ #ifndef REDISWRITER_H #define REDISWRITER_H -#include "redis/rediswriter.thpp" +#include "redis/rediswriter-ti.hpp" #include "icinga/customvarobject.hpp" #include "remote/messageorigin.hpp" #include "base/timer.hpp" @@ -88,7 +88,7 @@ private: void ExceptionHandler(boost::exception_ptr exp); - boost::shared_ptr ExecuteQuery(const std::vector& query); + std::shared_ptr ExecuteQuery(const std::vector& query); std::vector > ExecuteQueries(const std::vector >& queries); Timer::Ptr m_StatsTimer; diff --git a/lib/redis/rediswriter.ti b/lib/redis/rediswriter.ti index 0aa76c9c0..db3df0ab5 100644 --- a/lib/redis/rediswriter.ti +++ b/lib/redis/rediswriter.ti @@ -1,6 +1,6 @@ /****************************************************************************** * Icinga 2 * - * Copyright (C) 2012-2017 Icinga Development Team (https://www.icinga.com/) * + * Copyright (C) 2012-2018 Icinga Development Team (https://www.icinga.com/) * * * * This program is free software; you can redistribute it and/or * * modify it under the terms of the GNU General Public License * @@ -19,7 +19,7 @@ #include "base/configobject.hpp" -library demo; +library redis; namespace icinga { diff --git a/third-party/hiredis/CMakeLists.txt b/third-party/hiredis/CMakeLists.txt index afda9579f..e1a00a443 100644 --- a/third-party/hiredis/CMakeLists.txt +++ b/third-party/hiredis/CMakeLists.txt @@ -1,5 +1,5 @@ # Icinga 2 -# Copyright (C) 2012-2017 Icinga Development Team (https://www.icinga.com/) +# Copyright (C) 2012-2018 Icinga Development Team (https://www.icinga.com/) # # This program is free software; you can redistribute it and/or # modify it under the terms of the GNU General Public License @@ -15,7 +15,7 @@ # along with this program; if not, write to the Free Software Foundation # Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA. -add_library(hiredis SHARED net.c net.h hiredis.c hiredis.h sds.c sds.h async.c async.h read.c read.h) +add_library(hiredis OBJECT net.c net.h hiredis.c hiredis.h sds.c sds.h async.c async.h read.c read.h) if(HAVE_VISIBILITY_HIDDEN) set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -fvisibility=default") @@ -25,18 +25,4 @@ endif() set_target_properties ( hiredis PROPERTIES FOLDER Lib - VERSION ${SPEC_VERSION} ) - -install( - TARGETS hiredis - RUNTIME DESTINATION ${CMAKE_INSTALL_SBINDIR} - LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR}/icinga2 -) - -if(APPLE) - install( - TARGETS hiredis - LIBRARY DESTINATION ${CMAKE_INSTALL_BINDIR}/icinga-studio.app/Contents - ) -endif()