[MINOR] stats: add a new node-name setting

The new "node-name" stats setting enables reporting of a node ID on
the stats page. It is possible to return the system's host name as
well as a specific name.
diff --git a/src/cfgparse.c b/src/cfgparse.c
index bd720c6..8b3d3f1 100644
--- a/src/cfgparse.c
+++ b/src/cfgparse.c
@@ -1725,7 +1725,7 @@
 			curproxy->uri_auth = NULL; /* we must detach from the default config */
 
 		if (*(args[1]) == 0) {
-			Alert("parsing [%s:%d] : '%s' expects 'uri', 'realm', 'auth', 'scope' or 'enable'.\n", file, linenum, args[0]);
+			Alert("parsing [%s:%d] : '%s' expects 'uri', 'realm', 'node-name', 'auth', 'scope' or 'enable'.\n", file, linenum, args[0]);
 			err_code |= ERR_ALERT | ERR_FATAL;
 			goto out;
 		} else if (!strcmp(args[1], "uri")) {
@@ -1748,6 +1748,12 @@
 				err_code |= ERR_ALERT | ERR_ABORT;
 				goto out;
 			}
+		} else if (!strcmp(args[1], "node-name")) {
+			if (!stats_set_node_name(&curproxy->uri_auth, *(args[2]) ? args[2] : hostname)) {
+				Alert("parsing [%s:%d] : out of memory.\n", file, linenum);
+				err_code |= ERR_ALERT | ERR_ABORT;
+				goto out;
+			}
 		} else if (!strcmp(args[1], "refresh")) {
 			unsigned interval;
 
diff --git a/src/dumpstats.c b/src/dumpstats.c
index 8452d3b..d7c5110 100644
--- a/src/dumpstats.c
+++ b/src/dumpstats.c
@@ -371,7 +371,7 @@
 		if (!(s->data_ctx.stats.flags & STAT_FMT_CSV)) {
 			/* WARNING! This must fit in the first buffer !!! */	    
 			chunk_printf(&msg, sizeof(trash),
-			     "<html><head><title>Statistics Report for " PRODUCT_NAME "</title>\n"
+			     "<html><head><title>Statistics Report for " PRODUCT_NAME "%s%s</title>\n"
 			     "<meta http-equiv=\"content-type\" content=\"text/html; charset=iso-8859-1\">\n"
 			     "<style type=\"text/css\"><!--\n"
 			     "body {"
@@ -443,7 +443,10 @@
 			     "table.lgd td { border-width: 1px; border-style: solid solid solid solid; border-color: gray; padding: 2px;}\n"
 			     "table.lgd td.noborder { border-style: none; padding: 2px; white-space: nowrap;}\n"
 			     "-->\n"
-			     "</style></head>\n");
+			     "</style></head>\n",
+			     uri->node_name ? " on " : "",
+			     uri->node_name ? uri->node_name : ""
+			     );
 		} else {
 			print_csv_header(&msg, sizeof(trash));
 		}
@@ -464,7 +467,7 @@
 			chunk_printf(&msg, sizeof(trash),
 			     "<body><h1><a href=\"" PRODUCT_URL "\" style=\"text-decoration: none;\">"
 			     PRODUCT_NAME "%s</a></h1>\n"
-			     "<h2>Statistics Report for pid %d</h2>\n"
+			     "<h2>Statistics Report for pid %d%s%s</h2>\n"
 			     "<hr width=\"100%%\" class=\"hr\">\n"
 			     "<h3>&gt; General process information</h3>\n"
 			     "<table border=0 cols=4><tr><td align=\"left\" nowrap width=\"1%%\">\n"
@@ -494,7 +497,8 @@
 			     "<b>Display option:</b><ul style=\"margin-top: 0.25em;\">"
 			     "",
 			     (uri->flags&ST_HIDEVER)?"":(STATS_VERSION_STRING),
-			     pid, pid,
+			     pid, uri->node_name ? " on " : "", uri->node_name ? uri->node_name : "",
+			     pid,
 			     relative_pid, global.nbproc,
 			     up / 86400, (up % 86400) / 3600,
 			     (up % 3600) / 60, (up % 60),
diff --git a/src/uri_auth.c b/src/uri_auth.c
index 67e237a..ba029a6 100644
--- a/src/uri_auth.c
+++ b/src/uri_auth.c
@@ -110,6 +110,31 @@
 }
 
 /*
+ * Returns a default uri_auth with <node-name> set as the node name.
+ * Uses the pointer provided if not NULL and not initialized.
+ */
+struct uri_auth *stats_set_node_name(struct uri_auth **root, char *name)
+{
+	struct uri_auth *u;
+	char *name_copy;
+
+	if ((name_copy = strdup(name)) == NULL)
+		goto out_realm;
+	
+	if ((u = stats_check_init_uri_auth(root)) == NULL)
+		goto out_u;
+	
+	free(u->node_name);
+	u->node_name = name_copy;
+	return u;
+
+ out_u:
+	free(name_copy);
+ out_realm:
+	return NULL;
+}
+
+/*
  * Returns a default uri_auth with the <refresh> refresh interval.
  * Uses the pointer provided if not NULL and not initialized.
  */