SENTINEL INFO [section] */
| 3916 | |
| 3917 | /* SENTINEL INFO [section] */ |
| 3918 | void sentinelInfoCommand(client *c) { |
| 3919 | if (c->argc > 2) { |
| 3920 | addReplyErrorObject(c,shared.syntaxerr); |
| 3921 | return; |
| 3922 | } |
| 3923 | |
| 3924 | int defsections = 0, allsections = 0; |
| 3925 | char *section = c->argc == 2 ? szFromObj(c->argv[1]) : NULL; |
| 3926 | if (section) { |
| 3927 | allsections = !strcasecmp(section,"all"); |
| 3928 | defsections = !strcasecmp(section,"default"); |
| 3929 | } else { |
| 3930 | defsections = 1; |
| 3931 | } |
| 3932 | |
| 3933 | int sections = 0; |
| 3934 | sds info = sdsempty(); |
| 3935 | |
| 3936 | info_section_from_redis("server"); |
| 3937 | info_section_from_redis("clients"); |
| 3938 | info_section_from_redis("cpu"); |
| 3939 | info_section_from_redis("stats"); |
| 3940 | |
| 3941 | if (defsections || allsections || !strcasecmp(section,"sentinel")) { |
| 3942 | dictIterator *di; |
| 3943 | dictEntry *de; |
| 3944 | int master_id = 0; |
| 3945 | |
| 3946 | if (sections++) info = sdscat(info,"\r\n"); |
| 3947 | info = sdscatprintf(info, |
| 3948 | "# Sentinel\r\n" |
| 3949 | "sentinel_masters:%lu\r\n" |
| 3950 | "sentinel_tilt:%d\r\n" |
| 3951 | "sentinel_running_scripts:%d\r\n" |
| 3952 | "sentinel_scripts_queue_length:%ld\r\n" |
| 3953 | "sentinel_simulate_failure_flags:%lu\r\n", |
| 3954 | dictSize(sentinel.masters), |
| 3955 | sentinel.tilt, |
| 3956 | sentinel.running_scripts, |
| 3957 | listLength(sentinel.scripts_queue), |
| 3958 | sentinel.simfailure_flags); |
| 3959 | |
| 3960 | di = dictGetIterator(sentinel.masters); |
| 3961 | while((de = dictNext(di)) != NULL) { |
| 3962 | sentinelRedisInstance *ri = (sentinelRedisInstance*)dictGetVal(de); |
| 3963 | const char *status = "ok"; |
| 3964 | |
| 3965 | if (ri->flags & SRI_O_DOWN) status = "odown"; |
| 3966 | else if (ri->flags & SRI_S_DOWN) status = "sdown"; |
| 3967 | info = sdscatprintf(info, |
| 3968 | "master%d:name=%s,status=%s,address=%s:%d," |
| 3969 | "slaves=%lu,sentinels=%lu\r\n", |
| 3970 | master_id++, ri->name, status, |
| 3971 | announceSentinelAddr(ri->addr), ri->addr->port, |
| 3972 | dictSize(ri->slaves), |
| 3973 | dictSize(ri->sentinels)+1); |
| 3974 | } |
| 3975 | dictReleaseIterator(di); |
nothing calls this directly
no test coverage detected