MINOR: mworker: add the HAProxy version in "show proc"
Displays the HAProxy version so you can compare the version of old processes and new ones.
This commit is contained in:
parent
e8669fc9db
commit
1dc6963086
|
@ -2612,13 +2612,13 @@ processes:
|
|||
Example:
|
||||
|
||||
$ echo 'show proc' | socat /var/run/haproxy-master.sock -
|
||||
#<PID> <type> <relative PID> <reloads> <uptime>
|
||||
1162 master 0 5 0d 00h02m07s
|
||||
#<PID> <type> <relative PID> <reloads> <uptime> <version>
|
||||
1162 master 0 5 0d00h02m07s 2.0-dev7-0124c9-7
|
||||
# workers
|
||||
1271 worker 1 0 0d 00h00m00s
|
||||
1272 worker 2 0 0d 00h00m00s
|
||||
1271 worker 1 0 0d00h00m00s 2.0-dev7-0124c9-7
|
||||
1272 worker 2 0 0d00h00m00s 2.0-dev7-0124c9-7
|
||||
# old workers
|
||||
1233 worker [was: 1] 3 0d 00h00m43s
|
||||
1233 worker [was: 1] 3 0d00h00m43s 2.0-dev3-6019f6-289
|
||||
|
||||
|
||||
In this example, the master has been reloaded 5 times but one of the old
|
||||
|
|
|
@ -208,6 +208,7 @@ struct mworker_proc {
|
|||
char *id;
|
||||
char **command;
|
||||
char *path;
|
||||
char *version;
|
||||
int ipc_fd[2]; /* 0 is master side, 1 is worker side */
|
||||
int relative_pid;
|
||||
int reloads;
|
||||
|
|
|
@ -3039,6 +3039,7 @@ int main(int argc, char **argv)
|
|||
child->reloads == 0 && child->options & PROC_O_TYPE_WORKER) {
|
||||
child->timestamp = now.tv_sec;
|
||||
child->pid = ret;
|
||||
child->version = strdup(haproxy_version);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -20,6 +20,7 @@
|
|||
#include <common/cfgparse.h>
|
||||
#include <common/initcall.h>
|
||||
#include <common/mini-clist.h>
|
||||
#include <common/version.h>
|
||||
|
||||
#include <types/cli.h>
|
||||
#include <types/global.h>
|
||||
|
@ -121,7 +122,7 @@ void mworker_proc_list_to_env()
|
|||
type = 'w';
|
||||
|
||||
if (child->pid > -1)
|
||||
memprintf(&msg, "%s|type=%c;fd=%d;pid=%d;rpid=%d;reloads=%d;timestamp=%d;id=%s", msg ? msg : "", type, child->ipc_fd[0], child->pid, child->relative_pid, child->reloads, child->timestamp, child->id ? child->id : "");
|
||||
memprintf(&msg, "%s|type=%c;fd=%d;pid=%d;rpid=%d;reloads=%d;timestamp=%d;id=%s;version=%s", msg ? msg : "", type, child->ipc_fd[0], child->pid, child->relative_pid, child->reloads, child->timestamp, child->id ? child->id : "", child->version);
|
||||
}
|
||||
if (msg)
|
||||
setenv("HAPROXY_PROCESSES", msg, 1);
|
||||
|
@ -177,6 +178,8 @@ void mworker_env_to_proc_list()
|
|||
child->timestamp = atoi(subtoken+10);
|
||||
} else if (strncmp(subtoken, "id=", 3) == 0) {
|
||||
child->id = strdup(subtoken+3);
|
||||
} else if (strncmp(subtoken, "version=", 8) == 0) {
|
||||
child->version = strdup(subtoken+8);
|
||||
}
|
||||
}
|
||||
if (child->pid) {
|
||||
|
@ -444,9 +447,9 @@ static int cli_io_handler_show_proc(struct appctx *appctx)
|
|||
|
||||
chunk_reset(&trash);
|
||||
|
||||
chunk_printf(&trash, "#%-14s %-15s %-15s %-15s %-15s\n", "<PID>", "<type>", "<relative PID>", "<reloads>", "<uptime>");
|
||||
chunk_printf(&trash, "#%-14s %-15s %-15s %-15s %-15s %-15s\n", "<PID>", "<type>", "<relative PID>", "<reloads>", "<uptime>", "<version>");
|
||||
memprintf(&uptime, "%dd%02dh%02dm%02ds", up / 86400, (up % 86400) / 3600, (up % 3600) / 60, (up % 60));
|
||||
chunk_appendf(&trash, "%-15u %-15s %-15u %-15d %-15s\n", getpid(), "master", 0, proc_self->reloads, uptime);
|
||||
chunk_appendf(&trash, "%-15u %-15s %-15u %-15d %-15s %-15s\n", getpid(), "master", 0, proc_self->reloads, uptime, haproxy_version);
|
||||
free(uptime);
|
||||
uptime = NULL;
|
||||
|
||||
|
@ -464,7 +467,7 @@ static int cli_io_handler_show_proc(struct appctx *appctx)
|
|||
continue;
|
||||
}
|
||||
memprintf(&uptime, "%dd%02dh%02dm%02ds", up / 86400, (up % 86400) / 3600, (up % 3600) / 60, (up % 60));
|
||||
chunk_appendf(&trash, "%-15u %-15s %-15u %-15d %-15s\n", child->pid, "worker", child->relative_pid, child->reloads, uptime);
|
||||
chunk_appendf(&trash, "%-15u %-15s %-15u %-15d %-15s %-15s\n", child->pid, "worker", child->relative_pid, child->reloads, uptime, child->version);
|
||||
free(uptime);
|
||||
uptime = NULL;
|
||||
}
|
||||
|
@ -484,7 +487,7 @@ static int cli_io_handler_show_proc(struct appctx *appctx)
|
|||
if (child->options & PROC_O_LEAVING) {
|
||||
memprintf(&msg, "[was: %u]", child->relative_pid);
|
||||
memprintf(&uptime, "%dd%02dh%02dm%02ds", up / 86400, (up % 86400) / 3600, (up % 3600) / 60, (up % 60));
|
||||
chunk_appendf(&trash, "%-15u %-15s %-15s %-15d %-15s\n", child->pid, "worker", msg, child->reloads, uptime);
|
||||
chunk_appendf(&trash, "%-15u %-15s %-15s %-15d %-15s %-15s\n", child->pid, "worker", msg, child->reloads, uptime, child->version);
|
||||
free(uptime);
|
||||
uptime = NULL;
|
||||
}
|
||||
|
@ -506,7 +509,7 @@ static int cli_io_handler_show_proc(struct appctx *appctx)
|
|||
continue;
|
||||
}
|
||||
memprintf(&uptime, "%dd%02dh%02dm%02ds", up / 86400, (up % 86400) / 3600, (up % 3600) / 60, (up % 60));
|
||||
chunk_appendf(&trash, "%-15u %-15s %-15s %-15d %-15s\n", child->pid, child->id, "-", child->reloads, uptime);
|
||||
chunk_appendf(&trash, "%-15u %-15s %-15s %-15d %-15s %-15s\n", child->pid, child->id, "-", child->reloads, uptime, "-");
|
||||
free(uptime);
|
||||
uptime = NULL;
|
||||
}
|
||||
|
@ -521,7 +524,7 @@ static int cli_io_handler_show_proc(struct appctx *appctx)
|
|||
|
||||
if (child->options & PROC_O_LEAVING) {
|
||||
memprintf(&uptime, "%dd%02dh%02dm%02ds", up / 86400, (up % 86400) / 3600, (up % 3600) / 60, (up % 60));
|
||||
chunk_appendf(&trash, "%-15u %-15s %-15s %-15d %-15s\n", child->pid, child->id, "-", child->reloads, uptime);
|
||||
chunk_appendf(&trash, "%-15u %-15s %-15s %-15d %-15s %-15s\n", child->pid, child->id, "-", child->reloads, uptime, "-");
|
||||
free(uptime);
|
||||
uptime = NULL;
|
||||
}
|
||||
|
@ -599,6 +602,10 @@ void mworker_free_child(struct mworker_proc *child)
|
|||
free(child->id);
|
||||
child->id = NULL;
|
||||
}
|
||||
if (child->version) {
|
||||
free(child->version);
|
||||
child->version = NULL;
|
||||
}
|
||||
free(child);
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue