long options, better example

pull/89/merge
David Schweikert 8 years ago
parent bab585e9fa
commit d18ad321de

@ -1,28 +1,37 @@
Unreleased
* INCOMPATIBILITY WARNING:
2017-02-13 David Schweikert <david@schweikert.ch>
* Version 4.0-rc1
* INCOMPATIBILITY WARNING 1:
fping and fping6 are now unified into one binary. It means that, for
example, doing 'fping www.google.com' is going to ping the IPv6 IP of
www.google.com on IPv6-enabled hosts.
example, doing 'fping google.com' is going to ping the IPv6 IP of
google.com on IPv6-enabled hosts.
If you need exact compatibility with old versions, you can configure,
compile, and install fping twice: once for ipv4 and once for ipv6:
If you need exact compatibility with old versions, you can configure
and install fping twice: once for ipv4, and once for ipv6:
- ./configure --disable-ipv6; make clean install
- ./configure --disable-ipv4 --program-suffix=6; make clean install
Or, alternatively, you could write two wrappers 'fping' and 'fping6',
that set respectively the options '-4' and '-6' when calling the original
fping binary.
* INCOMPATIBILITY WARNING 2:
Option -n / --name is now doing a reverse-DNS lookups on host addresses,
only they are given as IP address, but not for hostnames. For example, if
you write 'fping -n google.com', fping would previously do a forward-DNS
lookup on google.com, and then a reverse-DNS lookup on the resolved IP
address. Now, it is just going to keep the name 'google.com'. That same
behavior can be achieved with the option -d / --rdns (which was previously
an alias for -n).
fping<4.0 fping>=4.0
fping -n NAME NAME->IP->IPNAME NAME
fping -d NAME NAME->IP->IPNAME NAME->IP->IPNAME
* Version 4.0
* (feature) Unified 'fping' and 'fping6' into one binary (#80)
* (feature) Long option names for all options
* (feature) --enable-ipv6 is now default
* (feature) New option -4 to force IPv4
* (feature) New option -6 to force IPv6
* (feature) Keep original name if a hostname is given with -n/--name
* (feature) New option -X/--rdns, similar to -n/--name, but which always
does a rdns-lookup, even for names (name->IP->name), as '-n'
was doing until now
* (feature) Option -d/--rdns now always does a rdns-lookup, even for names
(name->IP->name), as '-n' was doing until now
* (bugfix) Fix compatibility issue with GNU Hurd
* (other) A C99 compiler is now required
* (other) Option parsing with optparse (https://github.com/skeeto/optparse)

@ -3,7 +3,7 @@ dnl Process this file with autoconf to produce a configure script.
dnl Minimum Autoconf version required.
AC_PREREQ(2.59)
AC_INIT([fping],[3.16-rc2])
AC_INIT([fping],[4.0-rc1])
dnl --disable-ipv4
AC_ARG_ENABLE([ipv4],

@ -25,24 +25,24 @@ output is designed to be easy to parse.
=over 5
=item B<-4>
=item B<-4>, B<--ipv4>
Restrict name resolution and IPs to IPv4 addresses.
=item B<-6>
=item B<-6>, B<--ipv6>
Restrict name resolution and IPs to IPv6 addresses.
=item B<-a>
=item B<-a>, B<--alive>
Show systems that are alive.
=item B<-A>
=item B<-A>, B<--addr>
Display targets by address rather than DNS name. Combined with -d, the output
will be both the ip and (if available) the hostname.
=item B<-b> I<n>
=item B<-b>, B<--size>=I<BYTES>
Number of bytes of ping data to send. The minimum size (normally 12) allows
room for the data that B<fping> needs to do its work (sequence number,
@ -52,7 +52,7 @@ Default is 56, as in B<ping>. Maximum is the theoretical maximum IP datagram
size (64K), though most systems limit this to a smaller, system-dependent
number.
=item B<-B> I<n>
=item B<-B>, B<--backoff>=I<N>
Backoff factor. In the default mode, B<fping> sends several requests to a
target before giving up, waiting longer for a reply on each successive request.
@ -60,14 +60,14 @@ This parameter is the value by which the wait time (B<-t>) is multiplied on each
successive request; it must be entered as a floating-point number (x.y). The
default is 1.5.
=item B<-c> I<n>
=item B<-c>, B<--count>=I<N>
Number of request packets to send to each target. In this mode, a line is
displayed for each received response (this can suppressed with B<-q> or B<-Q>).
Also, statistics about responses for each target are displayed when all
requests have been sent (or when interrupted).
=item B<-C> I<n>
=item B<-C>, B<--vcount>=I<N>
Similar to B<-c>, but the per-target statistics are displayed in a format
designed for automated response-time statistics gathering. For example:
@ -78,28 +78,30 @@ designed for automated response-time statistics gathering. For example:
shows the response time in milliseconds for each of the five requests, with the
C<-> indicating that no response was received to the fourth request.
=item B<-d>
=item B<-d>, B<--rdns>
Use DNS to lookup address of return ping packet. This allows you to give fping
a list of IP addresses as input and print hostnames in the output.
a list of IP addresses as input and print hostnames in the output. This is similar
to option B<-n>/B<--name>, but will force a reverse-DNS lookup even if you give
hostnames as target (NAME->IP->NAME).
=item B<-D>
=item B<-D>, B<--timestamp>
Add Unix timestamps in front of output lines generated with in looping or counting
modes (B<-l>, B<-c>, or B<-C>).
=item B<-e>
=item B<-e>, B<--elapsed>
Show elapsed (round-trip) time of packets.
=item B<-f>
=item B<-f>, B<--file>
Read list of targets from a file. This option can only be used by the root
user. Regular users should pipe in the file via stdin:
% fping < targets_file
=item B<-g> I<addr/mask>
=item B<-g>, B<--generate> I<addr/mask>
Generate a target list from a supplied IP netmask, or a starting and ending IP.
Specify the netmask or start/end in the targets portion of the command line. If
@ -113,84 +115,85 @@ or
fping -g 192.168.1.1 192.168.1.254
=item B<-h>
=item B<-h>, B<--help>
Print usage message.
=item B<-i> I<n>
=item B<-i>, B<--interval>=I<MSEC>
The minimum amount of time (in milliseconds) between sending a ping packet
to any target (default is 25, minimum is 1).
=item B<-l>
=item B<-l>, B<--loop>
Loop sending packets to each target indefinitely. Can be interrupted with
Ctrl-C; statistics about responses for each target are then displayed.
=item B<-m>
=item B<-m>, B<--all>
Send pings to each of a target host's multiple IP addresses (use of option '-A'
is recommended).
=item B<-M>
=item B<-M>, B<--dontfrag>
Set the "Don't Fragment" bit in the IP header (used to determine/test the MTU).
=item B<-n>
=item B<-n>, B<--name>
Same as -d.
If targets are specified as IP addresses, do a reverse-DNS lookup on them
to
=item B<-N>
=item B<-N>, B<--netdata>
Format output for netdata (-l -Q are required). See: L<http://my-netdata.io/>
=item B<-o>
=item B<-o>, B<--outage>
Calculate "outage time" based on the number of lost pings and the interval used (useful for network convergence tests).
=item B<-O> I<n>
=item B<-O>, B<--tos>=I<N>
Set the typ of service flag (TOS). I<n> can be either decimal or hexadecimal
Set the typ of service flag (TOS). I<N> can be either decimal or hexadecimal
(0xh) format.
=item B<-p> <n>
=item B<-p>, B<--period>=<MSEC>
In looping or counting modes (B<-l>, B<-c>, or B<-C>), this parameter sets
the time in milliseconds that B<fping> waits between successive packets to
an individual target. Default is 1000 and minimum is 10.
=item B<-q>
=item B<-q>, B<--quet>
Quiet. Don't show per-probe results, but only the final summary. Also don't
show ICMP error messages.
=item B<-Q> I<n>
=item B<-Q>, B<--squiet>=I<SECS>
Like B<-q>, but show summary results every n seconds.
=item B<-r> I<n>
=item B<-r>, B<--retry>=I<N>
Retry limit (default 3). This is the number of times an attempt at pinging
a target will be made, not including the first try.
=item B<-R>
=item B<-R>, B<--random>
Instead of using all-zeros as the packet data, generate random bytes.
Use to defeat, e.g., link data compression.
=item B<-s>
=item B<-s>, B<--src>
Print cumulative statistics upon exit.
=item B<-S> I<addr>
=item B<-S>, B<--src>=I<addr>
Set source address.
=item B<-I> I<if>
=item B<-I>, B<--iface>=I<IFACE>
Set the interface (requires SO_BINDTODEVICE support)
=item B<-t> I<n>
=item B<-t>, B<--timeout>=I<MSEC>
Initial target timeout in milliseconds (default 500). In the default mode, this
is the amount of time that B<fping> waits for a response to its first request.
@ -202,15 +205,15 @@ B<-C>).
Ignored (for compatibility with fping 2.4).
=item B<-u>
=item B<-u>, B<--unreach>
Show targets that are unreachable.
=item B<-v>
=item B<-v>, B<--version>
Print B<fping> version information.
=item B<-H> I<n>
=item B<-H>, B<--ttl>=I<N>
Set the IP TTL field (time to live hops).
@ -218,12 +221,10 @@ Set the IP TTL field (time to live hops).
=head1 EXAMPLES
Generate ~1000 pings per second to a host until canceled, printing statistics
on the fly at one second intervals, and printing statistics at the end:
Generate 20 pings to two hosts in ca. 1 second (i.e. one ping every 50 ms to
each host), and report every ping RTT at the end:
# fping -s -l -i 1 -p 1 -T 1 -Q 1 127.0.0.1
Note that ping intervals less than 1ms can only be used as root.
$ fping --quiet --interval=1 --vcount=20 --period=50 127.0.0.1 127.0.0.2
=head1 AUTHORS

@ -368,15 +368,15 @@ int main(int argc, char** argv)
/* get command line options */
struct optparse_long longopts[] = {
{ NULL, '4', OPTPARSE_NONE },
{ NULL, '6', OPTPARSE_NONE },
{ "ipv4", '4', OPTPARSE_NONE },
{ "ipv6", '6', OPTPARSE_NONE },
{ "alive", 'a', OPTPARSE_NONE },
{ "addr", 'A', OPTPARSE_NONE },
{ "size", 'b', OPTPARSE_REQUIRED },
{ "backoff", 'B', OPTPARSE_REQUIRED },
{ "count", 'c', OPTPARSE_REQUIRED },
{ "vcount", 'C', OPTPARSE_REQUIRED },
{ NULL, 'd', OPTPARSE_NONE }, // same as '--name'
{ "rdns", 'd', OPTPARSE_NONE },
{ "timestamp", 'D', OPTPARSE_NONE },
{ "elapsed", 'e', OPTPARSE_NONE },
{ "file", 'f', OPTPARSE_REQUIRED },
@ -403,7 +403,6 @@ int main(int argc, char** argv)
{ NULL, 'T', OPTPARSE_REQUIRED },
{ "unreach", 'u', OPTPARSE_NONE },
{ "version", 'v', OPTPARSE_NONE },
{ "rdns", 'X', OPTPARSE_NONE }, // FIXME: similar to --name, but do name->IP->name if a name is provided
{ 0, 0, 0 }
};
@ -524,13 +523,20 @@ int main(int argc, char** argv)
netdata_flag = 1;
break;
case 'd':
case 'n':
name_flag = 1;
if(rdns_flag) {
fprintf(stderr, "%s: use either one of -d or -n\n", prog);
exit(1);
}
break;
case 'X':
case 'd':
rdns_flag = 1;
if(name_flag) {
fprintf(stderr, "%s: use either one of -d or -n\n", prog);
exit(1);
}
break;
case 'A':
@ -2676,8 +2682,8 @@ void usage(int is_error)
fprintf(out, "Usage: %s [options] [targets...]\n", prog);
fprintf(out, "\n");
fprintf(out, "Probing options:\n");
fprintf(out, " -4 only ping IPv4 addresses\n");
fprintf(out, " -6 only ping IPv6 addresses\n");
fprintf(out, " -4, --ipv4 only ping IPv4 addresses\n");
fprintf(out, " -6, --ipv6 only ping IPv6 addresses\n");
fprintf(out, " -b, --size=BYTES amount of ping data to send, in bytes (default %d)\n", DEFAULT_PING_DATA_SIZE);
fprintf(out, " -B, --backoff=N set exponential backoff factor to N\n");
fprintf(out, " -c, --count=N count of pings to send to each target (default %d)\n", count);

Loading…
Cancel
Save