summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMark Wong <markwkm@gmail.com>2012-10-19 17:23:22 -0700
committerMark Wong <markwkm@gmail.com>2012-10-19 17:23:22 -0700
commite826d795fccecf9c467039a0f6c32bd97ad79562 (patch)
tree19ff4e205ae6d45ecb70d5cc903d5980197e9da4
parenta211ac3f161d7ec2752ed038009f93b4f470e86c (diff)
Add ability to show current executing query
Cycle through what to display by continually pressing 'c'.
-rw-r--r--machine/m_linux.c4
-rw-r--r--pg.c4
-rw-r--r--pg_top.c19
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;
diff --git a/pg.c b/pg.c
index b5f2ab8..c9a7e16 100644
--- a/pg.c
+++ b/pg.c
@@ -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 \
diff --git a/pg_top.c b/pg_top.c
index a47472c..050ee6e 100644
--- a/pg_top.c
+++ b/pg_top.c
@@ -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
{