mirror of
http://git.haproxy.org/git/haproxy.git/
synced 2024-12-12 22:44:32 +00:00
MINOR: cli: displays uptime in show proc
Displays the uptime of the workers in `show proc`
This commit is contained in:
parent
e09cdc6d48
commit
e368330128
@ -212,6 +212,7 @@ struct mworker_proc {
|
||||
int ipc_fd[2]; /* 0 is master side, 1 is worker side */
|
||||
int relative_pid;
|
||||
int reloads;
|
||||
int timestamp;
|
||||
struct server *srv; /* the server entry in the master proxy */
|
||||
struct list list;
|
||||
};
|
||||
|
10
src/cli.c
10
src/cli.c
@ -1405,19 +1405,20 @@ static int cli_io_handler_show_proc(struct appctx *appctx)
|
||||
|
||||
chunk_reset(&trash);
|
||||
|
||||
chunk_printf(&trash, "#%-14s %-15s %-15s %-15s\n", "<PID>", "<type>", "<relative PID>", "<reloads>");
|
||||
chunk_appendf(&trash, "%-15u %-15s %-15u %-15s\n", getpid(), "master", 0, "-");
|
||||
chunk_printf(&trash, "#%-14s %-15s %-15s %-15s %s\n", "<PID>", "<type>", "<relative PID>", "<reloads>", "<uptime>");
|
||||
chunk_appendf(&trash, "%-15u %-15s %-15u %-15s %s\n", getpid(), "master", 0, "-", "-");
|
||||
|
||||
/* displays current processes */
|
||||
|
||||
chunk_appendf(&trash, "# workers\n");
|
||||
list_for_each_entry(child, &proc_list, list) {
|
||||
int up = now.tv_sec - child->timestamp;
|
||||
|
||||
if (child->reloads > 0) {
|
||||
old++;
|
||||
continue;
|
||||
}
|
||||
chunk_appendf(&trash, "%-15u %-15s %-15u %-15d\n", child->pid, "worker", child->relative_pid, child->reloads);
|
||||
chunk_appendf(&trash, "%-15u %-15s %-15u %-15d %dd %02dh%02dm%02ds\n", child->pid, "worker", child->relative_pid, child->reloads, up / 86400, (up % 86400) / 3600, (up % 3600) / 60, (up % 60));
|
||||
}
|
||||
|
||||
/* displays old processes */
|
||||
@ -1425,8 +1426,9 @@ static int cli_io_handler_show_proc(struct appctx *appctx)
|
||||
if (old) {
|
||||
chunk_appendf(&trash, "# old workers\n");
|
||||
list_for_each_entry(child, &proc_list, list) {
|
||||
int up = now.tv_sec - child->timestamp;
|
||||
if (child->reloads > 0)
|
||||
chunk_appendf(&trash, "%-15u %-15s %-15u %-15d\n", child->pid, "worker", child->relative_pid, child->reloads);
|
||||
chunk_appendf(&trash, "%-15u %-15s %-15u %-15d %dd %02dh%02dm%02ds\n", child->pid, "worker", child->relative_pid, child->reloads, up / 86400, (up % 86400) / 3600, (up % 3600) / 60, (up % 60));
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -541,9 +541,9 @@ static void mworker_proc_list_to_env()
|
||||
|
||||
list_for_each_entry(child, &proc_list, list) {
|
||||
if (msg)
|
||||
memprintf(&msg, "%s|type=worker;fd=%d;pid=%d;rpid=%d;reloads=%d", msg, child->ipc_fd[0], child->pid, child->relative_pid, child->reloads);
|
||||
memprintf(&msg, "%s|type=worker;fd=%d;pid=%d;rpid=%d;reloads=%d;timestamp=%d", msg, child->ipc_fd[0], child->pid, child->relative_pid, child->reloads, child->timestamp);
|
||||
else
|
||||
memprintf(&msg, "type=worker;fd=%d;pid=%d;rpid=%d;reloads=%d", child->ipc_fd[0], child->pid, child->relative_pid, child->reloads);
|
||||
memprintf(&msg, "type=worker;fd=%d;pid=%d;rpid=%d;reloads=%d;timestamp=%d", child->ipc_fd[0], child->pid, child->relative_pid, child->reloads, child->timestamp);
|
||||
}
|
||||
if (msg)
|
||||
setenv("HAPROXY_CHILDREN", msg, 1);
|
||||
@ -582,6 +582,8 @@ static void mworker_env_to_proc_list()
|
||||
} else if (strncmp(subtoken, "reloads=", 8) == 0) {
|
||||
/* we reloaded this process once more */
|
||||
child->reloads = atoi(subtoken+8) + 1;
|
||||
} else if (strncmp(subtoken, "timestamp=", 10) == 0) {
|
||||
child->timestamp = atoi(subtoken+10);
|
||||
}
|
||||
}
|
||||
if (child->pid)
|
||||
@ -1745,6 +1747,7 @@ static void init(int argc, char **argv)
|
||||
|
||||
tmproc->pid = -1;
|
||||
tmproc->reloads = 0;
|
||||
tmproc->timestamp = -1;
|
||||
tmproc->relative_pid = 1 + proc;
|
||||
tmproc->ipc_fd[0] = -1;
|
||||
tmproc->ipc_fd[1] = -1;
|
||||
@ -3018,6 +3021,7 @@ int main(int argc, char **argv)
|
||||
list_for_each_entry(child, &proc_list, list) {
|
||||
if (child->relative_pid == relative_pid &&
|
||||
child->reloads == 0) {
|
||||
child->timestamp = now.tv_sec;
|
||||
child->pid = ret;
|
||||
break;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user