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

Function statMode

app/redis-6.2.6/src/redis-cli.c:7980–8064  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

7978}
7979
7980static void statMode(void) {
7981 redisReply *reply;
7982 long aux, requests = 0;
7983 int i = 0;
7984
7985 while(1) {
7986 char buf[64];
7987 int j;
7988
7989 reply = reconnectingRedisCommand(context,"INFO");
7990 if (reply->type == REDIS_REPLY_ERROR) {
7991 printf("ERROR: %s\n", reply->str);
7992 exit(1);
7993 }
7994
7995 if ((i++ % 20) == 0) {
7996 printf(
7997"------- data ------ --------------------- load -------------------- - child -\n"
7998"keys mem clients blocked requests connections \n");
7999 }
8000
8001 /* Keys */
8002 aux = 0;
8003 for (j = 0; j < 20; j++) {
8004 long k;
8005
8006 sprintf(buf,"db%d:keys",j);
8007 k = getLongInfoField(reply->str,buf);
8008 if (k == LONG_MIN) continue;
8009 aux += k;
8010 }
8011 sprintf(buf,"%ld",aux);
8012 printf("%-11s",buf);
8013
8014 /* Used memory */
8015 aux = getLongInfoField(reply->str,"used_memory");
8016 bytesToHuman(buf,aux);
8017 printf("%-8s",buf);
8018
8019 /* Clients */
8020 aux = getLongInfoField(reply->str,"connected_clients");
8021 sprintf(buf,"%ld",aux);
8022 printf(" %-8s",buf);
8023
8024 /* Blocked (BLPOPPING) Clients */
8025 aux = getLongInfoField(reply->str,"blocked_clients");
8026 sprintf(buf,"%ld",aux);
8027 printf("%-8s",buf);
8028
8029 /* Requests */
8030 aux = getLongInfoField(reply->str,"total_commands_processed");
8031 sprintf(buf,"%ld (+%ld)",aux,requests == 0 ? 0 : aux-requests);
8032 printf("%-19s",buf);
8033 requests = aux;
8034
8035 /* Connections */
8036 aux = getLongInfoField(reply->str,"total_connections_received");
8037 sprintf(buf,"%ld",aux);

Callers 1

mainFunction · 0.85

Calls 6

reconnectingRedisCommandFunction · 0.85
sprintfFunction · 0.85
getLongInfoFieldFunction · 0.85
freeReplyObjectFunction · 0.85
bytesToHumanFunction · 0.70
printfFunction · 0.50

Tested by

no test coverage detected