MCPcopy Create free account
hub / github.com/F-Stack/f-stack / genRedisInfoString

Function genRedisInfoString

app/redis-6.2.6/src/server.c:4632–5351  ·  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

4630 * by the INFO command itself as we need to report the same information
4631 * on memory corruption problems. */
4632sds genRedisInfoString(const char *section) {
4633 sds info = sdsempty();
4634 time_t uptime = server.unixtime-server.stat_starttime;
4635 int j;
4636 int allsections = 0, defsections = 0, everything = 0, modules = 0;
4637 int sections = 0;
4638
4639 if (section == NULL) section = "default";
4640 allsections = strcasecmp(section,"all") == 0;
4641 defsections = strcasecmp(section,"default") == 0;
4642 everything = strcasecmp(section,"everything") == 0;
4643 modules = strcasecmp(section,"modules") == 0;
4644 if (everything) allsections = 1;
4645
4646 /* Server */
4647 if (allsections || defsections || !strcasecmp(section,"server")) {
4648 static int call_uname = 1;
4649 static struct utsname name;
4650 char *mode;
4651 char *supervised;
4652
4653 if (server.cluster_enabled) mode = "cluster";
4654 else if (server.sentinel_mode) mode = "sentinel";
4655 else mode = "standalone";
4656
4657 if (server.supervised) {
4658 if (server.supervised_mode == SUPERVISED_UPSTART) supervised = "upstart";
4659 else if (server.supervised_mode == SUPERVISED_SYSTEMD) supervised = "systemd";
4660 else supervised = "unknown";
4661 } else {
4662 supervised = "no";
4663 }
4664
4665 if (sections++) info = sdscat(info,"\r\n");
4666
4667 if (call_uname) {
4668 /* Uname can be slow and is always the same output. Cache it. */
4669 uname(&name);
4670 call_uname = 0;
4671 }
4672
4673 unsigned int lruclock;
4674 atomicGet(server.lruclock,lruclock);
4675 info = sdscatfmt(info,
4676 "# Server\r\n"
4677 "redis_version:%s\r\n"
4678 "redis_git_sha1:%s\r\n"
4679 "redis_git_dirty:%i\r\n"
4680 "redis_build_id:%s\r\n"
4681 "redis_mode:%s\r\n"
4682 "os:%s %s %s\r\n"
4683 "arch_bits:%i\r\n"
4684 "multiplexing_api:%s\r\n"
4685 "atomicvar_api:%s\r\n"
4686 "gcc_version:%i.%i.%i\r\n"
4687 "process_id:%I\r\n"
4688 "process_supervised:%s\r\n"
4689 "run_id:%s\r\n"

Callers 3

infoCommandFunction · 0.85
logServerInfoFunction · 0.85
RM_GetServerInfoFunction · 0.85

Calls 15

sdsemptyFunction · 0.85
strcasecmpFunction · 0.85
sdscatFunction · 0.85
unameFunction · 0.85
sdscatfmtFunction · 0.85
redisGitSHA1Function · 0.85
strtolFunction · 0.85
redisGitDirtyFunction · 0.85
redisBuildIdStringFunction · 0.85
aeGetApiNameFunction · 0.85
getExpansiveClientsInfoFunction · 0.85
sdscatprintfFunction · 0.85

Tested by

no test coverage detected