[MEDIUM] stats: add the "get weight" command to report a server's weight

This command is unrestricted and simply reports a server's weight, as
well as the weight initially configured, which at the moment are the
sames.
diff --git a/doc/configuration.txt b/doc/configuration.txt
index 8386e6f..82b73b3 100644
--- a/doc/configuration.txt
+++ b/doc/configuration.txt
@@ -6870,6 +6870,12 @@
   server. This has the same effect as restarting. This command is restricted
   and can only be issued on sockets configured for level "admin".
 
+get weight <backend>/<server>
+  Report the current weight and the initial weight of server <server> in
+  backend <backend> or an error if either doesn't exist. The initial weight is
+  the one that appears in the configuration file. Both are normally equal
+  unless the current weight has been changed.
+
 
 /*
  * Local variables:
diff --git a/src/dumpstats.c b/src/dumpstats.c
index dcbccf7..e576b12 100644
--- a/src/dumpstats.c
+++ b/src/dumpstats.c
@@ -62,6 +62,7 @@
 	"  show stat      : report counters for each proxy and server\n"
 	"  show errors    : report last request and response errors for each proxy\n"
 	"  show sess      : report the list of current sessions\n"
+	"  get weight     : report a server's current weight\n"
 	"";
 
 const char stats_permission_denied_msg[] =
@@ -377,7 +378,41 @@
 			return 0;
 		}
 	}
-	else { /* not "show" nor "clear"*/
+	else if (strcmp(args[0], "get") == 0) {
+		if (strcmp(args[1], "weight") == 0) {
+			struct proxy *px;
+			struct server *sv;
+
+			/* split "backend/server" and make <line> point to server */
+			for (line = args[2]; *line; line++)
+				if (*line == '/') {
+					*line++ = '\0';
+					break;
+				}
+
+			if (!*line) {
+				buffer_feed(si->ib, "Require 'backend/server'.\n");
+				return 1;
+			}
+
+			if (!get_backend_server(args[2], line, &px, &sv)) {
+				if (!px)
+					buffer_feed(si->ib, "No such backend.\n");
+				else
+					buffer_feed(si->ib, "No such server.\n");
+				return 1;
+			}
+
+			/* return server's effective weight at the moment */
+			snprintf(trash, sizeof(trash), "%d (initial %d)\n", sv->uweight, sv->iweight);
+			buffer_feed(si->ib, trash);
+			return 1;
+		}
+		else { /* not "get weight" */
+			return 0;
+		}
+	}
+	else { /* not "show" nor "clear" nor "get" */
 		return 0;
 	}
 	return 1;