Skip to content

Commit

Permalink
document --95th as command line option for the 95th percentile output…
Browse files Browse the repository at this point in the history
… instead of --95% to avoid possible issues in environments where % is considered a special character, both --95% and --95 are still kept as undocumented alternatives
  • Loading branch information
vergoh committed Jan 15, 2024
1 parent 37ad210 commit 52a71f2
Show file tree
Hide file tree
Showing 6 changed files with 14 additions and 18 deletions.
2 changes: 1 addition & 1 deletion CHANGES
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
- Using --nodaemon and --initdb at the same time didn't result in an error
being shown
- New
- Add 95th percentile output as --95%, also available via --alert, --json,
- Add 95th percentile output as --95th, also available via --alert, --json,
--xml and image output, requires 5MinuteHours configuration to be set to
at least 744 for storing all the necessary data
- Add --json support for --alert
Expand Down
6 changes: 3 additions & 3 deletions examples/vnstat.cgi
Original file line number Diff line number Diff line change
Expand Up @@ -365,13 +365,13 @@ sub main
handle_image($interfaces[$1], "$tmp_dir/vnstat_$1_y_l.png", "-y 0");
}
elsif ($query =~ /^(\d+)-95rx$/) {
handle_image($interfaces[$1], "$tmp_dir/vnstat_$1_95rx.png", "--95 0");
handle_image($interfaces[$1], "$tmp_dir/vnstat_$1_95rx.png", "--95th 0");
}
elsif ($query =~ /^(\d+)-95tx$/) {
handle_image($interfaces[$1], "$tmp_dir/vnstat_$1_95tx.png", "--95 1");
handle_image($interfaces[$1], "$tmp_dir/vnstat_$1_95tx.png", "--95th 1");
}
elsif ($query =~ /^(\d+)-95total$/) {
handle_image($interfaces[$1], "$tmp_dir/vnstat_$1_95total.png", "--95 2");
handle_image($interfaces[$1], "$tmp_dir/vnstat_$1_95total.png", "--95th 2");
}
elsif ($query =~ /^(\d+)-f$/) {
print_single_interface_html($1);
Expand Down
8 changes: 3 additions & 5 deletions man/vnstat.1
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ vnstat \- a console-based network traffic monitor

.B vnstat
.RB [ \-5bDedhlmqstvy? ]
.RB [ \-\-95% ]
.RB [ \-\-95th ]
.RB [ \-\-add ]
.RB [ \-\-alert
.IR "output exit type condition limit unit" ]
Expand Down Expand Up @@ -105,16 +105,14 @@ time sleeping between data updates.
.SH OPTIONS

.TP
.B "--95%"
.B "--95th"
Show 95th percentile output for the ongoing month. This output uses the 5 minute resolution
data of the ongoing month to calculate the 95th percentile traffic rate for received, transmitted
and total. In addition, the minimum, average and maximum traffic rates for received, transmitted
and total are also shown. This output requires the
.B 5MinuteHours
configuration option to have a value of at least 744 for storing all the necessary data, otherwise 100% coverage
isn't possible. This option can also be used as
.B "--95"
with the % being optional.
isn't possible.

.TP
.B "--add"
Expand Down
8 changes: 3 additions & 5 deletions man/vnstati.1
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ vnstati \- image output support for vnStat

.B vnstati
.RB [ \-5bcdDehiLmosStvy? ]
.RB [ \-\-95%
.RB [ \-\-95th
.IR mode ]
.RB [ \-5g
.RI [ limit ]
Expand Down Expand Up @@ -103,7 +103,7 @@ with the later being limited to png image format.
.SH OPTIONS

.TP
.BI "--95% " mode
.BI "--95th " mode
Show 95th percentile output graph for the ongoing month. This output uses the 5 minute resolution
data of the ongoing month to calculate the 95th percentile traffic rate for received, transmitted
or total as selected using the mandatory
Expand All @@ -115,9 +115,7 @@ resolution traffic rate bar graph averaged from the 5 minute resolution data of
is presented. This output requires the
.B 5MinuteHours
configuration option to have a value of at least 744 for storing all the necessary data, otherwise 100% coverage
isn't possible. Available modes: 0 = received, 1 = transmitted, 2 = total. This option can also be used as
.B "--95"
with the % being optional.
isn't possible. Available modes: 0 = received, 1 = transmitted, 2 = total.

.TP
.B "--altdate"
Expand Down
4 changes: 2 additions & 2 deletions src/vnstat_func.c
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ void showhelp(const PARAMS *p)
printf(" -b, --begin <date> set list begin date\n");
printf(" -e, --end <date> set list end date\n\n");

printf(" --95%% show 95th percentile\n");
printf(" --95th show 95th percentile\n");
printf(" --oneline [mode] show simple parsable format\n");
printf(" --json [mode] [limit] show database in json format\n");
printf(" --xml [mode] [limit] show database in xml format\n");
Expand Down Expand Up @@ -328,7 +328,7 @@ void parseargs(PARAMS *p, const int argc, char **argv)
}
currentarg++;
}
} else if ((strcmp(argv[currentarg], "--95") == 0) || (strcmp(argv[currentarg], "--95%") == 0) || (strcmp(argv[currentarg], "--95th") == 0)) {
} else if ((strcmp(argv[currentarg], "--95th") == 0) || (strcmp(argv[currentarg], "--95") == 0) || (strcmp(argv[currentarg], "--95%") == 0)) {
cfg.qmode = 13;
} else if (strcmp(argv[currentarg], "--oneline") == 0) {
cfg.qmode = 9;
Expand Down
4 changes: 2 additions & 2 deletions src/vnstati.c
Original file line number Diff line number Diff line change
Expand Up @@ -128,7 +128,7 @@ void showihelp(const IPARAMS *p)
printf(" -s, --summary output summary\n");
printf(" -hs, --hsummary [graph] output horizontal summary with graph\n");
printf(" -vs, --vsummary [graph] output vertical summary with graph\n");
printf(" --95%% <mode> output 95th percentile graph\n\n");
printf(" --95th <mode> output 95th percentile graph\n\n");

printf(" -nh, --noheader remove header from output\n");
printf(" -ne, --noedge remove edge from output\n");
Expand Down Expand Up @@ -443,7 +443,7 @@ void parseargs(IPARAMS *p, IMAGECONTENT *ic, int argc, char **argv)
printf("Summary graph changed: %d\n", cfg.summarygraph);
currentarg++;
}
} else if ((strcmp(argv[currentarg], "--95") == 0) || (strcmp(argv[currentarg], "--95%") == 0) || (strcmp(argv[currentarg], "--95th") == 0)) {
} else if ((strcmp(argv[currentarg], "--95th") == 0) || (strcmp(argv[currentarg], "--95") == 0) || (strcmp(argv[currentarg], "--95%") == 0)) {
cfg.qmode = 130;
if (currentarg + 1 < argc && (strlen(argv[currentarg + 1]) == 1 || ishelprequest(argv[currentarg + 1]))) {
if (!isdigit(argv[currentarg + 1][0]) || atoi(argv[currentarg + 1]) > 2 || atoi(argv[currentarg + 1]) < 0) {
Expand Down

0 comments on commit 52a71f2

Please sign in to comment.