mirror of
https://github.com/Icinga/icinga2.git
synced 2025-07-27 07:34:15 +02:00
Compile redis into the icinga2 binary; apply more C++11 code changes
This commit is contained in:
parent
61edfcb68d
commit
ddf2aea065
@ -204,6 +204,9 @@ if(HAVE_SYSTEMD)
|
|||||||
list(APPEND base_DEPS systemd)
|
list(APPEND base_DEPS systemd)
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
|
if(ICINGA2_WITH_REDIS)
|
||||||
|
list(APPEND base_OBJS $<TARGET_OBJECTS:hiredis>)
|
||||||
|
endif()
|
||||||
|
|
||||||
if(EDITLINE_FOUND)
|
if(EDITLINE_FOUND)
|
||||||
list(APPEND base_DEPS ${EDITLINE_LIBRARIES})
|
list(APPEND base_DEPS ${EDITLINE_LIBRARIES})
|
||||||
|
@ -53,6 +53,10 @@ if(ICINGA2_WITH_PERFDATA)
|
|||||||
list(APPEND icinga_app_SOURCES $<TARGET_OBJECTS:perfdata>)
|
list(APPEND icinga_app_SOURCES $<TARGET_OBJECTS:perfdata>)
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
|
if(ICINGA2_WITH_REDIS)
|
||||||
|
list(APPEND icinga_app_SOURCES $<TARGET_OBJECTS:redis>)
|
||||||
|
endif()
|
||||||
|
|
||||||
add_executable(icinga-app
|
add_executable(icinga-app
|
||||||
$<TARGET_OBJECTS:icingaloader>
|
$<TARGET_OBJECTS:icingaloader>
|
||||||
${base_OBJS}
|
${base_OBJS}
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
# Icinga 2
|
# 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
|
# This program is free software; you can redistribute it and/or
|
||||||
# modify it under the terms of the GNU General Public License
|
# 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
|
# along with this program; if not, write to the Free Software Foundation
|
||||||
# Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA.
|
# 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
|
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)
|
if(ICINGA2_UNITY_BUILD)
|
||||||
mkunity_target(redis redis redis_SOURCES)
|
mkunity_target(redis redis redis_SOURCES)
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
add_library(redis SHARED ${redis_SOURCES})
|
add_library(redis OBJECT ${redis_SOURCES})
|
||||||
|
|
||||||
target_link_libraries(redis ${Boost_LIBRARIES} base config icinga remote hiredis)
|
|
||||||
|
|
||||||
include_directories(${icinga2_SOURCE_DIR}/third-party)
|
include_directories(${icinga2_SOURCE_DIR}/third-party)
|
||||||
|
|
||||||
|
add_dependencies(redis base config icinga remote)
|
||||||
|
|
||||||
link_directories(${icinga2_BINARY_DIR}/third-party/hiredis)
|
link_directories(${icinga2_BINARY_DIR}/third-party/hiredis)
|
||||||
|
|
||||||
set_target_properties (
|
set_target_properties (
|
||||||
redis PROPERTIES
|
redis PROPERTIES
|
||||||
INSTALL_RPATH ${CMAKE_INSTALL_FULL_LIBDIR}/icinga2
|
|
||||||
DEFINE_SYMBOL I2_REDIS_BUILD
|
|
||||||
FOLDER Components
|
FOLDER Components
|
||||||
VERSION ${SPEC_VERSION}
|
|
||||||
)
|
)
|
||||||
|
|
||||||
install_if_not_exists(
|
install_if_not_exists(
|
||||||
@ -45,9 +43,4 @@ install_if_not_exists(
|
|||||||
${CMAKE_INSTALL_SYSCONFDIR}/icinga2/features-available
|
${CMAKE_INSTALL_SYSCONFDIR}/icinga2/features-available
|
||||||
)
|
)
|
||||||
|
|
||||||
install(
|
set(CPACK_NSIS_EXTRA_INSTALL_COMMANDS "${CPACK_NSIS_EXTRA_INSTALL_COMMANDS}" PARENT_SCOPE)
|
||||||
TARGETS redis
|
|
||||||
RUNTIME DESTINATION ${CMAKE_INSTALL_SBINDIR}
|
|
||||||
LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR}/icinga2
|
|
||||||
)
|
|
||||||
|
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
/******************************************************************************
|
/******************************************************************************
|
||||||
* Icinga 2 *
|
* 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 *
|
* This program is free software; you can redistribute it and/or *
|
||||||
* modify it under the terms of the GNU General Public License *
|
* modify it under the terms of the GNU General Public License *
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
/******************************************************************************
|
/******************************************************************************
|
||||||
* Icinga 2 *
|
* 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 *
|
* This program is free software; you can redistribute it and/or *
|
||||||
* modify it under the terms of the GNU General Public License *
|
* modify it under the terms of the GNU General Public License *
|
||||||
@ -18,7 +18,7 @@
|
|||||||
******************************************************************************/
|
******************************************************************************/
|
||||||
|
|
||||||
#include "redis/rediswriter.hpp"
|
#include "redis/rediswriter.hpp"
|
||||||
#include "redis/rediswriter.tcpp"
|
#include "redis/rediswriter-ti.cpp"
|
||||||
#include "remote/eventqueue.hpp"
|
#include "remote/eventqueue.hpp"
|
||||||
#include "base/json.hpp"
|
#include "base/json.hpp"
|
||||||
#include "base/statsfunction.hpp"
|
#include "base/statsfunction.hpp"
|
||||||
@ -147,7 +147,6 @@ void RedisWriter::TryToReconnect()
|
|||||||
m_ConfigDumpInProgress = false;
|
m_ConfigDumpInProgress = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
|
||||||
void RedisWriter::UpdateSubscriptionsTimerHandler()
|
void RedisWriter::UpdateSubscriptionsTimerHandler()
|
||||||
{
|
{
|
||||||
m_WorkQueue.Enqueue(std::bind(&RedisWriter::UpdateSubscriptions, this));
|
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);
|
<< "Invalid Redis subscriber info for subscriber '" << key << "': " << DiagnosticInformation(ex);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
*/
|
|
||||||
|
|
||||||
void RedisWriter::PublishStatsTimerHandler(void)
|
void RedisWriter::PublishStatsTimerHandler(void)
|
||||||
{
|
{
|
||||||
@ -233,10 +231,18 @@ void RedisWriter::PublishStats()
|
|||||||
return;
|
return;
|
||||||
|
|
||||||
//TODO: Figure out if more stats can be useful here.
|
//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();
|
Dictionary::Ptr status = new Dictionary();
|
||||||
Array::Ptr perfdata = new Array();
|
Array::Ptr perfdata = new Array();
|
||||||
func->Invoke(status, perfdata);
|
|
||||||
|
func->Invoke({ status, perfdata });
|
||||||
|
|
||||||
String jsonStats = JsonEncode(status);
|
String jsonStats = JsonEncode(status);
|
||||||
|
|
||||||
ExecuteQuery({ "PUBLISH", "icinga:stats", jsonStats });
|
ExecuteQuery({ "PUBLISH", "icinga:stats", jsonStats });
|
||||||
@ -278,7 +284,6 @@ void RedisWriter::HandleEvents()
|
|||||||
EventQueue::UnregisterIfUnused(queueName, queue);
|
EventQueue::UnregisterIfUnused(queueName, queue);
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
|
||||||
void RedisWriter::HandleEvent(const Dictionary::Ptr& event)
|
void RedisWriter::HandleEvent(const Dictionary::Ptr& event)
|
||||||
{
|
{
|
||||||
AssertOnWorkQueue();
|
AssertOnWorkQueue();
|
||||||
@ -313,9 +318,8 @@ void RedisWriter::HandleEvent(const Dictionary::Ptr& event)
|
|||||||
ExecuteQuery({ "EXEC" });
|
ExecuteQuery({ "EXEC" });
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
*/
|
|
||||||
|
|
||||||
void RedisWriter::HandleEvent(const Dictionary::Ptr& event)
|
void RedisWriter::SendEvent(const Dictionary::Ptr& event)
|
||||||
{
|
{
|
||||||
AssertOnWorkQueue();
|
AssertOnWorkQueue();
|
||||||
|
|
||||||
@ -412,7 +416,7 @@ std::vector<std::shared_ptr<redisReply> > RedisWriter::ExecuteQueries(const std:
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
boost::shared_ptr<redisReply> reply(rawReply, freeReplyObject);
|
std::shared_ptr<redisReply> reply(rawReply, freeReplyObject);
|
||||||
replies.push_back(reply);
|
replies.push_back(reply);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
/******************************************************************************
|
/******************************************************************************
|
||||||
* Icinga 2 *
|
* 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 *
|
* This program is free software; you can redistribute it and/or *
|
||||||
* modify it under the terms of the GNU General Public License *
|
* modify it under the terms of the GNU General Public License *
|
||||||
@ -20,7 +20,7 @@
|
|||||||
#ifndef REDISWRITER_H
|
#ifndef REDISWRITER_H
|
||||||
#define REDISWRITER_H
|
#define REDISWRITER_H
|
||||||
|
|
||||||
#include "redis/rediswriter.thpp"
|
#include "redis/rediswriter-ti.hpp"
|
||||||
#include "icinga/customvarobject.hpp"
|
#include "icinga/customvarobject.hpp"
|
||||||
#include "remote/messageorigin.hpp"
|
#include "remote/messageorigin.hpp"
|
||||||
#include "base/timer.hpp"
|
#include "base/timer.hpp"
|
||||||
@ -88,7 +88,7 @@ private:
|
|||||||
|
|
||||||
void ExceptionHandler(boost::exception_ptr exp);
|
void ExceptionHandler(boost::exception_ptr exp);
|
||||||
|
|
||||||
boost::shared_ptr<redisReply> ExecuteQuery(const std::vector<String>& query);
|
std::shared_ptr<redisReply> ExecuteQuery(const std::vector<String>& query);
|
||||||
std::vector<std::shared_ptr<redisReply> > ExecuteQueries(const std::vector<std::vector<String> >& queries);
|
std::vector<std::shared_ptr<redisReply> > ExecuteQueries(const std::vector<std::vector<String> >& queries);
|
||||||
|
|
||||||
Timer::Ptr m_StatsTimer;
|
Timer::Ptr m_StatsTimer;
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
/******************************************************************************
|
/******************************************************************************
|
||||||
* Icinga 2 *
|
* 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 *
|
* This program is free software; you can redistribute it and/or *
|
||||||
* modify it under the terms of the GNU General Public License *
|
* modify it under the terms of the GNU General Public License *
|
||||||
@ -19,7 +19,7 @@
|
|||||||
|
|
||||||
#include "base/configobject.hpp"
|
#include "base/configobject.hpp"
|
||||||
|
|
||||||
library demo;
|
library redis;
|
||||||
|
|
||||||
namespace icinga
|
namespace icinga
|
||||||
{
|
{
|
||||||
|
18
third-party/hiredis/CMakeLists.txt
vendored
18
third-party/hiredis/CMakeLists.txt
vendored
@ -1,5 +1,5 @@
|
|||||||
# Icinga 2
|
# 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
|
# This program is free software; you can redistribute it and/or
|
||||||
# modify it under the terms of the GNU General Public License
|
# 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
|
# along with this program; if not, write to the Free Software Foundation
|
||||||
# Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA.
|
# 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)
|
if(HAVE_VISIBILITY_HIDDEN)
|
||||||
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -fvisibility=default")
|
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -fvisibility=default")
|
||||||
@ -25,18 +25,4 @@ endif()
|
|||||||
set_target_properties (
|
set_target_properties (
|
||||||
hiredis PROPERTIES
|
hiredis PROPERTIES
|
||||||
FOLDER Lib
|
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()
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user