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.
diff --git a/doc/management.txt b/doc/management.txt
index 7cc1d75..616a040 100644
--- a/doc/management.txt
+++ b/doc/management.txt
@@ -2612,13 +2612,13 @@
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
diff --git a/include/types/global.h b/include/types/global.h
index 5fca648..f9ab4c2 100644
--- a/include/types/global.h
+++ b/include/types/global.h
@@ -208,6 +208,7 @@
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;
diff --git a/src/haproxy.c b/src/haproxy.c
index c9370a3..0c1d5a2 100644
--- a/src/haproxy.c
+++ b/src/haproxy.c
@@ -3039,6 +3039,7 @@
child->reloads == 0 && child->options & PROC_O_TYPE_WORKER) {
child->timestamp = now.tv_sec;
child->pid = ret;
+ child->version = strdup(haproxy_version);
break;
}
}
diff --git a/src/mworker.c b/src/mworker.c
index cd88723..6a4f1f5 100644
--- a/src/mworker.c
+++ b/src/mworker.c
@@ -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 @@
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 @@
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 @@
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 @@
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 @@
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 @@
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 @@
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 @@
free(child->id);
child->id = NULL;
}
+ if (child->version) {
+ free(child->version);
+ child->version = NULL;
+ }
free(child);
}