summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDeepak Kodihalli <dkodihal@in.ibm.com>2018-10-17 05:03:20 -0500
committerDeepak Kodihalli <dkodihal@in.ibm.com>2018-10-17 05:28:08 -0500
commitaabb92ef56c4faa8f05487e9fcdf83f1053f1a22 (patch)
treecc24e994776e565725ea201970d0389c87e2576b
parent93b1b7c4629b5c7f6dcf2950c1536e23ef014abc (diff)
downloadphosphor-logging-aabb92ef56c4faa8f05487e9fcdf83f1053f1a22.zip
phosphor-logging-aabb92ef56c4faa8f05487e9fcdf83f1053f1a22.tar.gz
phosphor-rsyslog-conf: react to hostname change
The rsyslog client caches the hostname when it starts up (hostname is included in logs that are streamed out). If someone changes hostname via REST API for example, the same won't reflect in rsyslog logs at the server. Listen to the hostname changed D-Bus signal from systemd, and restart rsyslogd when this happens. This ensures logs are streamed out with the updated hostname. Change-Id: Ied2b401e621314ef7c25e97dc93f86a429fb4077 Signed-off-by: Deepak Kodihalli <dkodihal@in.ibm.com>
-rw-r--r--phosphor-rsyslog-config/server-conf.hpp19
1 files changed, 18 insertions, 1 deletions
diff --git a/phosphor-rsyslog-config/server-conf.hpp b/phosphor-rsyslog-config/server-conf.hpp
index edab113..8660416 100644
--- a/phosphor-rsyslog-config/server-conf.hpp
+++ b/phosphor-rsyslog-config/server-conf.hpp
@@ -14,6 +14,7 @@ namespace rsyslog_config
using namespace phosphor::logging;
using NetworkClient = sdbusplus::xyz::openbmc_project::Network::server::Client;
using Iface = sdbusplus::server::object::object<NetworkClient>;
+namespace sdbusRule = sdbusplus::bus::match::rules;
/** @class Server
* @brief Configuration for rsyslog server
@@ -40,7 +41,13 @@ class Server : public Iface
const std::string& path,
const char* filePath) :
Iface(bus, path.c_str(), true),
- configFilePath(filePath)
+ configFilePath(filePath),
+ hostnameChange(
+ bus,
+ sdbusRule::propertiesChanged(
+ "/org/freedesktop/hostname1", "org.freedesktop.hostname1"),
+ std::bind(std::mem_fn(&Server::hostnameChanged),
+ this, std::placeholders::_1))
{
try
{
@@ -97,6 +104,16 @@ class Server : public Iface
void restore(const char* filePath);
std::string configFilePath{};
+
+ /** @brief React to hostname change
+ * @param[in] msg - sdbusplus message
+ */
+ void hostnameChanged(sdbusplus::message::message& msg)
+ {
+ restart();
+ }
+
+ sdbusplus::bus::match_t hostnameChange;
};
} // namespace rsyslog_config
OpenPOWER on IntegriCloud