summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMark Wong <mark@2ndQuadrant.com>2019-06-08 00:49:45 +0000
committerMark Wong <mark@2ndQuadrant.com>2019-06-26 22:13:52 +0000
commit0b7f7fb03d6580e6b1a0238b4c37bed9a5d3a029 (patch)
treeb5f83645c620f9eae05f04efaa21752cf9360d07
parent4483ea4e505f22345783fa42ae1fef19ea0d4a2c (diff)
Linux: show summarized backend states
Show a summary of PostgreSQL backends states instead of operating system process states.
-rw-r--r--TODO12
-rw-r--r--machine.h3
-rw-r--r--machine/m_common.c5
-rw-r--r--machine/m_linux.c11
-rw-r--r--machine/m_remote.c9
5 files changed, 10 insertions, 30 deletions
diff --git a/TODO b/TODO
index 6392cbc..a22745a 100644
--- a/TODO
+++ b/TODO
@@ -11,18 +11,6 @@
* Display summary statistics for average query cpu time, average query elapsed
time, etc.
-* Renamed number of processs to be number of connections since that is more
- accurate:
-
- 5 processes: 1 running, 4 sleeping
-
- to
-
- 5 connections: 1 running, 4 sleeping
-
-* Display summary statistics for connections such as total number of idles
- connections, etc.
-
* Display summary statistics for locks such as total number of granted locks,
total number of ungranted locks, etc.
diff --git a/machine.h b/machine.h
index 571e804..83c229e 100644
--- a/machine.h
+++ b/machine.h
@@ -45,6 +45,8 @@
#define NUM_AVERAGES 3
+#define NPROCSTATES 7
+
/*
* The statics struct is filled in by machine_init. Fields marked as
* "optional" are not filled in by every module.
@@ -166,5 +168,6 @@ void update_state(int *pgstate, char *state);
extern int mode_stats;
extern char *backendstatenames[];
+extern char *procstatenames[];
#endif /* _MACHINE_H_ */
diff --git a/machine/m_common.c b/machine/m_common.c
index ff03365..3d33c52 100644
--- a/machine/m_common.c
+++ b/machine/m_common.c
@@ -27,6 +27,11 @@ char *backendstatenames[] =
"", "idle", "active", "idltxn", "fast", "abort", "disabl", NULL
};
+char *procstatenames[] =
+{
+ "", " idle, ", " active, ", " idle txn, ", " fastpath, ", " aborted, ",
+ " disabled, ", NULL
+};
/* Store data directory to avoid unnecessary requests to server */
static char *data_directory = NULL;
diff --git a/machine/m_linux.c b/machine/m_linux.c
index 3440655..4d9c84a 100644
--- a/machine/m_linux.c
+++ b/machine/m_linux.c
@@ -124,15 +124,6 @@ struct io_node
/*=STATE IDENT STRINGS==================================================*/
-#define NPROCSTATES 7
-
-static char *procstatenames[NPROCSTATES + 1] =
-{
- "", " running, ", " sleeping, ", " uninterruptable, ",
- " zombie, ", " stopped, ", " swapping, ",
- NULL
-};
-
#define NCPUSTATES 5
static char *cpustatenames[NCPUSTATES + 1] =
{
@@ -937,7 +928,7 @@ get_process_info(struct system_info * si,
continue;
total_procs++;
- process_states[proc->state]++;
+ process_states[proc->pgstate]++;
if (timediff > 0.0)
{
diff --git a/machine/m_remote.c b/machine/m_remote.c
index c11694a..77b5a68 100644
--- a/machine/m_remote.c
+++ b/machine/m_remote.c
@@ -65,7 +65,6 @@ enum column_proctab { c_pid, c_comm, c_fullcomm, c_state, c_utime, c_stime,
#define NCPUSTATES 5
#define NMEMSTATS 5
-#define NPROCSTATES 7
#define NSWAPSTATS 3
#define MEMUSED 0
@@ -137,12 +136,6 @@ static char *memorynames[NMEMSTATS + 1] =
/* these are names given to allowed sorting orders -- first is default */
static char *ordernames[] = {"cpu", "size", "res", "time", "command", NULL};
-static char *procstatenames[NPROCSTATES + 1] =
-{
- "", " running, ", " sleeping, ", " uninterruptable, ", " zombie, ",
- " stopped, ", " swapping, ", NULL
-};
-
static char *swapnames[NSWAPSTATS + 1] =
{
"K used, ", "K free, ", "K cached", NULL
@@ -700,7 +693,7 @@ get_process_info_r(struct system_info *si, struct process_select *sel,
proc->cancelled_write_bytes = value;
++total_procs;
- ++process_states[proc->state];
+ ++process_states[proc->pgstate];
if (timediff > 0.0)
{