From 636acd1a2c2fde0f815107d87da3affbf11b7918 Mon Sep 17 00:00:00 2001 From: Gunnar Beutner Date: Mon, 17 Sep 2012 09:36:51 +0200 Subject: [PATCH 01/24] Add missing Makefile.am. --- icinga-app/config/Makefile.am | 8 ++++++++ 1 file changed, 8 insertions(+) create mode 100644 icinga-app/config/Makefile.am diff --git a/icinga-app/config/Makefile.am b/icinga-app/config/Makefile.am new file mode 100644 index 000000000..3e27bcfa2 --- /dev/null +++ b/icinga-app/config/Makefile.am @@ -0,0 +1,8 @@ +icinga2confdir = $(sysconfdir)/icinga2 +icinga2conf_DATA = \ + icinga2.conf.dist \ + example-ca.crt \ + example-ca.key \ + icinga-c1.pem \ + icinga-c2.pem \ + icinga-c3.pem From 0884a67ebeb9edb404d78b2cc5c0c666f0be53ad Mon Sep 17 00:00:00 2001 From: Gunnar Beutner Date: Mon, 17 Sep 2012 09:47:02 +0200 Subject: [PATCH 02/24] Fixed crash in EndpointManager::SubscriptionTimerHandler. --- lib/remoting/endpointmanager.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/lib/remoting/endpointmanager.cpp b/lib/remoting/endpointmanager.cpp index 674d413cd..fbf13c0d5 100644 --- a/lib/remoting/endpointmanager.cpp +++ b/lib/remoting/endpointmanager.cpp @@ -322,7 +322,8 @@ void EndpointManager::SubscriptionTimerHandler(void) } } - m_Endpoint->SetSubscriptions(subscriptions); + if (m_Endpoint) + m_Endpoint->SetSubscriptions(subscriptions); } void EndpointManager::ReconnectTimerHandler(void) From 093931a1d3ab14e3aed11184af26b144d328c7b2 Mon Sep 17 00:00:00 2001 From: Gunnar Beutner Date: Mon, 17 Sep 2012 09:48:34 +0200 Subject: [PATCH 03/24] Renamed icinga binary to icinga2 to avoid conflicts with Icinga 1.x --- icinga-app/Makefile.am | 12 ++++++------ icinga2.spec | 2 +- 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/icinga-app/Makefile.am b/icinga-app/Makefile.am index e5fc0887d..3f7e5a68c 100644 --- a/icinga-app/Makefile.am +++ b/icinga-app/Makefile.am @@ -4,12 +4,12 @@ SUBDIRS = \ config bin_PROGRAMS = \ - icinga + icinga2 -icinga_SOURCES = \ +icinga2_SOURCES = \ icinga.cpp -icinga_CPPFLAGS = \ +icinga2_CPPFLAGS = \ -DI2_ICINGALAUNCHER_BUILD \ $(LTDLINCL) \ $(BOOST_CPPFLAGS) \ @@ -19,10 +19,10 @@ icinga_CPPFLAGS = \ -I${top_srcdir}/lib/icinga \ -I${top_srcdir} -icinga_LDFLAGS = \ +icinga2_LDFLAGS = \ $(BOOST_LDFLAGS) -icinga_LDADD = \ +icinga2_LDADD = \ $(LIBLTDL) \ $(BOOST_SIGNALS_LIB) \ $(BOOST_THREAD_LIB) \ @@ -38,6 +38,6 @@ icinga_LDADD = \ -dlopen ${top_builddir}/components/delegation/delegation.la \ -dlopen ${top_builddir}/components/demo/demo.la -icinga_DEPENDENCIES = \ +icinga2_DEPENDENCIES = \ ${top_builddir}/components/replication/replication.la \ ${top_builddir}/components/convenience/convenience.la diff --git a/icinga2.spec b/icinga2.spec index 1ba401330..039ff41aa 100644 --- a/icinga2.spec +++ b/icinga2.spec @@ -33,7 +33,7 @@ make install DESTDIR=%{buildroot} %files %defattr(-,root,root) -%{_bindir}/icinga +%{_bindir}/icinga2 %{_datadir}/doc/icinga2 %{_libdir}/icinga2 %{_sysconfdir}/icinga2 From 86c0aff7195c1603fd5fe48c7acdc2ccb46d8cc1 Mon Sep 17 00:00:00 2001 From: Gunnar Beutner Date: Mon, 17 Sep 2012 11:13:35 +0200 Subject: [PATCH 04/24] Build fix for Windows. --- icinga-app/icinga.cpp | 8 +++++--- lib/base/base.vcxproj | 2 -- lib/base/base.vcxproj.filters | 6 ------ 3 files changed, 5 insertions(+), 11 deletions(-) diff --git a/icinga-app/icinga.cpp b/icinga-app/icinga.cpp index 5f4de4dd5..2efdc6ba0 100644 --- a/icinga-app/icinga.cpp +++ b/icinga-app/icinga.cpp @@ -24,8 +24,6 @@ # define ICINGA_VERSION VERSION ", " GIT_MESSAGE # include -#else /* _WIN32 */ -# define ICINGA_VERSION VERSION #endif /* _WIN32 */ using namespace icinga; @@ -51,7 +49,11 @@ int main(int argc, char **argv) * in the base library. */ Application::SetMainThread(); - Logger::Write(LogInformation, "icinga", "Icinga application loader (version: " ICINGA_VERSION ")"); + Logger::Write(LogInformation, "icinga", "Icinga application loader" +#ifndef _WIN32 + " (version: " ICINGA_VERSION ")" +#endif /* _WIN32 */ + ); if (argc < 3 || strcmp(argv[1], "-c") != 0) { stringstream msgbuf; diff --git a/lib/base/base.vcxproj b/lib/base/base.vcxproj index 50f17fab1..7a9b7b78c 100644 --- a/lib/base/base.vcxproj +++ b/lib/base/base.vcxproj @@ -36,7 +36,6 @@ - @@ -69,7 +68,6 @@ - diff --git a/lib/base/base.vcxproj.filters b/lib/base/base.vcxproj.filters index d059aaefc..a7b9317e4 100644 --- a/lib/base/base.vcxproj.filters +++ b/lib/base/base.vcxproj.filters @@ -34,9 +34,6 @@ Quelldateien - - Quelldateien - Quelldateien @@ -129,9 +126,6 @@ Headerdateien - - Headerdateien - Headerdateien From 4a1a02de7b623f02a44e4df4458c3434b9252fb3 Mon Sep 17 00:00:00 2001 From: Gunnar Beutner Date: Mon, 17 Sep 2012 11:15:10 +0200 Subject: [PATCH 05/24] Renamed the VS solution file to match the project's name. --- icinga.sln => icinga2.sln | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename icinga.sln => icinga2.sln (100%) diff --git a/icinga.sln b/icinga2.sln similarity index 100% rename from icinga.sln rename to icinga2.sln From d7b55f49260b48f3a6cb695a2ca445f137cc46ac Mon Sep 17 00:00:00 2001 From: Gunnar Beutner Date: Mon, 17 Sep 2012 11:17:15 +0200 Subject: [PATCH 06/24] Changed minimum version for Boost to 1.42 --- configure.ac | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/configure.ac b/configure.ac index dd99c5000..010e29c40 100644 --- a/configure.ac +++ b/configure.ac @@ -51,7 +51,7 @@ AM_PROG_LEX AC_PROG_YACC AC_PROG_LIBTOOL AX_CXX_GCC_ABI_DEMANGLE -AX_BOOST_BASE([1.46], [], [AC_MSG_ERROR([You need the Boost headers and libraries in order to build this application])]) +AX_BOOST_BASE([1.42], [], [AC_MSG_ERROR([You need the Boost headers and libraries in order to build this application])]) AX_BOOST_SIGNALS AX_BOOST_THREAD AX_BOOST_SYSTEM From d4fc6fc67244598b2eacb278a2ddd9ddc4dcaab9 Mon Sep 17 00:00:00 2001 From: Gunnar Beutner Date: Mon, 17 Sep 2012 13:32:59 +0200 Subject: [PATCH 07/24] Fix: Load the 'replication' component. --- lib/icinga/icingaapplication.cpp | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/lib/icinga/icingaapplication.cpp b/lib/icinga/icingaapplication.cpp index 9d7f91096..f875657fa 100644 --- a/lib/icinga/icingaapplication.cpp +++ b/lib/icinga/icingaapplication.cpp @@ -34,13 +34,13 @@ const String IcingaApplication::DefaultStatePath = "icinga.state"; IcingaApplication::IcingaApplication(const Dictionary::Ptr& serializedUpdate) : Application(serializedUpdate) { - /* load cibsync config component */ - ConfigItemBuilder::Ptr cibsyncComponentConfig = boost::make_shared(); - cibsyncComponentConfig->SetType("Component"); - cibsyncComponentConfig->SetName("cibsync"); - cibsyncComponentConfig->SetLocal(true); - cibsyncComponentConfig->Compile()->Commit(); - cibsyncComponentConfig.reset(); + /* load replication config component */ + ConfigItemBuilder::Ptr replicationComponentConfig = boost::make_shared(); + replicationComponentConfig->SetType("Component"); + replicationComponentConfig->SetName("replication"); + replicationComponentConfig->SetLocal(true); + replicationComponentConfig->Compile()->Commit(); + replicationComponentConfig.reset(); /* load convenience config component */ ConfigItemBuilder::Ptr convenienceComponentConfig = boost::make_shared(); From fee4246f5512343ce7d6f9faea0412295f9be3fa Mon Sep 17 00:00:00 2001 From: Gunnar Beutner Date: Mon, 17 Sep 2012 13:35:55 +0200 Subject: [PATCH 08/24] Updated doxygen documentation. --- docs/Doxyfile.in | 2 +- lib/base/component.h | 5 +++++ lib/base/dictionary.cpp | 3 +-- lib/base/dynamicobject.h | 14 +++++++++++++- lib/base/event.h | 5 +++++ lib/base/fifo.cpp | 15 --------------- lib/base/ioqueue.h | 6 ++++-- lib/base/logger.cpp | 5 ++--- lib/base/logger.h | 7 +++++++ lib/base/netstring.cpp | 12 ++++++------ lib/base/process.h | 11 +++++++++++ lib/base/qstring.cpp | 19 +++++++++++++++++++ lib/base/qstring.h | 21 ++++++++++++++++++++- lib/base/ringbuffer.h | 5 +++++ lib/base/scriptfunction.h | 5 +++++ lib/base/scripttask.h | 5 +++++ lib/base/streamlogger.cpp | 1 - lib/base/streamlogger.h | 4 +++- lib/base/sysloglogger.cpp | 19 +++++++++++++++++++ lib/base/sysloglogger.h | 21 +++++++++++++++++++++ lib/base/tcpserver.h | 2 +- lib/base/utility.cpp | 2 +- lib/base/utility.h | 2 +- lib/base/value.cpp | 2 +- lib/config/i2-config.h | 7 ++++--- lib/icinga/cib.h | 6 ++++++ lib/icinga/host.h | 5 +++++ lib/icinga/hostgroup.h | 5 +++++ lib/icinga/i2-icinga.h | 6 +++--- lib/icinga/macroprocessor.h | 5 +++++ lib/icinga/nagioschecktask.h | 5 +++++ lib/icinga/nullchecktask.h | 5 +++++ lib/icinga/service.h | 15 +++++++++++++++ lib/icinga/servicegroup.h | 5 +++++ lib/icinga/servicestatechangemessage.h | 5 +++++ lib/remoting/endpoint.h | 2 +- lib/remoting/endpointmanager.h | 8 ++------ lib/remoting/i2-remoting.h | 6 +++--- lib/remoting/messagepart.cpp | 2 +- lib/remoting/messagepart.h | 2 +- 40 files changed, 227 insertions(+), 55 deletions(-) diff --git a/docs/Doxyfile.in b/docs/Doxyfile.in index 914126ca6..90be6a95b 100644 --- a/docs/Doxyfile.in +++ b/docs/Doxyfile.in @@ -648,7 +648,7 @@ WARN_LOGFILE = # directories like "/usr/src/myproject". Separate the files or directories # with spaces. -INPUT = @top_srcdir@/base @top_srcdir@/jsonrpc @top_srcdir@/icinga @top_srcdir@/components @top_srcdir@/icinga-app +INPUT = lib/base lib/config lib/icinga lib/remoting components icinga-app # This tag can be used to specify the character encoding of the source files # that doxygen parses. Internally doxygen uses the UTF-8 encoding, which is diff --git a/lib/base/component.h b/lib/base/component.h index ce6f6d3b0..d87335f4b 100644 --- a/lib/base/component.h +++ b/lib/base/component.h @@ -23,6 +23,11 @@ namespace icinga { +/** + * Interface for application extensions. + * + * @ingroup base + */ class I2_BASE_API IComponent : public Object { public: diff --git a/lib/base/dictionary.cpp b/lib/base/dictionary.cpp index e9442b183..7bf487028 100644 --- a/lib/base/dictionary.cpp +++ b/lib/base/dictionary.cpp @@ -217,9 +217,8 @@ Dictionary::Ptr Dictionary::FromJson(cJSON *json) } /** - * Converts a dictionary to a JSON object. + * Converts this dictionary to a JSON object. * - * @param dictionary The dictionary. * @returns A JSON object that is equivalent to the dictionary. Values that * cannot be represented in JSON are omitted. */ diff --git a/lib/base/dynamicobject.h b/lib/base/dynamicobject.h index 6ff8b77ac..42619e29b 100644 --- a/lib/base/dynamicobject.h +++ b/lib/base/dynamicobject.h @@ -23,6 +23,9 @@ namespace icinga { +/** + * The type of an attribute for a DynamicObject. + */ enum DynamicAttributeType { Attribute_Transient = 1, @@ -43,6 +46,9 @@ enum DynamicAttributeType Attribute_All = Attribute_Transient | Attribute_Local | Attribute_Replicated | Attribute_Config }; +/** + * An attribute for a DynamicObject. + */ struct DynamicAttribute { Value Data; @@ -51,7 +57,8 @@ struct DynamicAttribute }; /** - * A dynamic object that can be instantiated from the configuration file. + * A dynamic object that can be instantiated from the configuration file + * and that supports attribute replication to remote application instances. * * @ingroup base */ @@ -147,6 +154,11 @@ private: void InternalApplyUpdate(const Dictionary::Ptr& serializedUpdate, int allowedTypes, bool suppressEvents); }; +/** + * Helper class for registering DynamicObject implementation classes. + * + * @ingroup base + */ class RegisterClassHelper { public: diff --git a/lib/base/event.h b/lib/base/event.h index 06ebe1f32..8a64b2ed6 100644 --- a/lib/base/event.h +++ b/lib/base/event.h @@ -23,6 +23,11 @@ namespace icinga { +/** + * A thread-safe event that can be posted to the main thread's event queue. + * + * @ingroup base + */ class I2_BASE_API Event { public: diff --git a/lib/base/fifo.cpp b/lib/base/fifo.cpp index 755bf1768..5f9e59bfd 100644 --- a/lib/base/fifo.cpp +++ b/lib/base/fifo.cpp @@ -130,21 +130,6 @@ void FIFO::Read(void *buffer, size_t count) Optimize(); } -/** - * Returns a pointer to the start of the write buffer. - * - * @param count Minimum size of the buffer; on return this parameter - * contains the actual size of the available buffer which can - * be larger than the requested size. - */ -/*void *FIFO::GetWriteBuffer(size_t *count) -{ - ResizeBuffer(m_Offset + m_DataSize + *count); - *count = m_AllocSize - m_Offset - m_DataSize; - - return m_Buffer + m_Offset + m_DataSize; -}*/ - /** * Implements IOQueue::Write. */ diff --git a/lib/base/ioqueue.h b/lib/base/ioqueue.h index 3ec17185c..842e9461f 100644 --- a/lib/base/ioqueue.h +++ b/lib/base/ioqueue.h @@ -25,6 +25,8 @@ namespace icinga /** * An I/O queue. + * + * @ingroup base */ class IOQueue { @@ -41,8 +43,8 @@ public: * to read more data than is available in the queue is a programming error. * Use GetBytesAvailable() to check how much data is available. * - * @buffer The buffer where data should be stored. May be NULL if you're - * not actually interested in the data. + * @param buffer The buffer where data should be stored. May be NULL if + * you're not actually interested in the data. * @param count The number of bytes to read from the queue. */ virtual void Peek(void *buffer, size_t count) = 0; diff --git a/lib/base/logger.cpp b/lib/base/logger.cpp index ff3c5bd4a..9d9f003c7 100644 --- a/lib/base/logger.cpp +++ b/lib/base/logger.cpp @@ -24,10 +24,9 @@ using namespace icinga; REGISTER_CLASS(Logger); /** - * Constructor for the logger class. + * Constructor for the Logger class. * - * @param minSeverity The minimum severity of log messages that should be sent - * to this logger. + * @param properties A serialized dictionary containing attributes. */ Logger::Logger(const Dictionary::Ptr& properties) : DynamicObject(properties) diff --git a/lib/base/logger.h b/lib/base/logger.h index 49a61863d..1b642fb59 100644 --- a/lib/base/logger.h +++ b/lib/base/logger.h @@ -50,6 +50,8 @@ struct LogEntry { /** * Base class for all loggers. + * + * @ingroup base */ class I2_BASE_API ILogger : public Object { @@ -68,6 +70,11 @@ private: friend class Logger; }; +/** + * A log provider. Can be instantiated from the config. + * + * @ingroup base + */ class I2_BASE_API Logger : public DynamicObject { public: diff --git a/lib/base/netstring.cpp b/lib/base/netstring.cpp index ff23cd275..3519580ca 100644 --- a/lib/base/netstring.cpp +++ b/lib/base/netstring.cpp @@ -24,9 +24,9 @@ using namespace icinga; /** * Reads data from an IOQueue in netString format. * - * @param fifo The IOQueue to read from. - * @param[out] str The String that has been read from the FIFO. - * @returns true if a complete String was read from the FIFO, false otherwise. + * @param queue The IOQueue to read from. + * @param[out] str The String that has been read from the IOQueue. + * @returns true if a complete String was read from the IOQueue, false otherwise. * @exception invalid_argument The input stream is invalid. * @see https://github.com/PeterScott/netString-c/blob/master/netString.c */ @@ -104,16 +104,16 @@ bool NetString::ReadStringFromIOQueue(IOQueue *queue, String *str) free(buffer); - /* remove the data from the fifo */ + /* remove the data from the IOQueue */ queue->Read(NULL, buffer_length); return true; } /** - * Writes data into a FIFO using the netString format. + * Writes data into an IOQueue using the netString format. * - * @param fifo The FIFO. + * @param queue The IOQueue. * @param str The String that is to be written. */ void NetString::WriteStringToIOQueue(IOQueue *queue, const String& str) diff --git a/lib/base/process.h b/lib/base/process.h index 36fb486a2..10fa8d33d 100644 --- a/lib/base/process.h +++ b/lib/base/process.h @@ -23,6 +23,11 @@ namespace icinga { +/** + * The result of a Process task. + * + * @ingroup base + */ struct ProcessResult { double ExecutionStart; @@ -31,6 +36,12 @@ struct ProcessResult String Output; }; +/** + * A process task. Executes an external application and returns the exit + * code and console output. + * + * @ingroup base + */ class I2_BASE_API Process : public AsyncTask { public: diff --git a/lib/base/qstring.cpp b/lib/base/qstring.cpp index a979002a7..03f0a3cf5 100644 --- a/lib/base/qstring.cpp +++ b/lib/base/qstring.cpp @@ -1,3 +1,22 @@ +/****************************************************************************** + * Icinga 2 * + * Copyright (C) 2012 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. * + ******************************************************************************/ + #include "i2-base.h" using namespace icinga; diff --git a/lib/base/qstring.h b/lib/base/qstring.h index c76fcf6a2..b5fe1c87c 100644 --- a/lib/base/qstring.h +++ b/lib/base/qstring.h @@ -1,3 +1,22 @@ +/****************************************************************************** + * Icinga 2 * + * Copyright (C) 2012 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. * + ******************************************************************************/ + #ifndef STRING_H #define STRING_H @@ -6,7 +25,7 @@ namespace icinga { /** * String class. * - * Rationale: The std::string class has an ambiguous assignment + * Rationale for having this: The std::string class has an ambiguous assignment * operator when used in conjunction with the Value class. */ class I2_BASE_API String diff --git a/lib/base/ringbuffer.h b/lib/base/ringbuffer.h index fc85a8cbe..217788246 100644 --- a/lib/base/ringbuffer.h +++ b/lib/base/ringbuffer.h @@ -23,6 +23,11 @@ namespace icinga { +/** + * A ring buffer that holds a pre-defined number of integers. + * + * @ingroup base + */ class I2_BASE_API RingBuffer { public: diff --git a/lib/base/scriptfunction.h b/lib/base/scriptfunction.h index 94bbc7138..86a459415 100644 --- a/lib/base/scriptfunction.h +++ b/lib/base/scriptfunction.h @@ -25,6 +25,11 @@ namespace icinga class ScriptTask; +/** + * A script function that can be used to execute a script task. + * + * @ingroup base + */ class I2_BASE_API ScriptFunction : public Object { public: diff --git a/lib/base/scripttask.h b/lib/base/scripttask.h index 7f55910d3..71d5912cf 100644 --- a/lib/base/scripttask.h +++ b/lib/base/scripttask.h @@ -23,6 +23,11 @@ namespace icinga { +/** + * A script task. + * + * @ingroup base + */ class I2_BASE_API ScriptTask : public AsyncTask { public: diff --git a/lib/base/streamlogger.cpp b/lib/base/streamlogger.cpp index c35da60da..758484a14 100644 --- a/lib/base/streamlogger.cpp +++ b/lib/base/streamlogger.cpp @@ -13,7 +13,6 @@ StreamLogger::StreamLogger(void) * Constructor for the StreamLogger class. * * @param stream The stream. - * @param minSeverity Minimum severity for log messages. */ StreamLogger::StreamLogger(ostream *stream) : ILogger(), m_Stream(stream), m_OwnsStream(false) diff --git a/lib/base/streamlogger.h b/lib/base/streamlogger.h index c06a4777c..541e5869d 100644 --- a/lib/base/streamlogger.h +++ b/lib/base/streamlogger.h @@ -5,7 +5,9 @@ namespace icinga { /** - * A logger that logs to stdout. + * A logger that logs to an iostream. + * + * @ingroup base */ class I2_BASE_API StreamLogger : public ILogger { diff --git a/lib/base/sysloglogger.cpp b/lib/base/sysloglogger.cpp index 8b66997b9..838d461f1 100644 --- a/lib/base/sysloglogger.cpp +++ b/lib/base/sysloglogger.cpp @@ -1,3 +1,22 @@ +/****************************************************************************** + * Icinga 2 * + * Copyright (C) 2012 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. * + ******************************************************************************/ + #include "i2-base.h" #ifndef _WIN32 diff --git a/lib/base/sysloglogger.h b/lib/base/sysloglogger.h index 19fa6d02e..291658d70 100644 --- a/lib/base/sysloglogger.h +++ b/lib/base/sysloglogger.h @@ -1,3 +1,22 @@ +/****************************************************************************** + * Icinga 2 * + * Copyright (C) 2012 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. * + ******************************************************************************/ + #ifndef SYSLOGLOGGER_H #define SYSLOGLOGGER_H @@ -7,6 +26,8 @@ namespace icinga /** * A logger that logs to syslog. + * + * @ingroup base */ class I2_BASE_API SyslogLogger : public ILogger { diff --git a/lib/base/tcpserver.h b/lib/base/tcpserver.h index 3ac03f08f..27aa3e34c 100644 --- a/lib/base/tcpserver.h +++ b/lib/base/tcpserver.h @@ -39,7 +39,7 @@ public: TcpServer(void); - void SetClientFactory(const ClientFactory& function); + void SetClientFactory(const ClientFactory& clientFactory); ClientFactory GetFactoryFunction(void) const; void Listen(void); diff --git a/lib/base/utility.cpp b/lib/base/utility.cpp index 710655d90..b64e6b145 100644 --- a/lib/base/utility.cpp +++ b/lib/base/utility.cpp @@ -249,7 +249,7 @@ String Utility::BaseName(const String& path) /** * Null deleter. Used as a parameter for the shared_ptr constructor. * - * @param -- The object that should be deleted. + * @param - The object that should be deleted. */ void Utility::NullDeleter(void *) { diff --git a/lib/base/utility.h b/lib/base/utility.h index 11687691b..7ff9a2ab2 100644 --- a/lib/base/utility.h +++ b/lib/base/utility.h @@ -44,7 +44,7 @@ public: static String DirName(const String& path); static String BaseName(const String& path); - static void NullDeleter(void *obj); + static void NullDeleter(void *); static double GetTime(void); diff --git a/lib/base/value.cpp b/lib/base/value.cpp index f29be13c4..f74bb7f3a 100644 --- a/lib/base/value.cpp +++ b/lib/base/value.cpp @@ -133,7 +133,7 @@ cJSON *Value::ToJson(void) const /** * Deserializes the string representation of a variant. * - * @params jsonString A JSON string obtained from Value::Serialize + * @param jsonString A JSON string obtained from Value::Serialize * @returns The newly deserialized variant. */ Value Value::Deserialize(const String& jsonString) diff --git a/lib/config/i2-config.h b/lib/config/i2-config.h index ce4cd4e69..868b7e66e 100644 --- a/lib/config/i2-config.h +++ b/lib/config/i2-config.h @@ -21,10 +21,11 @@ #define I2CONFIG_H /** - * @defgroup config Dynamic object library + * @defgroup config Configuration library * - * The dynamic object library implements serializable objects which support - * inheritance. + * The configuration library implements a compiler for Icinga 2's configuration + * format. It also provides functionality to create configuration objects + * at runtime. */ #include diff --git a/lib/icinga/cib.h b/lib/icinga/cib.h index f9353cda7..fc4bc5392 100644 --- a/lib/icinga/cib.h +++ b/lib/icinga/cib.h @@ -23,6 +23,12 @@ namespace icinga { +/** + * Common Information Base class. Holds some statistics (and will likely be + * removed/refactored). + * + * @ingroup icinga + */ class I2_ICINGA_API CIB { public: diff --git a/lib/icinga/host.h b/lib/icinga/host.h index 1c130befe..26d06bac0 100644 --- a/lib/icinga/host.h +++ b/lib/icinga/host.h @@ -23,6 +23,11 @@ namespace icinga { +/** + * An Icinga host. + * + * @ingroup icinga + */ class I2_ICINGA_API Host : public DynamicObject { public: diff --git a/lib/icinga/hostgroup.h b/lib/icinga/hostgroup.h index 29303da08..b0e854103 100644 --- a/lib/icinga/hostgroup.h +++ b/lib/icinga/hostgroup.h @@ -23,6 +23,11 @@ namespace icinga { +/** + * An Icinga host group. + * + * @ingroup icinga + */ class I2_ICINGA_API HostGroup : public DynamicObject { public: diff --git a/lib/icinga/i2-icinga.h b/lib/icinga/i2-icinga.h index 6e4ec6c81..d5f8e2766 100644 --- a/lib/icinga/i2-icinga.h +++ b/lib/icinga/i2-icinga.h @@ -21,10 +21,10 @@ #define I2ICINGA_H /** - * @defgroup icinga Icinga application + * @defgroup icinga Icinga library * - * The Icinga application is in charge of boot-strapping the Icinga - * environment and loading additional components. + * The Icinga library implements all Icinga-specific functionality that is + * common to all components (e.g. hosts, services, etc.). */ #include diff --git a/lib/icinga/macroprocessor.h b/lib/icinga/macroprocessor.h index 3f430f7ab..e015e9e82 100644 --- a/lib/icinga/macroprocessor.h +++ b/lib/icinga/macroprocessor.h @@ -23,6 +23,11 @@ namespace icinga { +/** + * Resolves macros. + * + * @ingroup icinga + */ class I2_ICINGA_API MacroProcessor { public: diff --git a/lib/icinga/nagioschecktask.h b/lib/icinga/nagioschecktask.h index ce6e575cf..c23cb1476 100644 --- a/lib/icinga/nagioschecktask.h +++ b/lib/icinga/nagioschecktask.h @@ -23,6 +23,11 @@ namespace icinga { +/** + * Implements Nagios(TM)-style checks. + * + * @ingroup icinga + */ class I2_ICINGA_API NagiosCheckTask { public: diff --git a/lib/icinga/nullchecktask.h b/lib/icinga/nullchecktask.h index d9a0a59ad..13b268180 100644 --- a/lib/icinga/nullchecktask.h +++ b/lib/icinga/nullchecktask.h @@ -23,6 +23,11 @@ namespace icinga { +/** + * Test class for additional check types. Implements the "null" check type. + * + * @ingroup icinga + */ class I2_ICINGA_API NullCheckTask { public: diff --git a/lib/icinga/service.h b/lib/icinga/service.h index 92c22ea18..8391cd6b6 100644 --- a/lib/icinga/service.h +++ b/lib/icinga/service.h @@ -23,6 +23,11 @@ namespace icinga { +/** + * The state of a service. + * + * @ingroup icinga + */ enum ServiceState { StateOK, @@ -32,6 +37,11 @@ enum ServiceState StateUncheckable, }; +/** + * The state type of a service. + * + * @ingroup icinga + */ enum ServiceStateType { StateTypeSoft, @@ -41,6 +51,11 @@ enum ServiceStateType class CheckResultMessage; class ServiceStatusMessage; +/** + * An Icinga service. + * + * @ingroup icinga + */ class I2_ICINGA_API Service : public DynamicObject { public: diff --git a/lib/icinga/servicegroup.h b/lib/icinga/servicegroup.h index 9552e29a2..48f2c4f6e 100644 --- a/lib/icinga/servicegroup.h +++ b/lib/icinga/servicegroup.h @@ -23,6 +23,11 @@ namespace icinga { +/** + * An Icinga service group. + * + * @ingroup icinga + */ class I2_ICINGA_API ServiceGroup : public DynamicObject { public: diff --git a/lib/icinga/servicestatechangemessage.h b/lib/icinga/servicestatechangemessage.h index 575855c2b..be8733db2 100644 --- a/lib/icinga/servicestatechangemessage.h +++ b/lib/icinga/servicestatechangemessage.h @@ -23,6 +23,11 @@ namespace icinga { +/** + * A state change message for a service. + * + * @ingroup icinga + */ class I2_ICINGA_API ServiceStateChangeMessage : public MessagePart { public: diff --git a/lib/remoting/endpoint.h b/lib/remoting/endpoint.h index b03778253..bfa6a9236 100644 --- a/lib/remoting/endpoint.h +++ b/lib/remoting/endpoint.h @@ -28,7 +28,7 @@ class EndpointManager; /** * An endpoint that can be used to send and receive messages. * - * @ingroup icinga + * @ingroup remoting */ class I2_REMOTING_API Endpoint : public DynamicObject { diff --git a/lib/remoting/endpointmanager.h b/lib/remoting/endpointmanager.h index 9796dd8e5..878cf368e 100644 --- a/lib/remoting/endpointmanager.h +++ b/lib/remoting/endpointmanager.h @@ -26,7 +26,7 @@ namespace icinga /** * Forwards messages between endpoints. * - * @ingroup icinga + * @ingroup remoting */ class I2_REMOTING_API EndpointManager : public Object { @@ -56,10 +56,6 @@ public: void ProcessResponseMessage(const Endpoint::Ptr& sender, const ResponseMessage& message); -// void ForEachEndpoint(function callback); -// Iterator Begin(void); -// Iterator End(void); - boost::signal OnNewEndpoint; private: @@ -78,7 +74,7 @@ private: /** * Information about a pending API request. * - * @ingroup icinga + * @ingroup remoting */ struct I2_REMOTING_API PendingRequest { diff --git a/lib/remoting/i2-remoting.h b/lib/remoting/i2-remoting.h index a54d94350..132a2314b 100644 --- a/lib/remoting/i2-remoting.h +++ b/lib/remoting/i2-remoting.h @@ -21,10 +21,10 @@ #define I2REMOTING_H /** - * @defgroup remoting JSON-RPC library + * @defgroup remoting Remoting library * - * The JSON-RPC library implements server and client classes for the JSON-RPC - * protocol. + * Implements server and client classes for the JSON-RPC protocol. Also + * supports endpoint-based communication using messages. */ #include diff --git a/lib/remoting/messagepart.cpp b/lib/remoting/messagepart.cpp index 7c04a951a..f5a5280da 100644 --- a/lib/remoting/messagepart.cpp +++ b/lib/remoting/messagepart.cpp @@ -63,7 +63,7 @@ Dictionary::Ptr MessagePart::GetDictionary(void) const * Retrieves a property's value. * * @param key The name of the property. - * @param[out] The value. + * @param[out] value The value. * @returns true if the value was retrieved, false otherwise. */ bool MessagePart::Get(String key, MessagePart *value) const diff --git a/lib/remoting/messagepart.h b/lib/remoting/messagepart.h index defff4357..f7a4f819d 100644 --- a/lib/remoting/messagepart.h +++ b/lib/remoting/messagepart.h @@ -45,7 +45,7 @@ public: * Retrieves a property's value. * * @param key The name of the property. - * @param[out] The value. + * @param[out] value The value. * @returns true if the value was retrieved, false otherwise. */ template From ff0af9d65ee65991e982ffefc12901ec717824df Mon Sep 17 00:00:00 2001 From: Gunnar Beutner Date: Mon, 17 Sep 2012 14:47:43 +0200 Subject: [PATCH 09/24] Fixed more doxygen warnings. --- docs/Doxyfile.in | 2 +- lib/base/application.h | 6 ++++++ lib/base/asynctask.h | 5 +++++ lib/base/dynamicobject.cpp | 10 ---------- lib/base/dynamicobject.h | 9 +++------ lib/base/logger.cpp | 11 +++++++++++ lib/base/logger.h | 14 ++++++++++---- lib/config/configcompiler.h | 6 ++++++ lib/config/configitem.h | 6 ++++++ lib/config/configitembuilder.h | 6 ++++++ lib/config/debuginfo.h | 5 +++++ lib/config/expression.h | 10 ++++++++++ lib/config/expressionlist.h | 5 +++++ lib/remoting/endpoint.cpp | 34 ++++++++++++++++++++++++++++++++++ 14 files changed, 108 insertions(+), 21 deletions(-) diff --git a/docs/Doxyfile.in b/docs/Doxyfile.in index 90be6a95b..2939d3bda 100644 --- a/docs/Doxyfile.in +++ b/docs/Doxyfile.in @@ -694,7 +694,7 @@ EXCLUDE_SYMLINKS = NO # against the file with absolute path, so to exclude all test directories # for example use the pattern */test/* -EXCLUDE_PATTERNS = +EXCLUDE_PATTERNS = */lib/config/config_parser* */lib/config/config_lexer* # The EXCLUDE_SYMBOLS tag can be used to specify one or more symbol names # (namespaces, classes, functions, etc.) that should be excluded from the diff --git a/lib/base/application.h b/lib/base/application.h index e91af95d8..6bcff1bb2 100644 --- a/lib/base/application.h +++ b/lib/base/application.h @@ -41,6 +41,12 @@ public: int Run(int argc, char **argv); + /** + * Starts the application. + * + * @param args Arguments for the application. + * @returns The exit code of the application. + */ virtual int Main(const vector& args) = 0; static void Shutdown(void); diff --git a/lib/base/asynctask.h b/lib/base/asynctask.h index b953b854f..66d438be3 100644 --- a/lib/base/asynctask.h +++ b/lib/base/asynctask.h @@ -118,6 +118,11 @@ public: } protected: + /** + * Begins executing the task. The Run method must ensure + * that one of the Finish*() functions is executed on the task + * object (possibly after the Run method has returned). + */ virtual void Run(void) = 0; private: diff --git a/lib/base/dynamicobject.cpp b/lib/base/dynamicobject.cpp index 60471c288..768ead8fd 100644 --- a/lib/base/dynamicobject.cpp +++ b/lib/base/dynamicobject.cpp @@ -214,16 +214,6 @@ void DynamicObject::ClearAttributesByType(DynamicAttributeType type) } } -DynamicObject::AttributeConstIterator DynamicObject::AttributeBegin(void) const -{ - return m_Attributes.begin(); -} - -DynamicObject::AttributeConstIterator DynamicObject::AttributeEnd(void) const -{ - return m_Attributes.end(); -} - String DynamicObject::GetType(void) const { return Get("__type"); diff --git a/lib/base/dynamicobject.h b/lib/base/dynamicobject.h index 42619e29b..e2e465263 100644 --- a/lib/base/dynamicobject.h +++ b/lib/base/dynamicobject.h @@ -51,9 +51,9 @@ enum DynamicAttributeType */ struct DynamicAttribute { - Value Data; - DynamicAttributeType Type; - double Tx; + Value Data; /**< The current value of the attribute. */ + DynamicAttributeType Type; /**< The type of the attribute. */ + double Tx; /**< The timestamp of the last value change. */ }; /** @@ -93,9 +93,6 @@ public: void ClearAttributesByType(DynamicAttributeType type); - AttributeConstIterator AttributeBegin(void) const; - AttributeConstIterator AttributeEnd(void) const; - static boost::signal OnRegistered; static boost::signal OnUnregistered; static boost::signal&)> OnTransactionClosing; diff --git a/lib/base/logger.cpp b/lib/base/logger.cpp index 9d9f003c7..3ed277df1 100644 --- a/lib/base/logger.cpp +++ b/lib/base/logger.cpp @@ -164,3 +164,14 @@ LogSeverity Logger::StringToSeverity(const String& severity) else throw_exception(invalid_argument("Invalid severity: " + severity)); } + +/** + * Retrieves the configuration object that belongs to this logger. + * + * @returns The configuration object. + */ +DynamicObject::Ptr ILogger::GetConfig(void) const +{ + return m_Config->GetSelf(); +} + diff --git a/lib/base/logger.h b/lib/base/logger.h index 1b642fb59..58eeae57f 100644 --- a/lib/base/logger.h +++ b/lib/base/logger.h @@ -42,10 +42,10 @@ enum LogSeverity * @ingroup base */ struct LogEntry { - double Timestamp; - LogSeverity Severity; - String Facility; - String Message; + double Timestamp; /**< The timestamp when this log entry was created. */ + LogSeverity Severity; /**< The severity of this log entry. */ + String Facility; /**< The facility this log entry belongs to. */ + String Message; /**< The log entry's message. */ }; /** @@ -59,6 +59,12 @@ public: typedef shared_ptr Ptr; typedef weak_ptr WeakPtr; + /** + * Processes the log entry and writes it to the log that is + * represented by this ILogger object. + * + * @param entry The log entry that is to be processed. + */ virtual void ProcessLogEntry(const LogEntry& entry) = 0; protected: diff --git a/lib/config/configcompiler.h b/lib/config/configcompiler.h index 782597a33..ef4c572a9 100644 --- a/lib/config/configcompiler.h +++ b/lib/config/configcompiler.h @@ -23,6 +23,12 @@ namespace icinga { +/** + * The configuration compiler can be used to compile a configuration file + * into a number of configuration objects. + * + * @ingroup config + */ class I2_CONFIG_API ConfigCompiler { public: diff --git a/lib/config/configitem.h b/lib/config/configitem.h index 699d379ee..0c1307dca 100644 --- a/lib/config/configitem.h +++ b/lib/config/configitem.h @@ -23,6 +23,12 @@ namespace icinga { +/** + * A configuration item. Can be used to create a configuration object at + * runtime. + * + * @ingroup config + */ class I2_CONFIG_API ConfigItem : public Object { public: typedef shared_ptr Ptr; diff --git a/lib/config/configitembuilder.h b/lib/config/configitembuilder.h index b1e46045c..9bd887b60 100644 --- a/lib/config/configitembuilder.h +++ b/lib/config/configitembuilder.h @@ -23,6 +23,12 @@ namespace icinga { +/** + * Config item builder. Used to dynamically build configuration objects + * at runtime. + * + * @ingroup config + */ class I2_CONFIG_API ConfigItemBuilder : public Object { public: diff --git a/lib/config/debuginfo.h b/lib/config/debuginfo.h index c6999a9bb..984c378aa 100644 --- a/lib/config/debuginfo.h +++ b/lib/config/debuginfo.h @@ -23,6 +23,11 @@ namespace icinga { +/** + * Debug information for a configuration element. + * + * @ingroup config + */ struct DebugInfo { String Path; diff --git a/lib/config/expression.h b/lib/config/expression.h index b239b7b53..533b0979f 100644 --- a/lib/config/expression.h +++ b/lib/config/expression.h @@ -23,6 +23,11 @@ namespace icinga { +/** + * The operator in a configuration expression. + * + * @ingroup config + */ enum ExpressionOperator { OperatorExecute, @@ -33,6 +38,11 @@ enum ExpressionOperator OperatorDivide }; +/** + * A configuration expression. + * + * @ingroup config + */ struct I2_CONFIG_API Expression { public: diff --git a/lib/config/expressionlist.h b/lib/config/expressionlist.h index 9869b60bf..a4f29fcf0 100644 --- a/lib/config/expressionlist.h +++ b/lib/config/expressionlist.h @@ -23,6 +23,11 @@ namespace icinga { +/** + * A list of configuration expressions. + * + * @ingroup config + */ class I2_CONFIG_API ExpressionList : public Object { public: diff --git a/lib/remoting/endpoint.cpp b/lib/remoting/endpoint.cpp index 0de95603d..c2dcb775d 100644 --- a/lib/remoting/endpoint.cpp +++ b/lib/remoting/endpoint.cpp @@ -28,6 +28,11 @@ boost::signal Endpoint::OnDisconnected; boost::signal Endpoint::OnSubscriptionRegistered; boost::signal Endpoint::OnSubscriptionUnregistered; +/** + * Constructor for the Endpoint class. + * + * @param properties A serialized dictionary containing attributes. + */ Endpoint::Endpoint(const Dictionary::Ptr& serializedUpdate) : DynamicObject(serializedUpdate) { @@ -38,11 +43,23 @@ Endpoint::Endpoint(const Dictionary::Ptr& serializedUpdate) RegisterAttribute("client", Attribute_Transient); } +/** + * Checks whether an endpoint with the specified name exists. + * + * @param name The name of the endpoint. + * @returns true if the endpoint exists, false otherwise. + */ bool Endpoint::Exists(const String& name) { return (DynamicObject::GetObject("Endpoint", name)); } +/** + * Retrieves an endpoint by name. + * + * @param name The name of the endpoint. + * @returns The endpoint. + */ Endpoint::Ptr Endpoint::GetByName(const String& name) { DynamicObject::Ptr configObject = DynamicObject::GetObject("Endpoint", name); @@ -53,6 +70,13 @@ Endpoint::Ptr Endpoint::GetByName(const String& name) return dynamic_pointer_cast(configObject); } +/** + * Helper function for creating new endpoint objects. + * + * @param name The name of the new endpoint. + * @param local Whether the new endpoint should be local. + * @returns The new endpoint. + */ Endpoint::Ptr Endpoint::MakeEndpoint(const String& name, bool local) { ConfigItemBuilder::Ptr endpointConfig = boost::make_shared(); @@ -334,11 +358,21 @@ void Endpoint::ClientClosedHandler(void) OnDisconnected(GetSelf()); } +/** + * Gets the node address for this endpoint. + * + * @returns The node address (hostname). + */ String Endpoint::GetNode(void) const { return Get("node"); } +/** + * Gets the service name for this endpoint. + * + * @returns The service name (port). + */ String Endpoint::GetService(void) const { return Get("service"); From 8bfb4ca005e138444304255ffb28956abbe07943 Mon Sep 17 00:00:00 2001 From: Gunnar Beutner Date: Mon, 17 Sep 2012 14:54:17 +0200 Subject: [PATCH 10/24] Updated README files to mention autogen.sh (hi lazyfrosch!) --- INSTALL | 9 +++++++++ README | 2 ++ 2 files changed, 11 insertions(+) diff --git a/INSTALL b/INSTALL index 68491c41a..e1bffa52f 100644 --- a/INSTALL +++ b/INSTALL @@ -58,6 +58,12 @@ The configure script supports all the usual parameters one comes to expect from autoconf. In particular you may want to use --prefix to specify an alternative installation prefix. +Note: The Git repository does not contain any auto-generated Autotools files, +i.e. there is no 'configure' script. In this case you will need to regenerate +the 'configure' script by running 'autogen.sh'. However, as an end-user you +should reconsider whether you really want to use the code from the Git +repository. In general it is advisable to use one of the dist tarballs instead. + Running Icinga 2 ---------------- @@ -73,3 +79,6 @@ Icinga 2 reads a single configuration file which is used to specify all configuration settings (global settings, hosts, services, etc.). The configuration format is explained in detail in the docs/icinga2-config.txt file. + +By default "make install" installs example configuration files to /etc/icinga2 +unless you have specified a different prefix or sysconfdir. diff --git a/README b/README index 5c51fcd89..b1c479725 100644 --- a/README +++ b/README @@ -7,5 +7,7 @@ information about how to install it. The documentation file docs/icinga2-intro.txt contains an in-depth overview of currently implemented and planned features for Icinga 2. +Read the INSTALL file for information on how to install Icinga 2. + Check the project website at http://www.icinga.org/ for status updates and https://www.icinga.org/support/ if you want to contact us. From b4e632141cc816f72d25c62b028fb51bd7db9726 Mon Sep 17 00:00:00 2001 From: Gunnar Beutner Date: Tue, 18 Sep 2012 12:38:08 +0200 Subject: [PATCH 11/24] Updated boost version (1.42 -> 1.41). --- INSTALL | 15 ++++++++------- configure.ac | 2 +- 2 files changed, 9 insertions(+), 8 deletions(-) diff --git a/INSTALL b/INSTALL index e1bffa52f..90017390f 100644 --- a/INSTALL +++ b/INSTALL @@ -12,15 +12,16 @@ Build Requirements ------------------ The following requirements need to be fulfilled in order to build the -application using a dist tarball (package names in parenthesis): +application using a dist tarball (package names for RHEL and Debian in +parenthesis): -* GNU make (make on RHEL and Debian) +* GNU make (make) * C++ compiler (gcc-c++ on RHEL, build-essential on Debian) * OpenSSL library and header files (openssl-devel on RHEL, libssl-dev on Debian) * Boost library and header files (boost-devel on RHEL, libboost-all-dev on Debian) -* optional: Doxygen (doxygen on RHEL and Debian) +* optional: Doxygen (doxygen) Packaging Requirements ---------------------- @@ -29,12 +30,12 @@ In order to build a dist tarball for the application the following external software components need to be installed in addition to the build requirements mentioned above: -* GNU Automake (automake on RHEL and Debian) -* GNU Autoconf (autoconf on RHEL and Debian) +* GNU Automake (automake) +* GNU Autoconf (autoconf) * GNU Libtool (libtool and libtool-ltdl-devel on RHEL, libtool and libltdl-dev on Debian) -* GNU bison (bison on RHEL and Debian) -* GNU flex (flex on RHEL and Debian) +* GNU bison (bison) +* GNU flex (flex) Debian Packages --------------- diff --git a/configure.ac b/configure.ac index 010e29c40..707c2fe90 100644 --- a/configure.ac +++ b/configure.ac @@ -51,7 +51,7 @@ AM_PROG_LEX AC_PROG_YACC AC_PROG_LIBTOOL AX_CXX_GCC_ABI_DEMANGLE -AX_BOOST_BASE([1.42], [], [AC_MSG_ERROR([You need the Boost headers and libraries in order to build this application])]) +AX_BOOST_BASE([1.41], [], [AC_MSG_ERROR([You need the Boost headers and libraries in order to build this application])]) AX_BOOST_SIGNALS AX_BOOST_THREAD AX_BOOST_SYSTEM From d9378482118fc61f27eec8f0a63905216c9db7db Mon Sep 17 00:00:00 2001 From: Gunnar Beutner Date: Tue, 18 Sep 2012 13:06:31 +0200 Subject: [PATCH 12/24] Updated paths in ax_boost_base.m4 to auto-detect boost on OpenIndiana. --- m4/ax_boost_base.m4 | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/m4/ax_boost_base.m4 b/m4/ax_boost_base.m4 index f72bc2c3d..3ae2fe045 100644 --- a/m4/ax_boost_base.m4 +++ b/m4/ax_boost_base.m4 @@ -108,7 +108,7 @@ if test "x$want_boost" = "xyes"; then fi done elif test "$cross_compiling" != yes; then - for ac_boost_path_tmp in /usr /usr/local /opt /opt/local "`pwd`/compat" ; do + for ac_boost_path_tmp in /usr /usr/local /opt /opt/local /usr/g++ "`pwd`/compat" ; do if test -d "$ac_boost_path_tmp/include/boost" && test -r "$ac_boost_path_tmp/include/boost"; then for libsubdir in $libsubdirs ; do if ls "$ac_boost_path_tmp/$libsubdir/libboost_"* >/dev/null 2>&1 ; then break; fi From d272f0d19de59040b834a728c39ba08670e482af Mon Sep 17 00:00:00 2001 From: Gunnar Beutner Date: Tue, 18 Sep 2012 13:19:27 +0200 Subject: [PATCH 13/24] Fix: missing files in the dist tarball --- icinga-app/config/Makefile.am | 2 ++ 1 file changed, 2 insertions(+) diff --git a/icinga-app/config/Makefile.am b/icinga-app/config/Makefile.am index 3e27bcfa2..cc397f481 100644 --- a/icinga-app/config/Makefile.am +++ b/icinga-app/config/Makefile.am @@ -6,3 +6,5 @@ icinga2conf_DATA = \ icinga-c1.pem \ icinga-c2.pem \ icinga-c3.pem + +EXTRA_DIST = $(icinga2conf_DATA) From 3cc165432923022b9d80236d26bfb38c514e27b2 Mon Sep 17 00:00:00 2001 From: Gunnar Beutner Date: Tue, 18 Sep 2012 15:37:49 +0200 Subject: [PATCH 14/24] Fixed detection of libboost_system on Solaris. --- m4/ax_boost_system.m4 | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/m4/ax_boost_system.m4 b/m4/ax_boost_system.m4 index 20df5eea4..af2a8d2d0 100644 --- a/m4/ax_boost_system.m4 +++ b/m4/ax_boost_system.m4 @@ -83,14 +83,14 @@ AC_DEFUN([AX_BOOST_SYSTEM], LDFLAGS_SAVE=$LDFLAGS if test "x$ax_boost_user_system_lib" = "x"; then - for libextension in `ls $BOOSTLIBDIR/libboost_system*.a* $BOOSTLIBDIR/libboost_system*.so* 2>/dev/null | sed 's,.*/,,' | sed -e 's;^lib\(boost_system.*\)\.\(so\|a\).*$;\1;' | tac` ; do + for libextension in `ls $BOOSTLIBDIR/libboost_system*.so* $BOOSTLIBDIR/libboost_system*.dylib* $BOOSTLIBDIR/libboost_system*.a* 2>/dev/null | sed 's,.*/,,' | sed -e 's;^lib\(boost_system.*\)\.so.*$;\1;' -e 's;^lib\(boost_system.*\)\.dylib.*$;\1;' -e 's;^lib\(boost_system.*\)\.a.*$;\1;'` ; do ax_lib=${libextension} AC_CHECK_LIB($ax_lib, exit, [BOOST_SYSTEM_LIB="-l$ax_lib"; AC_SUBST(BOOST_SYSTEM_LIB) link_system="yes"; break], [link_system="no"]) done if test "x$link_system" != "xyes"; then - for libextension in `ls $BOOSTLIBDIR/boost_system*.{dll,a}* 2>/dev/null | sed 's,.*/,,' | sed -e 's;^\(boost_system.*\)\.\(dll\|a\).*$;\1;' | tac` ; do + for libextension in `ls $BOOSTLIBDIR/boost_system*.dll* $BOOSTLIBDIR/boost_system*.a* 2>/dev/null | sed 's,.*/,,' | sed -e 's;^\(boost_system.*\)\.dll.*$;\1;' -e 's;^\(boost_system.*\)\.a*$;\1;'` ; do ax_lib=${libextension} AC_CHECK_LIB($ax_lib, exit, [BOOST_SYSTEM_LIB="-l$ax_lib"; AC_SUBST(BOOST_SYSTEM_LIB) link_system="yes"; break], From 8e2801e0625949a6ce3a14ce59a62fa0283e2908 Mon Sep 17 00:00:00 2001 From: Gunnar Beutner Date: Wed, 19 Sep 2012 12:32:39 +0200 Subject: [PATCH 15/24] Updated documentation. --- lib/base/asynctask.h | 3 ++ lib/base/component.h | 6 ++- lib/base/dictionary.cpp | 18 ++++++- lib/base/dictionary.h | 5 +- lib/base/dynamicobject.h | 9 ++++ lib/base/exception.h | 6 +++ lib/base/netstring.h | 4 +- lib/base/object.h | 41 ++++++++++++++-- lib/config/configcompiler.cpp | 81 ++++++++++++++++++++++++++++++-- lib/config/configcompiler.h | 8 ++-- lib/config/configitem.cpp | 65 ++++++++++++++++++++++++- lib/config/configitem.h | 22 +++++---- lib/config/configitembuilder.cpp | 6 ++- lib/config/configitembuilder.h | 18 +++---- lib/config/debuginfo.h | 7 +++ lib/config/expression.cpp | 11 +++-- lib/config/expression.h | 3 +- lib/config/expressionlist.cpp | 16 +++++++ lib/config/i2-config.h | 2 +- 19 files changed, 289 insertions(+), 42 deletions(-) diff --git a/lib/base/asynctask.h b/lib/base/asynctask.h index 66d438be3..e05c1c343 100644 --- a/lib/base/asynctask.h +++ b/lib/base/asynctask.h @@ -35,6 +35,9 @@ public: typedef shared_ptr > Ptr; typedef weak_ptr > WeakPtr; + /** + * A completion callback for an AsyncTask. + */ typedef function&)> CompletionCallback; /** diff --git a/lib/base/component.h b/lib/base/component.h index d87335f4b..f1c92bf22 100644 --- a/lib/base/component.h +++ b/lib/base/component.h @@ -41,7 +41,8 @@ protected: DynamicObject::Ptr GetConfig(void) const; private: - DynamicObject *m_Config; + DynamicObject *m_Config; /**< The configuration object for this + component. */ friend class Component; }; @@ -64,7 +65,8 @@ public: static void AddSearchDir(const String& componentDirectory); private: - IComponent::Ptr m_Impl; + IComponent::Ptr m_Impl; /**< The implementation object for this + component. */ }; typedef IComponent *(*CreateComponentFunction)(void); diff --git a/lib/base/dictionary.cpp b/lib/base/dictionary.cpp index 7bf487028..9306b3fbc 100644 --- a/lib/base/dictionary.cpp +++ b/lib/base/dictionary.cpp @@ -23,15 +23,31 @@ using namespace icinga; /** - * Compares the keys of dictionary keys using the less operator. + * Compares dictionary keys using the less operator. */ struct DictionaryKeyLessComparer { + /** + * Compares two keys. + * + * @param a The first key. + * @param b The second key. + * @returns true if the first key is less than the second key, false + * otherwise + */ bool operator()(const pair& a, const char *b) { return a.first < b; } + /** + * Compares two keys. + * + * @param a The first key. + * @param b The second key. + * @returns true if the first key is less than the second key, false + * otherwise + */ bool operator()(const char *a, const pair& b) { return a < b.first; diff --git a/lib/base/dictionary.h b/lib/base/dictionary.h index 43dbc61c9..fc5065eee 100644 --- a/lib/base/dictionary.h +++ b/lib/base/dictionary.h @@ -34,6 +34,9 @@ public: typedef shared_ptr Ptr; typedef weak_ptr WeakPtr; + /** + * An iterator that can be used to iterate over dictionary elements. + */ typedef map::iterator Iterator; Value Get(const char *key) const; @@ -56,7 +59,7 @@ public: cJSON *ToJson(void) const; private: - map m_Data; + map m_Data; /**< The data for the dictionary. */ }; inline Dictionary::Iterator range_begin(Dictionary::Ptr x) diff --git a/lib/base/dynamicobject.h b/lib/base/dynamicobject.h index e2e465263..364210529 100644 --- a/lib/base/dynamicobject.h +++ b/lib/base/dynamicobject.h @@ -25,6 +25,8 @@ namespace icinga /** * The type of an attribute for a DynamicObject. + * + * @ingroup base */ enum DynamicAttributeType { @@ -48,6 +50,8 @@ enum DynamicAttributeType /** * An attribute for a DynamicObject. + * + * @ingroup base */ struct DynamicAttribute { @@ -166,6 +170,11 @@ public: } }; +/** + * Factory function for DynamicObject-based classes. + * + * @ingroup base + */ template shared_ptr DynamicObjectFactory(const Dictionary::Ptr& serializedUpdate) { diff --git a/lib/base/exception.h b/lib/base/exception.h index 1e5bd19c5..b4ead45a8 100644 --- a/lib/base/exception.h +++ b/lib/base/exception.h @@ -86,6 +86,8 @@ DEFINE_EXCEPTION_CLASS(NotImplementedException); #ifdef _WIN32 /** * A Win32 error encapsulated in an exception. + * + * @ingroup base */ class Win32Exception : public Exception { @@ -112,6 +114,8 @@ public: /** * A Posix error encapsulated in an exception. + * + * @ingroup base */ class PosixException : public Exception { @@ -137,6 +141,8 @@ public: /** * An OpenSSL error encapsulated in an exception. + * + * @ingroup base */ class OpenSSLException : public Exception { diff --git a/lib/base/netstring.h b/lib/base/netstring.h index 3688ae33c..d32616e4c 100644 --- a/lib/base/netstring.h +++ b/lib/base/netstring.h @@ -24,9 +24,9 @@ namespace icinga { /** - * Helper functions for reading/writing messages in the netString format. + * Helper functions for reading/writing messages in the netstring format. * - * @see http://cr.yp.to/proto/netStrings.txt + * @see http://cr.yp.to/proto/netstrings.txt * * @ingroup base */ diff --git a/lib/base/object.h b/lib/base/object.h index c58a877cf..038819ac7 100644 --- a/lib/base/object.h +++ b/lib/base/object.h @@ -42,14 +42,28 @@ public: /** * Holds a shared pointer and provides support for implicit upcasts. + * + * @ingroup base */ class SharedPtrHolder { public: + /** + * Constructor for the SharedPtrHolder class. + * + * @param object The shared pointer that should be used to + * construct this shared pointer holder. + */ explicit SharedPtrHolder(const Object::Ptr& object) : m_Object(object) { } + /** + * Retrieves a shared pointer for the object that is associated + * this holder instance. + * + * @returns A shared pointer. + */ template operator shared_ptr(void) const { @@ -63,6 +77,12 @@ public: return other; } + /** + * Retrieves a weak pointer for the object that is associated + * with this holder instance. + * + * @returns A weak pointer. + */ template operator weak_ptr(void) const { @@ -70,7 +90,8 @@ public: } private: - Object::Ptr m_Object; + Object::Ptr m_Object; /**< The object that belongs to this + holder instance */ }; SharedPtrHolder GetSelf(void); @@ -88,23 +109,33 @@ private: Object(const Object& other); Object& operator=(const Object& rhs); - static boost::mutex m_Mutex; - static vector m_HeldObjects; + static boost::mutex m_Mutex; /**< Mutex which protects static members + of the Object class. */ + static vector m_HeldObjects; /**< Currently held + objects. */ #ifdef _DEBUG - static set m_AliveObjects; + static set m_AliveObjects; /**< Currently alive objects - + for debugging purposes. */ #endif /* _DEBUG */ }; /** * Compares a weak pointer with a raw pointer. + * + * @ingroup base */ template struct WeakPtrEqual { private: - const void *m_Ref; + const void *m_Ref; /**< The object. */ public: + /** + * Constructor for the WeakPtrEqual class. + * + * @param ref The object that should be compared with the weak pointer. + */ WeakPtrEqual(const void *ref) : m_Ref(ref) { } /** diff --git a/lib/config/configcompiler.cpp b/lib/config/configcompiler.cpp index bf80ce0be..386a92012 100644 --- a/lib/config/configcompiler.cpp +++ b/lib/config/configcompiler.cpp @@ -23,38 +23,78 @@ using std::ifstream; using namespace icinga; -ConfigCompiler::ConfigCompiler(const String& path, istream *input, HandleIncludeFunc includeHandler) +/** + * Constructor for the ConfigCompiler class. + * + * @param path The path of the configuration file (or another name that + * identifies the source of the configuration text). + * @param input Input stream for the configuration file. + * @param includeHandler Handler function for #include directives. + */ +ConfigCompiler::ConfigCompiler(const String& path, istream *input, + HandleIncludeFunc includeHandler) : m_Path(path), m_Input(input), m_HandleInclude(includeHandler) { InitializeScanner(); } +/** + * Destructor for the ConfigCompiler class. + */ ConfigCompiler::~ConfigCompiler(void) { DestroyScanner(); } +/** + * Reads data from the input stream. Used internally by the lexer. + * + * @param buffer Where to store data. + * @param max_size The maximum number of bytes to read from the stream. + * @returns The actual number of bytes read. + */ size_t ConfigCompiler::ReadInput(char *buffer, size_t max_size) { m_Input->read(buffer, max_size); return static_cast(m_Input->gcount()); } +/** + * Retrieves the scanner object. + * + * @returns The scanner object. + */ void *ConfigCompiler::GetScanner(void) const { return m_Scanner; } +/** + * Retrieves the result from the compiler. + * + * @returns A list of configuration items. + */ vector ConfigCompiler::GetResult(void) const { return m_Result; } +/** + * Retrieves the path for the input file. + * + * @returns The path. + */ String ConfigCompiler::GetPath(void) const { return m_Path; } +/** + * Handles an include directive by calling the include handler callback + * function. + * + * @param include The path from the include directive. + */ void ConfigCompiler::HandleInclude(const String& include) { String path = Utility::DirName(GetPath()) + "/" + include; @@ -62,13 +102,27 @@ void ConfigCompiler::HandleInclude(const String& include) std::copy(items.begin(), items.end(), back_inserter(m_Result)); } -vector ConfigCompiler::CompileStream(const String& path, istream *stream) +/** + * Compiles a stream. + * + * @param path A name identifying the stream. + * @param stream The input stream. + * @returns Configuration items. + */ +vector ConfigCompiler::CompileStream(const String& path, + istream *stream) { ConfigCompiler ctx(path, stream); ctx.Compile(); return ctx.GetResult(); } +/** + * Compiles a file. + * + * @param path The path. + * @returns Configuration items. + */ vector ConfigCompiler::CompileFile(const String& path) { ifstream stream; @@ -82,18 +136,39 @@ vector ConfigCompiler::CompileFile(const String& path) return CompileStream(path, &stream); } -vector ConfigCompiler::CompileText(const String& path, const String& text) +/** + * Compiles a snippet of text. + * + * @param path A name identifying the text. + * @param text The text. + * @returns Configuration items. + */ +vector ConfigCompiler::CompileText(const String& path, + const String& text) { stringstream stream(text); return CompileStream(path, &stream); } +/** + * Default include handler. Includes the file and returns a list of + * configuration items. + * + * @param include The path from the include directive. + * @returns A list of configuration objects. + */ vector ConfigCompiler::HandleFileInclude(const String& include) { /* TODO: implement wildcard includes */ return CompileFile(include); } +/** + * Adds an object to the result. + * + * @param object The configuration item. + */ + * void ConfigCompiler::AddObject(const ConfigItem::Ptr& object) { m_Result.push_back(object); diff --git a/lib/config/configcompiler.h b/lib/config/configcompiler.h index ef4c572a9..d214e446e 100644 --- a/lib/config/configcompiler.h +++ b/lib/config/configcompiler.h @@ -25,7 +25,7 @@ namespace icinga /** * The configuration compiler can be used to compile a configuration file - * into a number of configuration objects. + * into a number of configuration items. * * @ingroup config */ @@ -40,9 +40,11 @@ public: void Compile(void); - static vector CompileStream(const String& path, istream *stream); + static vector CompileStream(const String& path, + istream *stream); static vector CompileFile(const String& path); - static vector CompileText(const String& path, const String& text); + static vector CompileText(const String& path, + const String& text); static vector HandleFileInclude(const String& include); diff --git a/lib/config/configitem.cpp b/lib/config/configitem.cpp index ff57bf966..927ef341d 100644 --- a/lib/config/configitem.cpp +++ b/lib/config/configitem.cpp @@ -25,6 +25,15 @@ ConfigItem::ItemMap ConfigItem::m_Items; boost::signal ConfigItem::OnCommitted; boost::signal ConfigItem::OnRemoved; +/** + * Constructor for the ConfigItem class. + * + * @param type The object type. + * @param name The name of the item. + * @param exprl Expression list for the item. + * @param parents Parent objects for the item. + * @param debuginfo Debug information. + */ ConfigItem::ConfigItem(const String& type, const String& name, const ExpressionList::Ptr& exprl, const vector& parents, const DebugInfo& debuginfo) @@ -33,31 +42,63 @@ ConfigItem::ConfigItem(const String& type, const String& name, { } +/** + * Retrieves the type of the configuration item. + * + * @returns The type. + */ String ConfigItem::GetType(void) const { return m_Type; } +/** + * Retrieves the name of the configuration item. + * + * @returns The name. + */ String ConfigItem::GetName(void) const { return m_Name; } +/** + * Retrieves the debug information for the configuration item. + * + * @returns The debug information. + */ DebugInfo ConfigItem::GetDebugInfo(void) const { return m_DebugInfo; } +/** + * Retrieves the expression list for the configuration item. + * + * @returns The expression list. + */ ExpressionList::Ptr ConfigItem::GetExpressionList(void) const { return m_ExpressionList; } +/** + * Retrieves the list of parents for the configuration item. + * + * @returns The list of parents. + */ vector ConfigItem::GetParents(void) const { return m_Parents; } +/** + * Calculates the object's properties based on parent objects and the object's + * expression list. + * + * @param dictionary The dictionary that should be used to store the + * properties. + */ void ConfigItem::CalculateProperties(const Dictionary::Ptr& dictionary) const { BOOST_FOREACH(const String& name, m_Parents) { @@ -65,7 +106,8 @@ void ConfigItem::CalculateProperties(const Dictionary::Ptr& dictionary) const if (!parent) { stringstream message; - message << "Parent object '" << name << "' does not exist (" << m_DebugInfo << ")"; + message << "Parent object '" << name << "' does not" + " exist (" << m_DebugInfo << ")"; throw_exception(domain_error(message.str())); } @@ -75,6 +117,12 @@ void ConfigItem::CalculateProperties(const Dictionary::Ptr& dictionary) const m_ExpressionList->Execute(dictionary); } +/** + * Commits the configuration item by creating or updating a DynamicObject + * object. + * + * @returns The DynamicObject that was created/updated. + */ DynamicObject::Ptr ConfigItem::Commit(void) { DynamicObject::Ptr dobj = m_DynamicObject.lock(); @@ -125,6 +173,9 @@ DynamicObject::Ptr ConfigItem::Commit(void) return dobj; } +/** + * Unregisters the configuration item. + */ void ConfigItem::Unregister(void) { DynamicObject::Ptr dobj = m_DynamicObject.lock(); @@ -141,11 +192,23 @@ void ConfigItem::Unregister(void) OnRemoved(GetSelf()); } +/** + * Retrieves the DynamicObject that belongs to the configuration item. + * + * @returns The DynamicObject. + */ DynamicObject::Ptr ConfigItem::GetDynamicObject(void) const { return m_DynamicObject.lock(); } +/** + * Retrieves a configuration item by type and name. + * + * @param type The type of the ConfigItem that is to be looked up. + * @param name The name of the ConfigItem that is to be looked up. + * @returns The configuration item. + */ ConfigItem::Ptr ConfigItem::GetObject(const String& type, const String& name) { ConfigItem::ItemMap::iterator it; diff --git a/lib/config/configitem.h b/lib/config/configitem.h index 0c1307dca..8bce29493 100644 --- a/lib/config/configitem.h +++ b/lib/config/configitem.h @@ -24,8 +24,8 @@ namespace icinga { /** - * A configuration item. Can be used to create a configuration object at - * runtime. + * A configuration item. Non-abstract configuration items can be used to + * create configuration objects at runtime. * * @ingroup config */ @@ -52,7 +52,8 @@ public: DebugInfo GetDebugInfo(void) const; - static ConfigItem::Ptr GetObject(const String& type, const String& name); + static ConfigItem::Ptr GetObject(const String& type, + const String& name); static boost::signal OnCommitted; static boost::signal OnRemoved; @@ -60,17 +61,20 @@ public: private: void CalculateProperties(const Dictionary::Ptr& dictionary) const; - String m_Type; - String m_Name; + String m_Type; /**< The object type. */ + String m_Name; /**< The name. */ ExpressionList::Ptr m_ExpressionList; - vector m_Parents; - DebugInfo m_DebugInfo; + vector m_Parents; /**< The names of parent configuration + items. */ + DebugInfo m_DebugInfo; /**< Debug information. */ - DynamicObject::WeakPtr m_DynamicObject; + DynamicObject::WeakPtr m_DynamicObject; /**< The instantiated version + of this configuration + item */ typedef map, ConfigItem::Ptr> ItemMap; - static ItemMap m_Items; + static ItemMap m_Items; /**< All registered configuration items. */ }; } diff --git a/lib/config/configitembuilder.cpp b/lib/config/configitembuilder.cpp index 36e3671b0..70963bcec 100644 --- a/lib/config/configitembuilder.cpp +++ b/lib/config/configitembuilder.cpp @@ -68,7 +68,8 @@ void ConfigItemBuilder::AddExpression(const Expression& expr) m_ExpressionList->AddExpression(expr); } -void ConfigItemBuilder::AddExpression(const String& key, ExpressionOperator op, const Value& value) +void ConfigItemBuilder::AddExpression(const String& key, ExpressionOperator op, + const Value& value) { Expression expr(key, op, value, m_DebugInfo); AddExpression(expr); @@ -101,5 +102,6 @@ ConfigItem::Ptr ConfigItemBuilder::Compile(void) Expression abstractExpr("__abstract", OperatorSet, m_Abstract, m_DebugInfo); exprl->AddExpression(abstractExpr); - return boost::make_shared(m_Type, m_Name, exprl, m_Parents, m_DebugInfo); + return boost::make_shared(m_Type, m_Name, exprl, m_Parents, + m_DebugInfo); } diff --git a/lib/config/configitembuilder.h b/lib/config/configitembuilder.h index 9bd887b60..a857c3f11 100644 --- a/lib/config/configitembuilder.h +++ b/lib/config/configitembuilder.h @@ -46,19 +46,21 @@ public: void AddParent(const String& parent); void AddExpression(const Expression& expr); - void AddExpression(const String& key, ExpressionOperator op, const Value& value); + void AddExpression(const String& key, ExpressionOperator op, + const Value& value); void AddExpressionList(const ExpressionList::Ptr& exprl); ConfigItem::Ptr Compile(void); private: - String m_Type; - String m_Name; - bool m_Local; - bool m_Abstract; - vector m_Parents; - ExpressionList::Ptr m_ExpressionList; - DebugInfo m_DebugInfo; + String m_Type; /**< The object type. */ + String m_Name; /**< The name. */ + bool m_Local; /**< Whether the item is local. */ + bool m_Abstract; /**< Whether the item is abstract. */ + vector m_Parents; /**< The names of parent configuration + items. */ + ExpressionList::Ptr m_ExpressionList; /**< Expressions for this item. */ + DebugInfo m_DebugInfo; /**< Debug information. */ }; } diff --git a/lib/config/debuginfo.h b/lib/config/debuginfo.h index 984c378aa..7918f70ad 100644 --- a/lib/config/debuginfo.h +++ b/lib/config/debuginfo.h @@ -57,6 +57,13 @@ struct DebugInfo }; }; +/** + * Outputs a DebugInfo struct to a stream. + * + * @param out The output stream. + * @param val The DebugInfo struct. + * @returns The output stream. + */ inline ostream& operator<<(ostream& out, const DebugInfo& val) { out << "in " << val.Path << ": " diff --git a/lib/config/expression.cpp b/lib/config/expression.cpp index 66b37e2ab..fe88d2536 100644 --- a/lib/config/expression.cpp +++ b/lib/config/expression.cpp @@ -21,7 +21,8 @@ using namespace icinga; -Expression::Expression(const String& key, ExpressionOperator op, const Value& value, const DebugInfo& debuginfo) +Expression::Expression(const String& key, ExpressionOperator op, + const Value& value, const DebugInfo& debuginfo) : m_Key(key), m_Operator(op), m_Value(value), m_DebugInfo(debuginfo) { } @@ -69,7 +70,10 @@ void Expression::Execute(const Dictionary::Ptr& dictionary) const if (!dict) { if (!oldValue.IsEmpty()) { stringstream message; - message << "Wrong argument types for += (non-dictionary and dictionary) (" << m_DebugInfo << ")"; + message << "Wrong argument types for" + " += (non-dictionary and" + " dictionary) (" + << m_DebugInfo << ")"; throw_exception(domain_error(message.str())); } @@ -88,7 +92,8 @@ void Expression::Execute(const Dictionary::Ptr& dictionary) const } } else { stringstream message; - message << "+= only works for dictionaries (" << m_DebugInfo << ")"; + message << "+= only works for dictionaries (" + << m_DebugInfo << ")"; throw_exception(domain_error(message.str())); } diff --git a/lib/config/expression.h b/lib/config/expression.h index 533b0979f..378f1c94b 100644 --- a/lib/config/expression.h +++ b/lib/config/expression.h @@ -46,7 +46,8 @@ enum ExpressionOperator struct I2_CONFIG_API Expression { public: - Expression(const String& key, ExpressionOperator op, const Value& value, const DebugInfo& debuginfo); + Expression(const String& key, ExpressionOperator op, const Value& value, + const DebugInfo& debuginfo); void Execute(const Dictionary::Ptr& dictionary) const; diff --git a/lib/config/expressionlist.cpp b/lib/config/expressionlist.cpp index a22be1d61..54782f130 100644 --- a/lib/config/expressionlist.cpp +++ b/lib/config/expressionlist.cpp @@ -21,16 +21,32 @@ using namespace icinga; +/** + * Adds an expression to an expression list. + * + * @param expression The expression that should be added. + */ void ExpressionList::AddExpression(const Expression& expression) { m_Expressions.push_back(expression); } +/** + * Returns the number of items currently contained in the expression list. + * + * @returns The length of the list. + */ size_t ExpressionList::GetLength(void) const { return m_Expressions.size(); } +/** + * Executes the expression list. + * + * @param dictionary The dictionary that should be manipulated by the + * expressions. + */ void ExpressionList::Execute(const Dictionary::Ptr& dictionary) const { BOOST_FOREACH(const Expression& expression, m_Expressions) { diff --git a/lib/config/i2-config.h b/lib/config/i2-config.h index 868b7e66e..c378e182d 100644 --- a/lib/config/i2-config.h +++ b/lib/config/i2-config.h @@ -24,7 +24,7 @@ * @defgroup config Configuration library * * The configuration library implements a compiler for Icinga 2's configuration - * format. It also provides functionality to create configuration objects + * format. It also provides functionality for creating configuration objects * at runtime. */ From d98ceb7b7917e269eb6dd61457f3b20f52963395 Mon Sep 17 00:00:00 2001 From: Gunnar Beutner Date: Wed, 19 Sep 2012 12:55:07 +0200 Subject: [PATCH 16/24] Renamed default PID/state filenames. --- lib/icinga/icingaapplication.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/icinga/icingaapplication.cpp b/lib/icinga/icingaapplication.cpp index f875657fa..a2764db65 100644 --- a/lib/icinga/icingaapplication.cpp +++ b/lib/icinga/icingaapplication.cpp @@ -28,8 +28,8 @@ using namespace icinga; -const String IcingaApplication::DefaultPidPath = "icinga.pid"; -const String IcingaApplication::DefaultStatePath = "icinga.state"; +const String IcingaApplication::DefaultPidPath = "icinga2.pid"; +const String IcingaApplication::DefaultStatePath = "icinga2.state"; IcingaApplication::IcingaApplication(const Dictionary::Ptr& serializedUpdate) : Application(serializedUpdate) From 852ad5d964021b0d646880ad3201f1ce17cd65b5 Mon Sep 17 00:00:00 2001 From: Gunnar Beutner Date: Wed, 19 Sep 2012 13:00:48 +0200 Subject: [PATCH 17/24] Added Utility::GetPid() helper function. --- lib/base/application.cpp | 8 +------- lib/base/utility.cpp | 14 ++++++++++++++ lib/base/utility.h | 2 ++ lib/base/win32.h | 1 + 4 files changed, 18 insertions(+), 7 deletions(-) diff --git a/lib/base/application.cpp b/lib/base/application.cpp index 66a337b17..fc36f4605 100644 --- a/lib/base/application.cpp +++ b/lib/base/application.cpp @@ -347,13 +347,7 @@ void Application::UpdatePidFile(const String& filename) } #endif /* _WIN32 */ -#ifndef _WIN32 - pid_t pid = getpid(); -#else /* _WIN32 */ - DWORD pid = GetCurrentProcessId(); -#endif /* _WIN32 */ - - fprintf(m_PidFile, "%d", pid); + fprintf(m_PidFile, "%d", Utility::GetPid()); fflush(m_PidFile); } diff --git a/lib/base/utility.cpp b/lib/base/utility.cpp index b64e6b145..a34512e4d 100644 --- a/lib/base/utility.cpp +++ b/lib/base/utility.cpp @@ -289,3 +289,17 @@ double Utility::GetTime(void) return tv.tv_sec + tv.tv_usec / 1000000.0; #endif /* _WIN32 */ } + +/** + * Returns the ID of the current process. + * + * @returns The PID. + */ +pid_t Utility::GetPid(void) +{ +#ifndef _WIN32 + return getpid(); +#else /* _WIN32 */ + return GetCurrentProcessId(); +#endif /* _WIN32 */ +} diff --git a/lib/base/utility.h b/lib/base/utility.h index 7ff9a2ab2..96c914a37 100644 --- a/lib/base/utility.h +++ b/lib/base/utility.h @@ -48,6 +48,8 @@ public: static double GetTime(void); + static pid_t GetPid(void); + private: static bool m_SSLInitialized; diff --git a/lib/base/win32.h b/lib/base/win32.h index fea3d795d..a6fc28d9c 100644 --- a/lib/base/win32.h +++ b/lib/base/win32.h @@ -35,6 +35,7 @@ #endif /* __MINGW32__ */ typedef int socklen_t; +typedef DWORD pid_t; #define MAXPATHLEN MAX_PATH From c9d672886923f4b10a0efe12e5b8eb3c10a21748 Mon Sep 17 00:00:00 2001 From: Gunnar Beutner Date: Wed, 19 Sep 2012 13:03:17 +0200 Subject: [PATCH 18/24] Build fix. --- lib/config/configcompiler.cpp | 1 - 1 file changed, 1 deletion(-) diff --git a/lib/config/configcompiler.cpp b/lib/config/configcompiler.cpp index 386a92012..3e6be26f9 100644 --- a/lib/config/configcompiler.cpp +++ b/lib/config/configcompiler.cpp @@ -168,7 +168,6 @@ vector ConfigCompiler::HandleFileInclude(const String& include) * * @param object The configuration item. */ - * void ConfigCompiler::AddObject(const ConfigItem::Ptr& object) { m_Result.push_back(object); From fa7879776c032e4c7f12fbe50c58eca9823ea905 Mon Sep 17 00:00:00 2001 From: Gunnar Beutner Date: Wed, 19 Sep 2012 14:10:34 +0200 Subject: [PATCH 19/24] Report PID in the status.dat file. --- components/compat/compatcomponent.cpp | 1 + 1 file changed, 1 insertion(+) diff --git a/components/compat/compatcomponent.cpp b/components/compat/compatcomponent.cpp index 70d5c0fc6..22a9b6b49 100644 --- a/components/compat/compatcomponent.cpp +++ b/components/compat/compatcomponent.cpp @@ -187,6 +187,7 @@ void CompatComponent::StatusTimerHandler(void) << "\n"; statusfp << "programstatus {" << "\n" + << "icinga_pid=" << Utility::GetPid() << "\n" << "\t" << "daemon_mode=1" << "\n" << "\t" << "program_start=" << IcingaApplication::GetInstance()->GetStartTime() << "\n" << "\t" << "active_service_checks_enabled=1" << "\n" From 258210912df4d37ad85f27e011d59c3fc3db2fe8 Mon Sep 17 00:00:00 2001 From: Gunnar Beutner Date: Thu, 20 Sep 2012 10:36:58 +0200 Subject: [PATCH 20/24] Added note about git-buildpackage. --- INSTALL | 3 +++ 1 file changed, 3 insertions(+) diff --git a/INSTALL b/INSTALL index 90017390f..3acef743f 100644 --- a/INSTALL +++ b/INSTALL @@ -45,6 +45,9 @@ fully comply with the official Debian packaging requirements. These scripts can be found in the 'debian' sub-directory. Binary packages can be built using 'dpkg-buildpackage'. +If you're using 'git-buildpackage' make sure to specify the autogen.sh script +as a prebuild requirement (git-buildpackage --git-prebuild=./autogen.sh). + Building Icinga 2 ----------------- From ac6c9ab7c2c45193309d511554c12080ad4017fe Mon Sep 17 00:00:00 2001 From: Gunnar Beutner Date: Thu, 20 Sep 2012 10:39:55 +0200 Subject: [PATCH 21/24] Removed git-buildpackage note. Added gbp.conf file. --- INSTALL | 3 --- debian/gbp.conf | 2 ++ 2 files changed, 2 insertions(+), 3 deletions(-) create mode 100644 debian/gbp.conf diff --git a/INSTALL b/INSTALL index 3acef743f..90017390f 100644 --- a/INSTALL +++ b/INSTALL @@ -45,9 +45,6 @@ fully comply with the official Debian packaging requirements. These scripts can be found in the 'debian' sub-directory. Binary packages can be built using 'dpkg-buildpackage'. -If you're using 'git-buildpackage' make sure to specify the autogen.sh script -as a prebuild requirement (git-buildpackage --git-prebuild=./autogen.sh). - Building Icinga 2 ----------------- diff --git a/debian/gbp.conf b/debian/gbp.conf new file mode 100644 index 000000000..af6f0fd44 --- /dev/null +++ b/debian/gbp.conf @@ -0,0 +1,2 @@ +[git-buildpackage] +prebuild = ./autogen.sh From 88f844630547229e8538f1c7a84ca63825b5787f Mon Sep 17 00:00:00 2001 From: Gunnar Beutner Date: Thu, 20 Sep 2012 11:10:00 +0200 Subject: [PATCH 22/24] Updated .gitignore file. --- .gitignore | 1 + 1 file changed, 1 insertion(+) diff --git a/.gitignore b/.gitignore index 679b5320c..eef862815 100644 --- a/.gitignore +++ b/.gitignore @@ -37,3 +37,4 @@ stamp-h1 .libs icinga-app/icinga docs/dev +m4/ylwrap From 6a15e69e88027e591ad287aa0848748f34d9e7a9 Mon Sep 17 00:00:00 2001 From: Gunnar Beutner Date: Thu, 20 Sep 2012 11:10:11 +0200 Subject: [PATCH 23/24] Updated git-buildpackage options to not run ./configure twice. --- debian/gbp.conf | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/debian/gbp.conf b/debian/gbp.conf index af6f0fd44..a2c0dbe5c 100644 --- a/debian/gbp.conf +++ b/debian/gbp.conf @@ -1,2 +1,2 @@ [git-buildpackage] -prebuild = ./autogen.sh +prebuild = NOCONFIGURE=1 ./autogen.sh From 97829fbfcd479ce779c91d678fe5ada5d2e014c0 Mon Sep 17 00:00:00 2001 From: Gunnar Beutner Date: Fri, 21 Sep 2012 09:43:06 +0200 Subject: [PATCH 24/24] Cleaned up the code a bit. --- components/checker/checkercomponent.cpp | 5 +-- components/checker/checkercomponent.h | 8 ++--- .../convenience/conveniencecomponent.cpp | 9 ++--- components/convenience/conveniencecomponent.h | 5 ++- components/demo/democomponent.cpp | 16 ++++++--- lib/base/dynamicobject.cpp | 18 ++++++---- lib/base/utility.cpp | 18 ++++++---- lib/remoting/endpointmanager.cpp | 34 +++---------------- lib/remoting/endpointmanager.h | 4 ++- lib/remoting/jsonrpcclient.cpp | 19 +++++++---- 10 files changed, 70 insertions(+), 66 deletions(-) diff --git a/components/checker/checkercomponent.cpp b/components/checker/checkercomponent.cpp index 0fb475bf1..2411b45d0 100644 --- a/components/checker/checkercomponent.cpp +++ b/components/checker/checkercomponent.cpp @@ -30,7 +30,7 @@ void CheckerComponent::Start(void) m_Endpoint->RegisterSubscription("checker"); Service::OnCheckerChanged.connect(bind(&CheckerComponent::CheckerChangedHandler, this, _1)); - DynamicObject::OnUnregistered.connect(bind(&CheckerComponent::ServiceRemovedHandler, this, _1)); + DynamicObject::OnUnregistered.connect(bind(&CheckerComponent::ObjectRemovedHandler, this, _1)); m_CheckTimer = boost::make_shared(); m_CheckTimer->SetInterval(1); @@ -184,7 +184,7 @@ void CheckerComponent::CheckerChangedHandler(const Service::Ptr& service) } } -void CheckerComponent::ServiceRemovedHandler(const DynamicObject::Ptr& object) +void CheckerComponent::ObjectRemovedHandler(const DynamicObject::Ptr& object) { Service::Ptr service = dynamic_pointer_cast(object); @@ -197,3 +197,4 @@ void CheckerComponent::ServiceRemovedHandler(const DynamicObject::Ptr& object) } EXPORT_COMPONENT(checker, CheckerComponent); + diff --git a/components/checker/checkercomponent.h b/components/checker/checkercomponent.h index b54d5d97f..98a4ea92b 100644 --- a/components/checker/checkercomponent.h +++ b/components/checker/checkercomponent.h @@ -23,6 +23,9 @@ namespace icinga { +/** + * @ingroup checker + */ struct ServiceNextCheckExtractor { typedef double result_type; @@ -71,10 +74,7 @@ private: void AdjustCheckTimer(void); void CheckerChangedHandler(const Service::Ptr& service); - void ServiceRemovedHandler(const DynamicObject::Ptr& object); - - //void AssignServiceRequestHandler(const Endpoint::Ptr& sender, const RequestMessage& request); - //void ClearServicesRequestHandler(const Endpoint::Ptr& sender, const RequestMessage& request); + void ObjectRemovedHandler(const DynamicObject::Ptr& object); }; } diff --git a/components/convenience/conveniencecomponent.cpp b/components/convenience/conveniencecomponent.cpp index f8bf2aaa6..e4caea210 100644 --- a/components/convenience/conveniencecomponent.cpp +++ b/components/convenience/conveniencecomponent.cpp @@ -26,8 +26,8 @@ using namespace icinga; */ void ConvenienceComponent::Start(void) { - ConfigItem::OnCommitted.connect(boost::bind(&ConvenienceComponent::HostCommittedHandler, this, _1)); - ConfigItem::OnRemoved.connect(boost::bind(&ConvenienceComponent::HostRemovedHandler, this, _1)); + ConfigItem::OnCommitted.connect(boost::bind(&ConvenienceComponent::ObjectCommittedHandler, this, _1)); + ConfigItem::OnRemoved.connect(boost::bind(&ConvenienceComponent::ObjectRemovedHandler, this, _1)); } template @@ -68,7 +68,7 @@ static void CopyServiceAttributes(const Host::Ptr& host, TDict serviceDesc, Service::ResolveDependencies(host, hostchecks)); } -void ConvenienceComponent::HostCommittedHandler(const ConfigItem::Ptr& item) +void ConvenienceComponent::ObjectCommittedHandler(const ConfigItem::Ptr& item) { if (item->GetType() != "Host") return; @@ -139,7 +139,7 @@ void ConvenienceComponent::HostCommittedHandler(const ConfigItem::Ptr& item) host->Set("convenience_services", newServices); } -void ConvenienceComponent::HostRemovedHandler(const ConfigItem::Ptr& item) +void ConvenienceComponent::ObjectRemovedHandler(const ConfigItem::Ptr& item) { if (item->GetType() != "Host") return; @@ -161,3 +161,4 @@ void ConvenienceComponent::HostRemovedHandler(const ConfigItem::Ptr& item) } EXPORT_COMPONENT(convenience, ConvenienceComponent); + diff --git a/components/convenience/conveniencecomponent.h b/components/convenience/conveniencecomponent.h index 2a5807df8..e1d7db788 100644 --- a/components/convenience/conveniencecomponent.h +++ b/components/convenience/conveniencecomponent.h @@ -32,9 +32,8 @@ public: virtual void Start(void); private: - void HostAddedHandler(const ConfigItem::Ptr& item); - void HostCommittedHandler(const ConfigItem::Ptr& item); - void HostRemovedHandler(const ConfigItem::Ptr& item); + void ObjectCommittedHandler(const ConfigItem::Ptr& item); + void ObjectRemovedHandler(const ConfigItem::Ptr& item); }; } diff --git a/components/demo/democomponent.cpp b/components/demo/democomponent.cpp index 2474ed9b1..ebc8dd841 100644 --- a/components/demo/democomponent.cpp +++ b/components/demo/democomponent.cpp @@ -28,7 +28,8 @@ void DemoComponent::Start(void) { m_Endpoint = Endpoint::MakeEndpoint("demo", true); m_Endpoint->RegisterTopicHandler("demo::HelloWorld", - boost::bind(&DemoComponent::HelloWorldRequestHandler, this, _2, _3)); + boost::bind(&DemoComponent::HelloWorldRequestHandler, this, _2, + _3)); m_DemoTimer = boost::make_shared(); m_DemoTimer->SetInterval(5); @@ -51,20 +52,25 @@ void DemoComponent::Stop(void) */ void DemoComponent::DemoTimerHandler(void) { - Logger::Write(LogInformation, "demo", "Sending multicast 'hello world' message."); + Logger::Write(LogInformation, "demo", "Sending multicast 'hello" + " world' message."); RequestMessage request; request.SetMethod("demo::HelloWorld"); - EndpointManager::GetInstance()->SendMulticastMessage(m_Endpoint, request); + EndpointManager::GetInstance()->SendMulticastMessage(m_Endpoint, + request); } /** * Processes demo::HelloWorld messages. */ -void DemoComponent::HelloWorldRequestHandler(const Endpoint::Ptr& sender, const RequestMessage& request) +void DemoComponent::HelloWorldRequestHandler(const Endpoint::Ptr& sender, + const RequestMessage& request) { - Logger::Write(LogInformation, "demo", "Got 'hello world' from address=" + sender->GetAddress() + ", identity=" + sender->GetName()); + Logger::Write(LogInformation, "demo", "Got 'hello world' from" + " address=" + sender->GetAddress() + ", identity=" + + sender->GetName()); } EXPORT_COMPONENT(demo, DemoComponent); diff --git a/lib/base/dynamicobject.cpp b/lib/base/dynamicobject.cpp index 768ead8fd..2911a8e3c 100644 --- a/lib/base/dynamicobject.cpp +++ b/lib/base/dynamicobject.cpp @@ -85,15 +85,18 @@ Dictionary::Ptr DynamicObject::BuildUpdate(double sinceTx, int attributeTypes) c return update; } -void DynamicObject::ApplyUpdate(const Dictionary::Ptr& serializedUpdate, int allowedTypes) +void DynamicObject::ApplyUpdate(const Dictionary::Ptr& serializedUpdate, + int allowedTypes) { InternalApplyUpdate(serializedUpdate, allowedTypes, false); } -void DynamicObject::InternalApplyUpdate(const Dictionary::Ptr& serializedUpdate, int allowedTypes, bool suppressEvents) +void DynamicObject::InternalApplyUpdate(const Dictionary::Ptr& serializedUpdate, + int allowedTypes, bool suppressEvents) { double configTx = 0; - if ((allowedTypes & Attribute_Config) != 0 && serializedUpdate->Contains("configTx")) { + if ((allowedTypes & Attribute_Config) != 0 && + serializedUpdate->Contains("configTx")) { configTx = serializedUpdate->Get("configTx"); if (configTx > m_ConfigTx) @@ -127,7 +130,8 @@ void DynamicObject::InternalApplyUpdate(const Dictionary::Ptr& serializedUpdate, } } -void DynamicObject::RegisterAttribute(const String& name, DynamicAttributeType type) +void DynamicObject::RegisterAttribute(const String& name, + DynamicAttributeType type) { DynamicAttribute attr; attr.Type = type; @@ -155,7 +159,8 @@ Value DynamicObject::Get(const String& name) const return InternalGetAttribute(name); } -void DynamicObject::InternalSetAttribute(const String& name, const Value& data, double tx, bool suppressEvent) +void DynamicObject::InternalSetAttribute(const String& name, const Value& data, + double tx, bool suppressEvent) { DynamicAttribute attr; attr.Type = Attribute_Transient; @@ -412,7 +417,8 @@ void DynamicObject::RestoreObjects(const String& filename) std::ifstream fp; fp.open(filename.CStr()); - /* TODO: Fix this horrible mess. */ + /* TODO: Fix this horrible mess by implementing a class that provides + * IOQueue functionality for files. */ FIFO::Ptr fifo = boost::make_shared(); while (fp) { char buffer[1024]; diff --git a/lib/base/utility.cpp b/lib/base/utility.cpp index a34512e4d..b6c89282d 100644 --- a/lib/base/utility.cpp +++ b/lib/base/utility.cpp @@ -145,10 +145,12 @@ String Utility::GetCertificateCN(const shared_ptr& certificate) { char buffer[256]; - int rc = X509_NAME_get_text_by_NID(X509_get_subject_name(certificate.get()), NID_commonName, buffer, sizeof(buffer)); + int rc = X509_NAME_get_text_by_NID(X509_get_subject_name(certificate.get()), + NID_commonName, buffer, sizeof(buffer)); if (rc == -1) - throw_exception(OpenSSLException("X509 certificate has no CN attribute", ERR_get_error())); + throw_exception(OpenSSLException("X509 certificate has no CN" + " attribute", ERR_get_error())); return buffer; } @@ -165,14 +167,17 @@ shared_ptr Utility::GetX509Certificate(String pemfile) BIO *fpcert = BIO_new(BIO_s_file()); if (fpcert == NULL) - throw_exception(OpenSSLException("BIO_new failed", ERR_get_error())); + throw_exception(OpenSSLException("BIO_new failed", + ERR_get_error())); if (BIO_read_filename(fpcert, pemfile.CStr()) < 0) - throw_exception(OpenSSLException("BIO_read_filename failed", ERR_get_error())); + throw_exception(OpenSSLException("BIO_read_filename failed", + ERR_get_error())); cert = PEM_read_bio_X509_AUX(fpcert, NULL, NULL, NULL); if (cert == NULL) - throw_exception(OpenSSLException("PEM_read_bio_X509_AUX failed", ERR_get_error())); + throw_exception(OpenSSLException("PEM_read_bio_X509_AUX failed", + ERR_get_error())); BIO_free(fpcert); @@ -210,7 +215,8 @@ String Utility::DirName(const String& path) #else /* _WIN32 */ if (!PathRemoveFileSpec(dir)) { free(dir); - throw_exception(Win32Exception("PathRemoveFileSpec() failed", GetLastError())); + throw_exception(Win32Exception("PathRemoveFileSpec() failed", + GetLastError())); } result = dir; diff --git a/lib/remoting/endpointmanager.cpp b/lib/remoting/endpointmanager.cpp index fbf13c0d5..080f46aa0 100644 --- a/lib/remoting/endpointmanager.cpp +++ b/lib/remoting/endpointmanager.cpp @@ -258,25 +258,9 @@ void EndpointManager::SendMulticastMessage(const Endpoint::Ptr& sender, } } -/** - * Calls the specified callback function for each registered endpoint. - * - * @param callback The callback function. - */ -//void EndpointManager::ForEachEndpoint(function callback) -//{ -// map::iterator prev, i; -// for (i = m_Endpoints.begin(); i != m_Endpoints.end(); ) { -// prev = i; -// i++; -// -// callback(GetSelf(), prev->second); -// } -//} - void EndpointManager::SendAPIMessage(const Endpoint::Ptr& sender, const Endpoint::Ptr& recipient, RequestMessage& message, - function callback, double timeout) + const EndpointManager::APICallback& callback, double timeout) { m_NextMessageID++; @@ -355,7 +339,8 @@ void EndpointManager::RequestTimerHandler(void) map::iterator it; for (it = m_Requests.begin(); it != m_Requests.end(); it++) { if (it->second.HasTimedOut()) { - it->second.Callback(GetSelf(), Endpoint::Ptr(), it->second.Request, ResponseMessage(), true); + it->second.Callback(GetSelf(), Endpoint::Ptr(), + it->second.Request, ResponseMessage(), true); m_Requests.erase(it); @@ -364,7 +349,8 @@ void EndpointManager::RequestTimerHandler(void) } } -void EndpointManager::ProcessResponseMessage(const Endpoint::Ptr& sender, const ResponseMessage& message) +void EndpointManager::ProcessResponseMessage(const Endpoint::Ptr& sender, + const ResponseMessage& message) { String id; if (!message.GetID(&id)) @@ -381,16 +367,6 @@ void EndpointManager::ProcessResponseMessage(const Endpoint::Ptr& sender, const m_Requests.erase(it); } -//EndpointManager::Iterator EndpointManager::Begin(void) -//{ -// return m_Endpoints.begin(); -//} - -//EndpointManager::Iterator EndpointManager::End(void) -//{ -// return m_Endpoints.end(); -//} - EndpointManager::Ptr EndpointManager::GetInstance(void) { static EndpointManager::Ptr instance; diff --git a/lib/remoting/endpointmanager.h b/lib/remoting/endpointmanager.h index 878cf368e..72c0ba910 100644 --- a/lib/remoting/endpointmanager.h +++ b/lib/remoting/endpointmanager.h @@ -51,8 +51,10 @@ public: void SendAnycastMessage(const Endpoint::Ptr& sender, const RequestMessage& message); void SendMulticastMessage(const Endpoint::Ptr& sender, const RequestMessage& message); + typedef function APICallback; + void SendAPIMessage(const Endpoint::Ptr& sender, const Endpoint::Ptr& recipient, RequestMessage& message, - function callback, double timeout = 30); + const APICallback& callback, double timeout = 30); void ProcessResponseMessage(const Endpoint::Ptr& sender, const ResponseMessage& message); diff --git a/lib/remoting/jsonrpcclient.cpp b/lib/remoting/jsonrpcclient.cpp index 5da414da3..4fd349746 100644 --- a/lib/remoting/jsonrpcclient.cpp +++ b/lib/remoting/jsonrpcclient.cpp @@ -30,7 +30,8 @@ using namespace icinga; JsonRpcClient::JsonRpcClient(TcpClientRole role, shared_ptr sslContext) : TlsClient(role, sslContext) { - OnDataAvailable.connect(boost::bind(&JsonRpcClient::DataAvailableHandler, this)); + OnDataAvailable.connect(boost::bind(&JsonRpcClient::DataAvailableHandler, + this)); } /** @@ -59,12 +60,16 @@ void JsonRpcClient::DataAvailableHandler(void) try { Value value = Value::Deserialize(jsonString); - if (!value.IsObjectType()) - throw_exception(invalid_argument("JSON-RPC message must be a dictionary.")); + if (!value.IsObjectType()) { + throw_exception(invalid_argument("JSON-RPC" + " message must be a dictionary.")); + } OnNewMessage(GetSelf(), MessagePart(value)); } catch (const exception& ex) { - Logger::Write(LogCritical, "jsonrpc", "Exception while processing message from JSON-RPC client: " + String(ex.what())); + Logger::Write(LogCritical, "remoting", "Exception" + " while processing message from JSON-RPC client: " + + String(ex.what())); } } } @@ -77,9 +82,11 @@ void JsonRpcClient::DataAvailableHandler(void) * @param sslContext SSL context for the TLS connection. * @returns A new JSON-RPC client. */ -JsonRpcClient::Ptr icinga::JsonRpcClientFactory(SOCKET fd, TcpClientRole role, shared_ptr sslContext) +JsonRpcClient::Ptr icinga::JsonRpcClientFactory(SOCKET fd, TcpClientRole role, + shared_ptr sslContext) { - JsonRpcClient::Ptr client = boost::make_shared(role, sslContext); + JsonRpcClient::Ptr client = boost::make_shared(role, + sslContext); client->SetFD(fd); return client; }