...
 
Commits (15)
Change log for ethstats, the network traffic statistics utility
1.2.1 2018/05/17
- fix a bashism in the check for feature-check
- use single quotes and "--" in shell commands in the Makefile
1.2.0 2018/05/17
- fix a Perl 6 bug: allow the ".", "/", and "-" characters in
an interface name
- allow the program to be run directly during the tests
- add the "--help" and "--version" long options
- add the "--features" long option
1.1.1 2015/12/28
- fix a grave bug I introduced in 1.1.0: get the correct value
for the number of packets sent out on an interface
......
......@@ -4,7 +4,7 @@ SCRIPT= ethstats
SRC= ethstats.pl
MAN1= ${SCRIPT}.1
MAN1GZ= ${MAN1}.gz
TEST_SCRIPT?= ${SCRIPT}
TEST_SCRIPT?= ./${SCRIPT}
GZIP?= gzip -cn
INSTALL?= install
......@@ -33,41 +33,59 @@ INSTALL_SCRIPT?= ${INSTALL} ${COPY} -o ${BINOWN} -g ${BINGRP} -m ${BINMODE}
all: ${SCRIPT} ${MAN1GZ}
clean:
${RM} ${SCRIPT} ${MAN1GZ}
${RM} -- '${SCRIPT}' '${MAN1GZ}'
install: all
${MKDIR} ${DESTDIR}${BINDIR}
${INSTALL_SCRIPT} ${SCRIPT} ${DESTDIR}${BINDIR}/
${MKDIR} ${DESTDIR}${MANDIR}1
${INSTALL_SCRIPT} ${MAN1GZ} ${DESTDIR}${MANDIR}1/
${MKDIR} -- '${DESTDIR}${BINDIR}'
${INSTALL_SCRIPT} -- '${SCRIPT}' '${DESTDIR}${BINDIR}/'
${MKDIR} -- '${DESTDIR}${MANDIR}1'
${INSTALL_SCRIPT} -- '${MAN1GZ}' '${DESTDIR}${MANDIR}1/'
test: all
@echo "=== Perl syntax check"
${PERL} -c ${TEST_SCRIPT}
@echo '=== Perl syntax check'
'${PERL}' -c '${TEST_SCRIPT}'
@echo "=== Basic version/usage functionality"
${PERL} ${TEST_SCRIPT} -V -h
@echo '=== Basic version/usage functionality'
'${TEST_SCRIPT}' -V -h
@echo
@echo "=== Error out on invalid options"
! ${PERL} ${TEST_SCRIPT} -X
@echo '=== Long options for version and usage'
'${TEST_SCRIPT}' --version
'${TEST_SCRIPT}' --help
@echo '=== The features long option'
'${TEST_SCRIPT}' --features
'${TEST_SCRIPT}' --features | fgrep -qe ' ethstats='
if feature-check feature-check feature-check 2>/dev/null; then \
echo '=== Feature checks'; \
feature-check -l -- '${TEST_SCRIPT}'; \
feature-check -- '${TEST_SCRIPT}' ethstats; \
feature-check -- '${TEST_SCRIPT}' ethstats ge 1; \
feature-check -- '${TEST_SCRIPT}' 'ethstats lt 1000'; \
else \
echo '=== Skipping the feature checks - the feature-check tool does not seem to be installed'; \
fi
@echo '=== Error out on invalid options'
! '${TEST_SCRIPT}' -X
! '${TEST_SCRIPT}' --whee
@echo
@if [ -r "/proc/net/dev" ]; then \
echo "=== A single run"; \
${PERL} ${TEST_SCRIPT} -n3 -c2; \
@if [ -r '/proc/net/dev' ]; then \
echo '=== A single run'; \
'${TEST_SCRIPT}' -n3 -c2; \
else \
echo "=== Skipping the single run"; \
echo '=== Skipping the single run'; \
fi
@echo
test-p6:
${MAKE} TEST_SCRIPT=ethstats.p6 PERL=perl6 test
${MAKE} TEST_SCRIPT=./ethstats.p6 PERL=perl6 test
${SCRIPT}: ${SRC}
${INSTALL_EXEC} ${SRC} ${SCRIPT}
${INSTALL_EXEC} -- '${SRC}' '${SCRIPT}'
${MAN1GZ}: ${MAN1}
${GZIP} ${MAN1} > ${MAN1GZ} || (${RM} ${MAN1GZ}; false)
${GZIP} -- '${MAN1}' > '${MAN1GZ}' || (${RM} -- '${MAN1GZ}'; false)
.PHONY: all clean install test
ethstats (1.1.1-4) UNRELEASED; urgency=medium
ethstats (1.2.1-1) UNRELEASED; urgency=medium
* Use my Debian e-mail address.
* Declare compliance with Debian Policy 4.1.4 with no changes.
* Drop an empty line at the end of the changelog file.
* Add a trivial autopkgtest running adequate on the installed package.
* Use the B-D: debhelper-compat (= 11) mechanism.
* New upstream release, add the feature-check tool to the build and
test dependencies.
-- Peter Pentchev <roam@debian.org> Thu, 17 May 2018 00:06:12 +0300
......
......@@ -3,7 +3,7 @@ Section: net
Priority: optional
Maintainer: Peter Pentchev <roam@debian.org>
Build-Depends: debhelper-compat (= 11)
Build-Depends-Indep: perl
Build-Depends-Indep: perl, feature-check
Standards-Version: 4.1.4
Homepage: https://devel.ringlet.net/net/ethstats/
Vcs-Git: https://gitlab.com/ethstats/ethstats.git -b debian
......
Test-Command: env TEST_SCRIPT='/usr/bin/ethstats' make test
Depends: @, make
Depends: @, feature-check, make
Restrictions: allow-stderr
Test-Command: adequate ethstats
......
......@@ -10,16 +10,23 @@ use strict;
use Getopt::Tiny;
use Terminal::ANSIColor;
constant VERSION = '1.2.1';
sub version()
{
say 'ethstats 1.1.1';
say 'ethstats ' ~ VERSION;
}
sub features()
{
say 'Features: ethstats=' ~ VERSION;
}
sub usage(Bool:D $err = True)
{
my $s = q:to/EOUSAGE/;
Usage: ethstats [-t] [-C | -M] [-c count] [-i iface] [-n period]
ethstats -V | -h
ethstats -V | --version | -h | --help
-C color the "total" line in the output
-c exit after the specified number of samples
......@@ -131,7 +138,7 @@ grammar Interfaces {
rule in {<bytes> <packets> <errs> <drop> <fifo> <frame> <compressed> <multicast>}
rule out {<bytes> <packets> <errs> <drop> <fifo> <colls> <carrier> <compressed>}
token iface { \w+ }
token iface { <[ \w . / - ]>+ }
token bytes { <uint> }
token packets { <uint> }
......@@ -212,6 +219,18 @@ sub convert(Str $iface, UInt:D $period, InterfaceStats:D $total)
$opts.bool('h', Nil, -> $v { %flags<h> = $v });
$opts.bool('V', Nil, -> $v { %flags<V> = $v });
$opts.str('-', Nil, -> $v {
given $v {
when 'help' { %flags<h> = True }
when 'version' { %flags<V> = True }
when 'features' { %flags<features> = True }
default {
note "Invalid long option '$v'";
usage;
}
}
});
my Bool $addtime = False;
$opts.bool('t', Nil, -> $v { $addtime = $v; });
......@@ -259,10 +278,13 @@ sub convert(Str $iface, UInt:D $period, InterfaceStats:D $total)
if %flags<V> {
version;
}
if %flags<features> {
features;
}
if %flags<h> {
usage False;
}
if %flags<V> || %flags<h> {
if %flags<V> || %flags<features> || %flags<h> {
exit 0;
}
......
......@@ -14,7 +14,7 @@ use v5.010;
use strict;
use warnings;
use version; our $VERSION = version->declare("1.1.1");
use version; our $VERSION = version->declare("1.2.1");
use Getopt::Std;
......@@ -33,7 +33,7 @@ sub usage($)
my ($err) = @_;
my $s = <<EOUSAGE
Usage: ethstats [-t] [-C | -M] [-c count] [-i iface] [-n period]
ethstats -V | -h
ethstats -V | --version | -h | --help
-C color the "total" line in the output
-c exit after the specified number of samples
......@@ -58,6 +58,11 @@ sub version()
say "ethstats $main::VERSION";
}
sub features()
{
say "Features: ethstats=$main::VERSION";
}
sub format_line($ $)
{
my ($name, $dev) = @_;
......@@ -154,10 +159,27 @@ MAIN:
my $period = 10;
my %opts;
getopts 'Cc:hi:Mn:tV', \%opts or usage(1);
version if $opts{V};
usage 0 if $opts{h};
exit 0 if $opts{V} || $opts{h};
getopts 'Cc:hi:Mn:tV-:', \%opts or usage(1);
my $Vflag = $opts{V} || ($opts{'-'} // '') eq 'version';
my $hflag = $opts{h};
my $featuresflag;
my $dash = $opts{'-'};
if (defined $dash) {
if ($dash eq 'version') {
$Vflag = 1;
} elsif ($dash eq 'help') {
$hflag = 1;
} elsif ($dash eq 'features') {
$featuresflag = 1;
} else {
warn "Invalid long option '$dash'\n";
usage 1;
}
}
version if $Vflag;
features if $featuresflag;
usage 0 if $hflag;
exit 0 if $Vflag || $featuresflag || $hflag;
my $addtime = $opts{t};
if (defined $opts{n}) {
......