aboutsummaryrefslogtreecommitdiffstats
path: root/logforwarder/src/apps/vespa-logforwarder-start/cf-handler.cpp
diff options
context:
space:
mode:
authorArne Juul <arnej@yahooinc.com>2023-04-26 10:24:29 +0000
committerArne Juul <arnej@yahooinc.com>2023-04-26 10:24:29 +0000
commit3cfbb21fd89ebcb9309b21637b3604691d3c8a79 (patch)
treea9bc026128dc4793d450e4028eb56833b6b4f596 /logforwarder/src/apps/vespa-logforwarder-start/cf-handler.cpp
parent9a4376dae10e986c7061633e5a02f18c24a951da (diff)
write "outputs.conf" if role is configured
Diffstat (limited to 'logforwarder/src/apps/vespa-logforwarder-start/cf-handler.cpp')
-rw-r--r--logforwarder/src/apps/vespa-logforwarder-start/cf-handler.cpp31
1 files changed, 28 insertions, 3 deletions
diff --git a/logforwarder/src/apps/vespa-logforwarder-start/cf-handler.cpp b/logforwarder/src/apps/vespa-logforwarder-start/cf-handler.cpp
index 5d17357e74e..849c8311bd0 100644
--- a/logforwarder/src/apps/vespa-logforwarder-start/cf-handler.cpp
+++ b/logforwarder/src/apps/vespa-logforwarder-start/cf-handler.cpp
@@ -31,11 +31,19 @@ bool isExecutable(const char *path) {
}
return ((statbuf.st_mode & S_IXOTH) != 0);
}
+
+time_t lastModTime(const vespalib::string &fn) {
+ if (fn.empty()) return 0;
+ struct stat info;
+ if (stat(fn.c_str(), &info) != 0) return 0;
+ return info.st_mtime;
}
+} // namespace
+
void CfHandler::doConfigure() {
- std::unique_ptr<LogforwarderConfig> cfg(_handle->getConfig());
- const LogforwarderConfig& config(*cfg);
+ _lastConfig = _handle->getConfig();
+ const LogforwarderConfig& config(*_lastConfig);
LOG(debug, "validating splunk home '%s'", config.splunkHome.c_str());
auto program = config.splunkHome + "/bin/splunk";
if (isExecutable(program.c_str())) {
@@ -45,10 +53,27 @@ void CfHandler::doConfigure() {
}
}
+vespalib::string CfHandler::clientCertFile() const {
+ static const vespalib::string certDir = "/var/lib/sia/certs/";
+ if (_lastConfig && !_lastConfig->role.empty()) {
+ return certDir + _lastConfig->role + ".pem";
+ }
+ return "";
+}
+
+bool CfHandler::certFileChanged() {
+ time_t modTime = lastModTime(clientCertFile());
+ if (modTime != _lastCertFileChange) {
+ _lastCertFileChange = modTime;
+ return true;
+ }
+ return false;
+}
+
void
CfHandler::check()
{
- if (_subscriber.nextConfigNow()) {
+ if (_subscriber.nextConfigNow() || certFileChanged()) {
doConfigure();
}
}