From a326ddbb9fa56afbf4c1715ae8e092725fa0c9ec Mon Sep 17 00:00:00 2001 From: Michael Friedrich Date: Sat, 28 Sep 2013 12:54:26 +0200 Subject: [PATCH] Revamp livestatus startup logging a bit. --- components/livestatus/listener.cpp | 15 ++++++++++++--- contrib/config/mf/icinga2.conf | 7 +++---- 2 files changed, 15 insertions(+), 7 deletions(-) diff --git a/components/livestatus/listener.cpp b/components/livestatus/listener.cpp index 7bc1105f3..a72e545a9 100644 --- a/components/livestatus/listener.cpp +++ b/components/livestatus/listener.cpp @@ -21,11 +21,14 @@ #include "base/objectlock.h" #include "base/dynamictype.h" #include "base/logger_fwd.h" +#include "base/exception.h" #include "base/tcpsocket.h" #include "base/unixsocket.h" #include "base/networkstream.h" #include "base/application.h" #include +#include + using namespace icinga; using namespace livestatus; @@ -49,6 +52,7 @@ void LivestatusListener::Start(void) boost::thread thread(boost::bind(&LivestatusListener::ServerThreadProc, this, socket)); thread.detach(); + Log(LogInformation, "livestatus", "Created tcp socket listening on host '" + GetBindHost() + "' port '" + GetBindPort() + "'."); } else if (GetSocketType() == "unix") { #ifndef _WIN32 @@ -56,13 +60,18 @@ void LivestatusListener::Start(void) socket->Bind(GetSocketPath()); /* group must be able to write */ - if (chmod(GetSocketPath().CStr(), 0660) < 0) { - Log(LogCritical, "livestatus", "Cannot chmod unix socket '" + GetSocketPath() + "' to 0660: " + strerror(errno)); - return; + mode_t mode = S_IRUSR | S_IWUSR | S_IRGRP | S_IWGRP; + + if (chmod(GetSocketPath().CStr(), mode) < 0) { + BOOST_THROW_EXCEPTION(posix_error() + << boost::errinfo_api_function("chmod") + << boost::errinfo_errno(errno) + << boost::errinfo_file_name(GetSocketPath())); } boost::thread thread(boost::bind(&LivestatusListener::ServerThreadProc, this, socket)); thread.detach(); + Log(LogInformation, "livestatus", "Created unix socket in '" + GetSocketPath() + "'."); #else /* no unix sockets on windows */ Log(LogCritical, "livestatus", "Unix sockets are not supported on Windows."); diff --git a/contrib/config/mf/icinga2.conf b/contrib/config/mf/icinga2.conf index 384bac466..38bcb63ee 100644 --- a/contrib/config/mf/icinga2.conf +++ b/contrib/config/mf/icinga2.conf @@ -54,7 +54,6 @@ object PerfdataWriter "pnp" { /** * LIVESTATUS */ -/* library "livestatus" object LivestatusListener "livestatus-tcp" { @@ -65,9 +64,9 @@ object LivestatusListener "livestatus-tcp" { object LivestatusListener "livestatus-unix" { socket_type = "unix", - socket_path = (Icinga2Prefix + "/var/run/icinga2/livestatus") + socket_path = (Icinga2Prefix + "/var/run/icinga2/rw/livestatus") } -*/ + /** * IDO */ @@ -131,7 +130,7 @@ object Host "localhost" { notifications["mail-michi"] = { templates = [ "mail-notification" ], users = [ "michi" ], - groups = [ "all-michis" ], + user_groups = [ "all-michis" ], notification_period = "24x7", notification_state_filter = (StateFilterUnknown | StateFilterOK | StateFilterWarning | StateFilterCritical), notification_type_filter = (NotificationRecovery | NotificationDowntimeStart | NotificationDowntimeEnd), -- 2.50.0