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. */
| 4630 | * by the INFO command itself as we need to report the same information |
| 4631 | * on memory corruption problems. */ |
| 4632 | sds 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" |
no test coverage detected