[master] 480da50 varnishhist -P: make graph boundary parameters optional

Nils Goroll nils.goroll at uplex.de
Mon Mar 26 11:02:13 UTC 2018


commit 480da504f9fe623be1e38dd4da7ec34fb8421e67
Author: Nils Goroll <nils.goroll at uplex.de>
Date:   Wed Mar 21 15:00:02 2018 +0100

    varnishhist -P: make graph boundary parameters optional

diff --git a/bin/varnishhist/varnishhist.c b/bin/varnishhist/varnishhist.c
index 27d3174..b33f5ce 100644
--- a/bin/varnishhist/varnishhist.c
+++ b/bin/varnishhist/varnishhist.c
@@ -549,9 +549,14 @@ main(int argc, char **argv)
 				    "-P: '%s' is not a valid tag name",
 				    optarg);
 
+			if (VSL_tagflags[match_tag])
+				VUT_Error(vut, 1,
+				    "-P: '%s' is an unsafe or binary record",
+				    optarg);
+
 			cli_p.prefix = colon + 1;
-			colon = strchr(colon + 1, ':');
 
+			colon = strchr(colon + 1, ':');
 			if (colon == NULL)
 				profile_error(optarg);
 
@@ -559,20 +564,24 @@ main(int argc, char **argv)
 			if (*cli_p.prefix == '\0')
 				cli_p.prefix = NULL;
 
-			if (sscanf(colon + 1, "%d:%d:%d", &cli_p.field,
-			    &cli_p.hist_low, &cli_p.hist_high) != 3)
+			if (sscanf(colon + 1, "%d",  &cli_p.field) != 1)
 				profile_error(optarg);
 
-			if (VSL_tagflags[match_tag])
-				VUT_Error(vut, 1,
-				    "-P: '%s' is an unsafe or binary record",
-				    optarg);
-
 			cli_p.name = "custom";
 			cli_p.tag = match_tag;
+			cli_p.hist_low = -6;
+			cli_p.hist_high = 3;
 			profile = NULL;
 			active_profile = &cli_p;
 
+			colon = strchr(colon + 1, ':');
+			if (colon == NULL)
+				break;
+
+			if (sscanf(colon + 1, "%d:%d",  &cli_p.hist_low,
+				   &cli_p.hist_high) != 2)
+				profile_error(optarg);
+
 			break;
 		case 'B':
 			timebend = strtod(optarg, NULL);
diff --git a/bin/varnishhist/varnishhist_options.h b/bin/varnishhist/varnishhist_options.h
index 999a678..0c04278 100644
--- a/bin/varnishhist/varnishhist_options.h
+++ b/bin/varnishhist/varnishhist_options.h
@@ -47,14 +47,15 @@
 	)
 
 #define HIS_OPT_P							\
-	VOPT("P:", "[-P <[cb:]tag:[prefix]:field_num:min:max>]",	\
+	VOPT("P:", "[-P <[cb:]tag:[prefix]:field_num[:min:max]>]",	\
 	    "Custom profile definition",				\
 	    "Graph the given custom definition defined as: an optional" \
 	    " (c)lient or (b)ackend filter (defaults to client), the"	\
 	    " tag we'll look for, a prefix to look for (can be empty,"	\
 	    " but must be terminated by a colon) and the field number"	\
 	    " of the value we are interested in. min and max are the"	\
-	    " boundaries of the graph (these are power of ten)."	\
+	    " boundaries of the graph in power of ten and default to"	\
+	    " -6 and 3."						\
 	)
 
 #define HIS_OPT_B							\


More information about the varnish-commit mailing list