]> granicus.if.org Git - icinga2/commitdiff
Revamp livestatus startup logging a bit.
authorMichael Friedrich <Michael.Friedrich@netways.de>
Sat, 28 Sep 2013 10:54:26 +0000 (12:54 +0200)
committerMichael Friedrich <Michael.Friedrich@netways.de>
Sat, 28 Sep 2013 10:54:26 +0000 (12:54 +0200)
components/livestatus/listener.cpp
contrib/config/mf/icinga2.conf

index 7bc1105f3c01db0f2503c3884ca1771a9efb2e54..a72e545a9c60c5e50b1889526f52f39c3a3d0314 100644 (file)
 #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 <boost/smart_ptr/make_shared.hpp>
+#include <boost/exception/diagnostic_information.hpp>
+
 
 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.");
index 384bac46627ae7c7ff7e9de4c529820eaed27889..38bcb63eefe5bdb925dad0ed002327b6f9b625c8 100644 (file)
@@ -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),