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

Function statMode

src/redis-cli.c:6866–6950  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

6864}
6865
6866static void statMode(void) {
6867 redisReply *reply;
6868 long aux, requests = 0;
6869 int i = 0;
6870
6871 while(1) {
6872 char buf[64];
6873 int j;
6874
6875 reply = reconnectingRedisCommand(context,"INFO");
6876 if (reply->type == REDIS_REPLY_ERROR) {
6877 printf("ERROR: %s\n", reply->str);
6878 exit(1);
6879 }
6880
6881 if ((i++ % 20) == 0) {
6882 printf(
6883"------- data ------ --------------------- load -------------------- - child -\n"
6884"keys mem clients blocked requests connections \n");
6885 }
6886
6887 /* Keys */
6888 aux = 0;
6889 for (j = 0; j < 20; j++) {
6890 long k;
6891
6892 snprintf(buf,sizeof(buf),"db%d:keys",j);
6893 k = getLongInfoField(reply->str,buf);
6894 if (k == LONG_MIN) continue;
6895 aux += k;
6896 }
6897 snprintf(buf,sizeof(buf),"%ld",aux);
6898 printf("%-11s",buf);
6899
6900 /* Used memory */
6901 aux = getLongInfoField(reply->str,"used_memory");
6902 bytesToHuman(buf,aux,sizeof(buf));
6903 printf("%-8s",buf);
6904
6905 /* Clients */
6906 aux = getLongInfoField(reply->str,"connected_clients");
6907 snprintf(buf,sizeof(buf),"%ld",aux);
6908 printf(" %-8s",buf);
6909
6910 /* Blocked (BLPOPPING) Clients */
6911 aux = getLongInfoField(reply->str,"blocked_clients");
6912 snprintf(buf,sizeof(buf),"%ld",aux);
6913 printf("%-8s",buf);
6914
6915 /* Requests */
6916 aux = getLongInfoField(reply->str,"total_commands_processed");
6917 snprintf(buf,sizeof(buf),"%ld (+%ld)",aux,requests == 0 ? 0 : aux-requests);
6918 printf("%-19s",buf);
6919 requests = aux;
6920
6921 /* Connections */
6922 aux = getLongInfoField(reply->str,"total_connections_received");
6923 snprintf(buf,sizeof(buf),"%ld",aux);

Callers 1

mainFunction · 0.85

Calls 4

reconnectingRedisCommandFunction · 0.85
getLongInfoFieldFunction · 0.85
freeReplyObjectFunction · 0.85
bytesToHumanFunction · 0.70

Tested by

no test coverage detected