[Pkg-nagios-changes] [pkg-icinga2] 03/04: Imported Upstream version 2.4.1
Alexander Wirt
formorer at debian.org
Thu Nov 26 11:59:48 UTC 2015
This is an automated email from the git hooks/post-receive script.
formorer pushed a commit to branch master
in repository pkg-icinga2.
commit d91f9847f9c6cf9730b1d0caea5056adf016b420
Author: Alexander Wirt <formorer at debian.org>
Date: Thu Nov 26 12:58:13 2015 +0100
Imported Upstream version 2.4.1
---
CMakeLists.txt | 6 +--
INSTALL.md | 2 -
doc/2-getting-started.md | 6 +--
lib/base/configobject.cpp | 7 +--
lib/base/configobject.hpp | 4 --
lib/remote/apilistener.cpp | 83 +++++++++++++-----------------
lib/remote/apilistener.hpp | 8 ---
lib/remote/endpoint.cpp | 2 +-
lib/remote/jsonrpcconnection-heartbeat.cpp | 6 +++
lib/remote/zone.cpp | 9 +---
lib/remote/zone.hpp | 5 --
11 files changed, 48 insertions(+), 90 deletions(-)
diff --git a/CMakeLists.txt b/CMakeLists.txt
index 64c1a60..a280a88 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -38,7 +38,6 @@ option(ICINGA2_WITH_LIVESTATUS "Build the Livestatus module" ON)
option(ICINGA2_WITH_NOTIFICATION "Build the notification module" ON)
option(ICINGA2_WITH_PERFDATA "Build the perfdata module" ON)
option(ICINGA2_WITH_STUDIO "Build the Icinga Studio application" OFF)
-option(ICINGA2_WITH_TESTS "Run unit tests" ON)
file(STRINGS icinga2.spec VERSION_LINE REGEX "^Version: ")
string(REPLACE "Version: " "" ICINGA2_VERSION ${VERSION_LINE})
@@ -242,6 +241,7 @@ add_subdirectory(icinga-app)
add_subdirectory(etc)
add_subdirectory(itl)
add_subdirectory(doc)
+add_subdirectory(test)
add_subdirectory(agent)
add_subdirectory(plugins)
@@ -249,10 +249,6 @@ if(ICINGA2_WITH_STUDIO)
add_subdirectory(icinga-studio)
endif()
-if(ICINGA2_WITH_TESTS)
- add_subdirectory(test)
-endif()
-
set(CPACK_PACKAGE_NAME "Icinga2")
set(CPACK_PACKAGE_VENDOR "Icinga Development Team")
set(CPACK_PACKAGE_VERSION ${ICINGA2_VERSION})
diff --git a/INSTALL.md b/INSTALL.md
index 5cc0065..116b703 100644
--- a/INSTALL.md
+++ b/INSTALL.md
@@ -107,8 +107,6 @@ Defaults to `OFF`.
- `ICINGA2_WITH_LIVESTATUS`: Determines whether the Livestatus module is built; defaults to `ON`
- `ICINGA2_WITH_NOTIFICATION`: Determines whether the notification module is built; defaults to `ON`
- `ICINGA2_WITH_PERFDATA`: Determines whether the perfdata module is built; defaults to `ON`
-- `ICINGA2_WITH_STUDIO`: Determines whether the Icinga Studio application is built; defaults to `OFF`
-- `ICINGA2_WITH_TESTS`: Determines whether the unit tests are built; defaults to `ON`
CMake determines the Icinga 2 version number using `git describe` if the
source directory is contained in a Git repository. Otherwise the version number
diff --git a/doc/2-getting-started.md b/doc/2-getting-started.md
index a3697f9..ae5a002 100644
--- a/doc/2-getting-started.md
+++ b/doc/2-getting-started.md
@@ -498,17 +498,15 @@ and located at /usr/local/share/icinga2-ido-pgsql/schema/pgsql.sql
Set up a PostgreSQL database for Icinga 2:
# cd /tmp
- # sudo -u postgres psql -c "CREATE ROLE icinga WITH LOGIN PASSWORD 'icinga'"
+ # sudo -u postgres psql -c "CREATE ROLE icinga WITH LOGIN PASSWORD 'icinga'";
# sudo -u postgres createdb -O icinga -E UTF8 icinga
# sudo -u postgres createlang plpgsql icinga
> **Note**
>
> When using PostgreSQL 9.x you can omit the `createlang` command.
-> Also it is assumed here that your locale is set to utf-8, you may run into
-> problems otherwise.
-Locate your pg\_hba.conf (Debian: `/etc/postgresql/*/main/pg_hba.conf`,
+Locate your pg_hba.conf (Debian: `/etc/postgresql/*/main/pg_hba.conf`,
RHEL/SUSE: `/var/lib/pgsql/data/pg_hba.conf`), add the icinga user with md5
authentication method and restart the postgresql server.
diff --git a/lib/base/configobject.cpp b/lib/base/configobject.cpp
index 00b4af1..9b59f69 100644
--- a/lib/base/configobject.cpp
+++ b/lib/base/configobject.cpp
@@ -440,7 +440,7 @@ void ConfigObject::OnConfigLoaded(void)
void ConfigObject::OnAllConfigLoaded(void)
{
- m_Zone = GetObject("Zone", GetZoneName());
+ /* Nothing to do here. */
}
void ConfigObject::CreateChildObjects(const Type::Ptr& childType)
@@ -684,8 +684,3 @@ ConfigObject::Ptr ConfigObject::GetObject(const String& type, const String& name
return ConfigObject::Ptr();
return dtype->GetObject(name);
}
-
-ConfigObject::Ptr ConfigObject::GetZone(void) const
-{
- return m_Zone;
-}
diff --git a/lib/base/configobject.hpp b/lib/base/configobject.hpp
index 94a69c3..1991d5c 100644
--- a/lib/base/configobject.hpp
+++ b/lib/base/configobject.hpp
@@ -53,8 +53,6 @@ public:
Value GetExtension(const String& key);
void ClearExtension(const String& key);
- ConfigObject::Ptr GetZone(void) const;
-
void ModifyAttribute(const String& attr, const Value& value, bool updateVersion = true);
void RestoreAttribute(const String& attr, bool updateVersion = true);
bool IsAttributeModified(const String& attr) const;
@@ -99,8 +97,6 @@ protected:
explicit ConfigObject(void);
private:
- ConfigObject::Ptr m_Zone;
-
static void RestoreObject(const String& message, int attributeTypes);
};
diff --git a/lib/remote/apilistener.cpp b/lib/remote/apilistener.cpp
index 2deb032..653b736 100644
--- a/lib/remote/apilistener.cpp
+++ b/lib/remote/apilistener.cpp
@@ -41,14 +41,13 @@ using namespace icinga;
REGISTER_TYPE(ApiListener);
boost::signals2::signal<void(bool)> ApiListener::OnMasterChanged;
-ApiListener::Ptr ApiListener::m_Instance;
REGISTER_STATSFUNCTION(ApiListener, &ApiListener::StatsFunc);
REGISTER_APIFUNCTION(Hello, icinga, &ApiListener::HelloAPIHandler);
ApiListener::ApiListener(void)
- : m_SyncQueue(0, 4), m_LogMessageCount(0)
+ : m_LogMessageCount(0)
{ }
void ApiListener::OnConfigLoaded(void)
@@ -91,9 +90,7 @@ void ApiListener::OnConfigLoaded(void)
void ApiListener::OnAllConfigLoaded(void)
{
- m_LocalEndpoint = Endpoint::GetByName(GetIdentity());
-
- if (!m_LocalEndpoint)
+ if (!Endpoint::GetByName(GetIdentity()))
BOOST_THROW_EXCEPTION(ScriptError("Endpoint object for '" + GetIdentity() + "' is missing.", GetDebugInfo()));
}
@@ -104,10 +101,11 @@ void ApiListener::Start(bool runtimeCreated)
{
SyncZoneDirs();
- if (m_Instance)
- BOOST_THROW_EXCEPTION(ScriptError("Only one ApiListener object is allowed.", GetDebugInfo()));
-
- m_Instance = this;
+ if (std::distance(ConfigType::GetObjectsByType<ApiListener>().first,
+ ConfigType::GetObjectsByType<ApiListener>().second) > 1) {
+ Log(LogCritical, "ApiListener", "Only one ApiListener object is allowed.");
+ return;
+ }
ObjectImpl<ApiListener>::Start(runtimeCreated);
@@ -135,7 +133,10 @@ void ApiListener::Start(bool runtimeCreated)
ApiListener::Ptr ApiListener::GetInstance(void)
{
- return m_Instance;
+ BOOST_FOREACH(const ApiListener::Ptr& listener, ConfigType::GetObjectsByType<ApiListener>())
+ return listener;
+
+ return ApiListener::Ptr();
}
boost::shared_ptr<SSL_CTX> ApiListener::GetSSLContext(void) const
@@ -168,7 +169,7 @@ bool ApiListener::IsMaster(void) const
if (!master)
return false;
- return master == GetLocalEndpoint();
+ return master->GetName() == GetIdentity();
}
/**
@@ -373,8 +374,26 @@ void ApiListener::NewClientHandlerInternal(const Socket::Ptr& client, const Stri
if (endpoint) {
endpoint->AddClient(aclient);
- if (need_sync)
- m_SyncQueue.Enqueue(boost::bind(&ApiListener::SyncClient, this, aclient, endpoint));
+ if (need_sync) {
+ {
+ ObjectLock olock(endpoint);
+
+ endpoint->SetSyncing(true);
+ }
+
+ Log(LogInformation, "ApiListener")
+ << "Sending updates for endpoint '" << endpoint->GetName() << "'.";
+
+ /* sync zone file config */
+ SendConfigUpdate(aclient);
+ /* sync runtime config */
+ SendRuntimeConfigObjects(aclient);
+
+ Log(LogInformation, "ApiListener")
+ << "Finished sending updates for endpoint '" << endpoint->GetName() << "'.";
+
+ ReplayLog(aclient);
+ }
} else
AddAnonymousClient(aclient);
} else {
@@ -386,33 +405,6 @@ void ApiListener::NewClientHandlerInternal(const Socket::Ptr& client, const Stri
}
}
-void ApiListener::SyncClient(const JsonRpcConnection::Ptr& aclient, const Endpoint::Ptr& endpoint)
-{
- try {
- {
- ObjectLock olock(endpoint);
-
- endpoint->SetSyncing(true);
- }
-
- Log(LogInformation, "ApiListener")
- << "Sending updates for endpoint '" << endpoint->GetName() << "'.";
-
- /* sync zone file config */
- SendConfigUpdate(aclient);
- /* sync runtime config */
- SendRuntimeConfigObjects(aclient);
-
- Log(LogInformation, "ApiListener")
- << "Finished sending updates for endpoint '" << endpoint->GetName() << "'.";
-
- ReplayLog(aclient);
- } catch (const std::exception& ex) {
- Log(LogCritical, "ApiListener")
- << "Error while syncing endpoint '" << endpoint->GetName() << "': " << DiagnosticInformation(ex);
- }
-}
-
void ApiListener::ApiTimerHandler(void)
{
double now = Utility::GetTime();
@@ -425,7 +417,7 @@ void ApiListener::ApiTimerHandler(void)
bool need = false;
BOOST_FOREACH(const Endpoint::Ptr& endpoint, ConfigType::GetObjectsByType<Endpoint>()) {
- if (endpoint == GetLocalEndpoint())
+ if (endpoint->GetName() == GetIdentity())
continue;
if (endpoint->GetLogDuration() >= 0 && ts < now - endpoint->GetLogDuration())
@@ -462,7 +454,7 @@ void ApiListener::ApiTimerHandler(void)
BOOST_FOREACH(const Endpoint::Ptr& endpoint, zone->GetEndpoints()) {
/* don't connect to ourselves */
- if (endpoint == GetLocalEndpoint()) {
+ if (endpoint->GetName() == GetIdentity()) {
Log(LogDebug, "ApiListener")
<< "Not connecting to Endpoint '" << endpoint->GetName() << "' because that's us.";
continue;
@@ -609,7 +601,7 @@ void ApiListener::SyncRelayMessage(const MessageOrigin::Ptr& origin,
BOOST_FOREACH(const Endpoint::Ptr& endpoint, ConfigType::GetObjectsByType<Endpoint>()) {
/* don't relay messages to ourselves */
- if (endpoint == GetLocalEndpoint())
+ if (endpoint->GetName() == GetIdentity())
continue;
Zone::Ptr target_zone = endpoint->GetZone();
@@ -1037,8 +1029,3 @@ Value ApiListener::HelloAPIHandler(const MessageOrigin::Ptr& origin, const Dicti
{
return Empty;
}
-
-Endpoint::Ptr ApiListener::GetLocalEndpoint(void) const
-{
- return m_LocalEndpoint;
-}
diff --git a/lib/remote/apilistener.hpp b/lib/remote/apilistener.hpp
index 7ddea81..9cf8278 100644
--- a/lib/remote/apilistener.hpp
+++ b/lib/remote/apilistener.hpp
@@ -59,8 +59,6 @@ public:
Endpoint::Ptr GetMaster(void) const;
bool IsMaster(void) const;
- Endpoint::Ptr GetLocalEndpoint(void) const;
-
static String GetApiDir(void);
void SyncSendMessage(const Endpoint::Ptr& endpoint, const Dictionary::Ptr& message);
@@ -99,9 +97,6 @@ private:
std::set<JsonRpcConnection::Ptr> m_AnonymousClients;
std::set<HttpServerConnection::Ptr> m_HttpClients;
Timer::Ptr m_Timer;
- Endpoint::Ptr m_LocalEndpoint;
-
- static ApiListener::Ptr m_Instance;
void ApiTimerHandler(void);
@@ -113,7 +108,6 @@ private:
void ListenerThreadProc(const Socket::Ptr& server);
WorkQueue m_RelayQueue;
- WorkQueue m_SyncQueue;
boost::mutex m_LogLock;
Stream::Ptr m_LogFile;
@@ -145,8 +139,6 @@ private:
void DeleteConfigObject(const ConfigObject::Ptr& object, const MessageOrigin::Ptr& origin,
const JsonRpcConnection::Ptr& client = JsonRpcConnection::Ptr());
void SendRuntimeConfigObjects(const JsonRpcConnection::Ptr& aclient);
-
- void SyncClient(const JsonRpcConnection::Ptr& aclient, const Endpoint::Ptr& endpoint);
};
}
diff --git a/lib/remote/endpoint.cpp b/lib/remote/endpoint.cpp
index 4d7464f..fc8c986 100644
--- a/lib/remote/endpoint.cpp
+++ b/lib/remote/endpoint.cpp
@@ -122,5 +122,5 @@ Endpoint::Ptr Endpoint::GetLocalEndpoint(void)
if (!listener)
return Endpoint::Ptr();
- return listener->GetLocalEndpoint();
+ return Endpoint::GetByName(listener->GetIdentity());
}
diff --git a/lib/remote/jsonrpcconnection-heartbeat.cpp b/lib/remote/jsonrpcconnection-heartbeat.cpp
index f61cb4b..fdf5400 100644
--- a/lib/remote/jsonrpcconnection-heartbeat.cpp
+++ b/lib/remote/jsonrpcconnection-heartbeat.cpp
@@ -46,6 +46,12 @@ void JsonRpcConnection::HeartbeatTimerHandler(void)
{
BOOST_FOREACH(const Endpoint::Ptr& endpoint, ConfigType::GetObjectsByType<Endpoint>()) {
BOOST_FOREACH(const JsonRpcConnection::Ptr& client, endpoint->GetClients()) {
+ if (endpoint->GetSyncing()) {
+ Log(LogInformation, "JsonRpcConnection")
+ << "Not sending heartbeat for endpoint '" << endpoint->GetName() << "' because we're replaying the log for it.";
+ continue;
+ }
+
if (client->m_NextHeartbeat != 0 && client->m_NextHeartbeat < Utility::GetTime()) {
Log(LogWarning, "JsonRpcConnection")
<< "Client for endpoint '" << endpoint->GetName() << "' has requested "
diff --git a/lib/remote/zone.cpp b/lib/remote/zone.cpp
index b9538d5..1a307c9 100644
--- a/lib/remote/zone.cpp
+++ b/lib/remote/zone.cpp
@@ -27,14 +27,9 @@ using namespace icinga;
REGISTER_TYPE(Zone);
-void Zone::OnAllConfigLoaded(void)
-{
- m_Parent = Zone::GetByName(GetParentRaw());
-}
-
Zone::Ptr Zone::GetParent(void) const
{
- return m_Parent;
+ return Zone::GetByName(GetParentRaw());
}
std::set<Endpoint::Ptr> Zone::GetEndpoints(void) const
@@ -66,7 +61,7 @@ bool Zone::CanAccessObject(const ConfigObject::Ptr& object)
if (dynamic_pointer_cast<Zone>(object))
object_zone = static_pointer_cast<Zone>(object);
else
- object_zone = static_pointer_cast<Zone>(object->GetZone());
+ object_zone = Zone::GetByName(object->GetZoneName());
if (!object_zone)
object_zone = Zone::GetLocalZone();
diff --git a/lib/remote/zone.hpp b/lib/remote/zone.hpp
index 5738aa7..9092e26 100644
--- a/lib/remote/zone.hpp
+++ b/lib/remote/zone.hpp
@@ -36,8 +36,6 @@ public:
DECLARE_OBJECT(Zone);
DECLARE_OBJECTNAME(Zone);
- virtual void OnAllConfigLoaded(void) override;
-
Zone::Ptr GetParent(void) const;
std::set<Endpoint::Ptr> GetEndpoints(void) const;
@@ -46,9 +44,6 @@ public:
bool IsGlobal(void) const;
static Zone::Ptr GetLocalZone(void);
-
-private:
- Zone::Ptr m_Parent;
};
}
--
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-nagios/pkg-icinga2.git
More information about the Pkg-nagios-changes
mailing list