MCPcopy Create free account
hub / github.com/Snapchat/KeyDB / genRedisInfoString

Function genRedisInfoString

src/server.cpp:5598–6404  ·  view source on GitHub ↗

Create the string returned by the INFO command. This is decoupled * by the INFO command itself as we need to report the same information * on memory corruption problems. */

Source from the content-addressed store, hash-verified

5596 * by the INFO command itself as we need to report the same information
5597 * on memory corruption problems. */
5598sds genRedisInfoString(const char *section) {
5599 sds info = sdsempty();
5600 time_t uptime = g_pserver->unixtime-cserver.stat_starttime;
5601 int j;
5602 int allsections = 0, defsections = 0, everything = 0, modules = 0;
5603 int sections = 0;
5604
5605 if (section == NULL) section = "default";
5606 allsections = strcasecmp(section,"all") == 0;
5607 defsections = strcasecmp(section,"default") == 0;
5608 everything = strcasecmp(section,"everything") == 0;
5609 modules = strcasecmp(section,"modules") == 0;
5610 if (everything) allsections = 1;
5611
5612 /* Server */
5613 if (allsections || defsections || !strcasecmp(section,"server")) {
5614 static int call_uname = 1;
5615 static struct utsname name;
5616 const char *mode;
5617 const char *supervised;
5618
5619 if (g_pserver->cluster_enabled) mode = "cluster";
5620 else if (g_pserver->sentinel_mode) mode = "sentinel";
5621 else mode = "standalone";
5622
5623 if (cserver.supervised) {
5624 if (cserver.supervised_mode == SUPERVISED_UPSTART) supervised = "upstart";
5625 else if (cserver.supervised_mode == SUPERVISED_SYSTEMD) supervised = "systemd";
5626 else supervised = "unknown";
5627 } else {
5628 supervised = "no";
5629 }
5630
5631 if (sections++) info = sdscat(info,"\r\n");
5632
5633 if (call_uname) {
5634 /* Uname can be slow and is always the same output. Cache it. */
5635 uname(&name);
5636 call_uname = 0;
5637 }
5638
5639 unsigned int lruclock = g_pserver->lruclock.load();
5640 ustime_t ustime;
5641 __atomic_load(&g_pserver->ustime, &ustime, __ATOMIC_RELAXED);
5642 info = sdscatfmt(info,
5643 "# Server\r\n"
5644 "redis_version:%s\r\n"
5645 "redis_git_sha1:%s\r\n"
5646 "redis_git_dirty:%i\r\n"
5647 "redis_build_id:%s\r\n"
5648 "redis_mode:%s\r\n"
5649 "os:%s %s %s\r\n"
5650 "arch_bits:%i\r\n"
5651 "multiplexing_api:%s\r\n"
5652 "atomicvar_api:%s\r\n"
5653 "gcc_version:%i.%i.%i\r\n"
5654 "process_id:%I\r\n"
5655 "process_supervised:%s\r\n"

Callers 3

infoCommandFunction · 0.85
logServerInfoFunction · 0.85
RM_GetServerInfoFunction · 0.85

Calls 15

sdsemptyFunction · 0.85
sdscatFunction · 0.85
sdscatfmtFunction · 0.85
redisGitSHA1Function · 0.85
redisGitDirtyFunction · 0.85
redisBuildIdStringFunction · 0.85
aeGetApiNameFunction · 0.85
getExpansiveClientsInfoFunction · 0.85
sdscatprintfFunction · 0.85
raxSizeFunction · 0.85
zmalloc_used_memoryFunction · 0.85

Tested by

no test coverage detected