summaryrefslogtreecommitdiffstats
path: root/commands.c
diff options
context:
space:
mode:
authorMark Wong <mark@2ndQuadrant.com>2019-06-25 03:54:44 +0000
committerMark Wong <mark@2ndQuadrant.com>2019-07-08 19:17:01 +0000
commit907fe08432c1128aa6d5d38fd50d5102fb1a4f6c (patch)
treed7f87051b06b2af05b7b1e16c54c4fcbbdf0096c /commands.c
parentfcc197f996035faeed84ec859e70e68fd1bd6fa5 (diff)
Fix handling of display headers
Show the correct header when listing top activity, i/o, or replication processes.
Diffstat (limited to 'commands.c')
-rw-r--r--commands.c34
1 files changed, 16 insertions, 18 deletions
diff --git a/commands.c b/commands.c
index 1b628dc..9efa549 100644
--- a/commands.c
+++ b/commands.c
@@ -47,12 +47,6 @@ extern int overstrike;
extern int max_topn;
-char header_io_stats[64] =
- " PID RCHAR WCHAR SYSCR SYSCW READS WRITES CWRITES COMMAND";
-
-char header_replication_stats[] =
- " PID USERNAME APPLICATION CLIENT STATE PRIMARY SENT WRITE FLUSH REPLAY SLAG WLAG FLAG RLAG";
-
#define BEGIN "BEGIN;"
#define ROLLBACK "ROLLBACK;"
@@ -62,6 +56,7 @@ struct cmd cmd_map[] = {
{' ', cmd_update},
{'?', cmd_help},
{'A', cmd_explain_analyze},
+ {'a', cmd_activity},
{'c', cmd_cmdline},
#ifdef ENABLE_COLOR
{'C', cmd_color},
@@ -87,6 +82,16 @@ struct cmd cmd_map[] = {
{'\0', NULL},
};
+int
+cmd_activity(struct pg_top_context *pgtctx)
+{
+ pgtctx->mode = MODE_PROCESSES;
+ pgtctx->header_text =
+ pgtctx->header_options[pgtctx->mode_remote][pgtctx->mode];
+ reset_display(pgtctx);
+ return No;
+}
+
#ifdef ENABLE_COLOR
int
cmd_color(struct pg_top_context *pgtctx)
@@ -250,17 +255,9 @@ cmd_idletog(struct pg_top_context *pgtctx)
int
cmd_io(struct pg_top_context *pgtctx)
{
- if (pgtctx->mode == MODE_IO_STATS)
- {
- pgtctx->mode = MODE_PROCESSES;
- pgtctx->header_text =
- pgtctx->header_processes;
- }
- else
- {
- pgtctx->mode = MODE_IO_STATS;
- pgtctx->header_text = header_io_stats;
- }
+ pgtctx->mode = MODE_IO_STATS;
+ pgtctx->header_text =
+ pgtctx->header_options[pgtctx->mode_remote][pgtctx->mode];
reset_display(pgtctx);
return No;
}
@@ -326,7 +323,8 @@ int
cmd_replication(struct pg_top_context *pgtctx)
{
pgtctx->mode = MODE_REPLICATION;
- pgtctx->header_text = header_replication_stats;
+ pgtctx->header_text =
+ pgtctx->header_options[pgtctx->mode_remote][pgtctx->mode];
reset_display(pgtctx);
return No;
}