summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMark Wong <mark@2ndQuadrant.com>2019-06-14 16:04:43 +0000
committerMark Wong <mark@2ndQuadrant.com>2019-07-08 12:07:56 -0700
commit1d9377c1c6ed915c9be5ef3a93e9e0ccf207e27e (patch)
tree515a909469619b087e10a82d4f2462a0843827bd
parentf59d4646908e5e2faa9b2df21d723cc5d9d5dd40 (diff)
Linux: remove wcpu from display
Removed the weighted cpu numbers for two reasons: * need more screen space * some current top programs already removing the weighted calculated This also allows us to fix more data that is intended to be more useful for monitoring database related processes.
-rw-r--r--machine/m_linux.c41
-rw-r--r--machine/m_remote.c31
-rw-r--r--pg_top.1.in2
3 files changed, 7 insertions, 67 deletions
diff --git a/machine/m_linux.c b/machine/m_linux.c
index b63c932..98cfd15 100644
--- a/machine/m_linux.c
+++ b/machine/m_linux.c
@@ -84,8 +84,7 @@ struct top_proc
unsigned long start_time;
unsigned long xtime;
unsigned long qtime;
- double pcpu,
- wcpu;
+ double pcpu;
/* Data from /proc/<pid>/io. */
long long rchar;
@@ -145,7 +144,7 @@ static char *swapnames[NSWAPSTATS + 1] =
};
static char fmt_header[] =
-" PID X SIZE RES STATE XTIME QTIME WCPU CPU COMMAND";
+" PID X SIZE RES STATE XTIME QTIME %CPU COMMAND";
/* these are names given to allowed sorting orders -- first is default */
static char *ordernames[] =
@@ -718,11 +717,7 @@ get_process_info(struct system_info * si,
int compare_index, struct pg_conninfo_ctx *conninfo, int mode)
{
struct timeval thistime;
- double timediff,
- alpha,
- beta;
- unsigned long now;
- unsigned long elapsed;
+ double timediff;
/* calculate the time difference since our last check */
gettimeofday(&thistime, 0);
@@ -737,23 +732,6 @@ get_process_info(struct system_info * si,
}
lasttime = thistime;
- /* round current time to a second */
- now = (unsigned long) thistime.tv_sec;
- if (thistime.tv_usec >= 500000)
- {
- now++;
- }
-
- /* calculate constants for the exponental average */
- if (timediff > 0.0 && timediff < 30.0)
- {
- alpha = 0.5 * (timediff / 30.0);
- beta = 1.0 - alpha;
- }
- else
- {
- alpha = beta = 0.5;
- }
timediff *= HZ; /* convert to ticks */
/* read the process information */
@@ -817,7 +795,6 @@ get_process_info(struct system_info * si,
else
{
n->time = 0;
- n->wcpu = 0;
}
otime = n->time;
@@ -842,15 +819,6 @@ get_process_info(struct system_info * si,
{
n->pcpu = 0;
}
- n->wcpu = n->pcpu * alpha + n->wcpu * beta;
- }
- else if ((elapsed = (now - boottime) * HZ - n->start_time) > 0)
- {
- n->wcpu = n->pcpu;
- }
- else
- {
- n->wcpu = n->pcpu = 0.0;
}
if ((show_idle || n->pgstate != STATE_IDLE) &&
@@ -940,7 +908,7 @@ format_next_process(caddr_t handle)
struct top_proc *p = &pgtable[proc_index++];
snprintf(fmt, sizeof(fmt),
- "%5d %-8.8s %5s %5s %-6s %5s %5s %5.2f%% %5.2f%% %s",
+ "%5d %-8.8s %5s %5s %-6s %5s %5s %5.1f %s",
p->pid,
p->usename,
format_k(p->size),
@@ -948,7 +916,6 @@ format_next_process(caddr_t handle)
backendstatenames[p->pgstate],
format_time(p->xtime),
format_time(p->qtime),
- p->wcpu * 100.0,
p->pcpu * 100.0,
p->name);
diff --git a/machine/m_remote.c b/machine/m_remote.c
index 2fc57f2..b2a2dfe 100644
--- a/machine/m_remote.c
+++ b/machine/m_remote.c
@@ -102,7 +102,6 @@ struct top_proc_r
unsigned long xtime;
unsigned long qtime;
double pcpu;
- double wcpu;
/* The change in the previous values and current values. */
long long rchar_diff;
@@ -156,7 +155,7 @@ static char *swapnames[NSWAPSTATS + 1] =
};
static char fmt_header[] =
- " PID X SIZE RES STATE XTIME QTIME WCPU CPU COMMAND";
+ " PID X SIZE RES STATE XTIME QTIME %CPU COMMAND";
/* Now the array that maps process state to a weight. */
@@ -560,7 +559,7 @@ format_next_process_r(caddr_t handler)
struct top_proc_r *p = &pgrtable[proc_r_index++];
snprintf(fmt, sizeof(fmt),
- "%5d %-8.8s %5s %5s %-6s %5s %5s %5.2f%% %5.2f%% %s",
+ "%5d %-8.8s %5s %5s %-6s %5s %5s %5.1f %s",
(int) p->pid, /* Some OS's need to cast pid_t to int. */
p->usename,
format_k(p->size),
@@ -568,7 +567,6 @@ format_next_process_r(caddr_t handler)
backendstatenames[p->pgstate],
format_time(p->xtime),
format_time(p->qtime),
- p->wcpu * 100.0,
p->pcpu * 100.0,
p->name);
@@ -679,10 +677,6 @@ get_process_info_r(struct system_info *si, struct process_select *sel,
struct timeval thistime;
double timediff;
- double alpha;
- double beta;
- unsigned long now;
- unsigned long elapsed;
int active_procs = 0;
int total_procs = 0;
@@ -706,21 +700,6 @@ get_process_info_r(struct system_info *si, struct process_select *sel,
}
lasttime = thistime;
- /* Round current time to a second. */
- now = (unsigned long) thistime.tv_sec;
- if (thistime.tv_usec >= 500000)
- now++;
-
- /* Calculate constants for the exponental average. */
- if (timediff > 0.0 && timediff < 30.0)
- {
- alpha = 0.5 * (timediff / 30.0);
- beta = 1.0 - alpha;
- }
- else
- {
- alpha = beta = 0.5;
- }
timediff *= HZ; /* Convert to ticks. */
connect_to_db(conninfo);
@@ -777,7 +756,6 @@ get_process_info_r(struct system_info *si, struct process_select *sel,
else
{
n->time = 0;
- n->wcpu = 0;
}
otime = n->time;
@@ -861,12 +839,7 @@ get_process_info_r(struct system_info *si, struct process_select *sel,
{
if ((n->pcpu = (n->time - otime) / timediff) < 0.0001)
n->pcpu = 0;
- n->wcpu = n->pcpu * alpha + n->wcpu * beta;
}
- else if ((elapsed = (now - boottime) * HZ - n->start_time) > 0)
- n->wcpu = n->pcpu;
- else
- n->wcpu = n->pcpu = 0.0;
if ((show_idle || n->pgstate != STATE_IDLE) &&
(sel->usename[0] == '\0' ||
diff --git a/pg_top.1.in b/pg_top.1.in
index 9085b82..16d949c 100644
--- a/pg_top.1.in
+++ b/pg_top.1.in
@@ -324,7 +324,7 @@ Elapsed time since the current transactions started.
.B QTIME
Elapsed time since the current query started.
.TP
-.B CPU
+.B %CPU
Percentage of available cpu time used by this process.
.TP
.B COMMAND