diff options
author | Mark Wong <markwkm@gmail.com> | 2012-10-19 17:23:22 -0700 |
---|---|---|
committer | Mark Wong <markwkm@gmail.com> | 2012-10-19 17:23:22 -0700 |
commit | e826d795fccecf9c467039a0f6c32bd97ad79562 (patch) | |
tree | 19ff4e205ae6d45ecb70d5cc903d5980197e9da4 | |
parent | a211ac3f161d7ec2752ed038009f93b4f470e86c (diff) |
Add ability to show current executing query
Cycle through what to display by continually pressing 'c'.
-rw-r--r-- | machine/m_linux.c | 4 | ||||
-rw-r--r-- | pg.c | 4 | ||||
-rw-r--r-- | pg_top.c | 19 |
3 files changed, 20 insertions, 7 deletions
diff --git a/machine/m_linux.c b/machine/m_linux.c index 3046acb..b00480a 100644 --- a/machine/m_linux.c +++ b/machine/m_linux.c @@ -649,7 +649,7 @@ read_one_proc_stat(pid_t pid, struct top_proc * proc, struct process_select * se /* full cmd handling */ fullcmd = sel->fullcmd; - if (fullcmd) + if (fullcmd == 1) { sprintf(buffer, "%d/cmdline", pid); if ((fd = open(buffer, O_RDONLY)) != -1) @@ -922,6 +922,8 @@ get_process_info(struct system_info * si, otime = proc->time; read_one_proc_stat(pid, proc, sel); + if (sel->fullcmd == 2) + update_procname(proc, PQgetvalue(pgresult, i, 1)); if (proc->state == 0) continue; @@ -9,11 +9,11 @@ #include "pg_top.h" #define QUERY_PROCESSES \ - "SELECT pid\n" \ + "SELECT pid, query\n" \ "FROM pg_stat_activity;" #define QUERY_PROCESSES_9_1 \ - "SELECT procpid\n" \ + "SELECT procpid, current_query\n" \ "FROM pg_stat_activity;" #define CURRENT_QUERY \ @@ -1201,10 +1201,21 @@ Usage: %s [-ITWbcinqru] [-x x] [-s x] [-o field] [-z username]\n\ case CMD_cmdline: if (statics.flags.fullcmds) { - ps.fullcmd = !ps.fullcmd; - new_message(MT_standout | MT_delayed, - " %sisplaying full command lines.", - ps.fullcmd ? "D" : "Not d"); + ps.fullcmd = (ps.fullcmd + 1) % 3; + switch (ps.fullcmd) { + case 2: + new_message(MT_standout | MT_delayed, + " Displaying current query."); + break; + case 1: + new_message(MT_standout | MT_delayed, + " Displaying full command lines."); + break; + case 0: + default: + new_message(MT_standout | MT_delayed, + " Not displaying full command lines."); + } } else { |