This is an automated email from the ASF dual-hosted git repository.
twice pushed a commit to branch unstable
in repository https://gitbox.apache.org/repos/asf/kvrocks.git
The following commit(s) were added to refs/heads/unstable by this push:
new e07972b4 feat(server): add rocksdb_version, server_time_usec,
executable and config_file to INFO (#2781)
e07972b4 is described below
commit e07972b4a9859949b2d98395c13e8d5c0ac903c6
Author: Twice <[email protected]>
AuthorDate: Sun Feb 9 18:36:51 2025 +0800
feat(server): add rocksdb_version, server_time_usec, executable and
config_file to INFO (#2781)
---
src/config/config.h | 1 +
src/server/server.cc | 15 +++++++++++++--
2 files changed, 14 insertions(+), 2 deletions(-)
diff --git a/src/config/config.h b/src/config/config.h
index 7c76759c..3a9a7db4 100644
--- a/src/config/config.h
+++ b/src/config/config.h
@@ -249,6 +249,7 @@ struct Config {
void ClearMaster();
bool IsSlave() const { return !master_host.empty(); }
bool HasConfigFile() const { return !path_.empty(); }
+ std::string ConfigFilePath() const { return path_; }
private:
std::string path_;
diff --git a/src/server/server.cc b/src/server/server.cc
index 9f21b04c..395f972c 100644
--- a/src/server/server.cc
+++ b/src/server/server.cc
@@ -30,6 +30,7 @@
#include <algorithm>
#include <atomic>
#include <cstdint>
+#include <cstdlib>
#include <functional>
#include <iomanip>
#include <jsoncons/json.hpp>
@@ -43,6 +44,7 @@
#include "config/config.h"
#include "fmt/format.h"
#include "redis_connection.h"
+#include "rocksdb/version.h"
#include "storage/compaction_checker.h"
#include "storage/redis_db.h"
#include "storage/scripting.h"
@@ -970,10 +972,10 @@ Server::InfoEntries Server::GetServerInfo() {
}
Server::InfoEntries entries;
- entries.emplace_back("version", VERSION);
+ entries.emplace_back("version", VERSION); // deprecated
entries.emplace_back("kvrocks_version", VERSION);
entries.emplace_back("redis_version", REDIS_VERSION);
- entries.emplace_back("git_sha1", GIT_COMMIT);
+ entries.emplace_back("git_sha1", GIT_COMMIT); // deprecated
entries.emplace_back("kvrocks_git_sha1", GIT_COMMIT);
entries.emplace_back("redis_mode", (config_->cluster_enabled ? "cluster" :
"standalone"));
entries.emplace_back("kvrocks_mode", (config_->cluster_enabled ? "cluster" :
"standalone"));
@@ -985,12 +987,21 @@ Server::InfoEntries Server::GetServerInfo() {
entries.emplace_back("clang_version",
fmt::format("{}.{}.{}", __clang_major__,
__clang_minor__, __clang_patchlevel__));
#endif
+ entries.emplace_back("rocksdb_version", fmt::format("{}.{}.{}",
ROCKSDB_MAJOR, ROCKSDB_MINOR, ROCKSDB_PATCH));
entries.emplace_back("arch_bits", sizeof(void *) * 8);
entries.emplace_back("process_id", getpid());
entries.emplace_back("tcp_port", config_->port);
+ entries.emplace_back("server_time_usec", util::GetTimeStampUS());
int64_t now_secs = util::GetTimeStamp<std::chrono::seconds>();
entries.emplace_back("uptime_in_seconds", now_secs - start_time_secs_);
entries.emplace_back("uptime_in_days", (now_secs - start_time_secs_) /
86400);
+#ifdef __linux__
+ if (auto exec_path = realpath("/proc/self/exe", nullptr)) {
+ entries.emplace_back("executable", exec_path);
+ free(exec_path); // NOLINT(cppcoreguidelines-no-malloc)
+ }
+#endif
+ entries.emplace_back("config_file", config_->ConfigFilePath());
return entries;
}