Compare commits

21 Commits
Author SHA1 Message Date
David Schweikert ecba31b2dd Release 3.5 2013-05-22 08:56:44 +02:00
David Schweikert 28eea9c273 Re-create configure script with autoconf 2.69 for aarch64 support (Chuck Anderson, #45) 2013-05-22 08:48:08 +02:00
David Schweikert 121bea1d24 Fix compatibility issue with FreeBSD (Alexandre Raynaud, Jason Harris, #39) 2013-05-21 22:02:39 +02:00
David Schweikert 5d6db6f08d document new -D flag 2013-05-21 21:47:33 +02:00
David Schweikert 543d22122d Merge pull request #42 from tohojo/master
Add -D flag to print timestamp in front of output lines.
2013-05-21 12:43:02 -07:00
David Schweikert 70a29a11af fix sprint_tm buffer size crash (reported by Japheth Cleaver) 2013-05-21 21:36:36 +02:00
David Schweikert b0e09ce6fe Coverity: remove pointless expression 2013-04-23 21:59:32 +02:00
David Schweikert 6400ffb339 Merge branch 'master' of github.com:schweikert/fping 2013-04-23 21:26:02 +02:00
David Schweikert 98d44d02bb Merge pull request #47 from dlad/fix-warning
fix clang warning: comparison of unsigned expression < 0 is always false
2013-04-23 12:12:20 -07:00
Dipen Lad 69fff78ca4 fix clang warning: comparison of unsigned expression < 0 is always false 2013-04-20 21:50:22 +01:00
Toke Høiland-Jørgensen 5b6784a4ea Fix formatting of usec part of timestamp output. 2013-03-17 16:33:52 +01:00
Toke Høiland-Jørgensen 25dc120355 Add -D flag to print timestamps before output lines (like Linux ping). 2013-03-11 09:29:58 -04:00
David Schweikert f906225fbd update changelog 2013-02-17 23:09:58 +01:00
David Schweikert 3e29f0631c Merge pull request #35 from ghost/patch-1
Fixes failing fping6 build on OS X 10.8
2013-02-17 14:08:46 -08:00
David Schweikert 10d0a54c07 remove version information from man-page (#31) 2013-02-17 23:06:27 +01:00
David Schweikert ad4ca1609d Update ChangeLog 2013-02-17 23:05:38 +01:00
David Schweikert e0edbf28fc Merge pull request #34 from mv/fix-spec-file
Fix setuid permissions. Provides fping6.
2013-02-17 14:04:04 -08:00
Simon Hitzemann 1c85a422c1 Fixes failing fping6 build on OS X 10.8 2012-12-28 16:52:25 +01:00
Marcus Vinicius Ferreira 86cfc7cf74 Fix setuid permissions. Provides fping6. 2012-12-24 12:51:34 -02:00
David Schweikert fd020977b5 Prepare 3.4 2012-09-04 09:32:09 +02:00
David Schweikert 81c96c0807 Revert "Output statistics to stdout instead of stderr (suggested by Simon Leinen, #9)"
This reverts commit b4d0a93b70.
2012-09-04 09:27:52 +02:00
6 changed files with 139 additions and 80 deletions
+14
View File
@@ -1,3 +1,17 @@
2013-05-22 David Schweikert <david@schweikert.ch>
* Version 3.5
* Fix sprint_tm buffer size crash (reported by Japheth Cleaver)
* Addded -D flag to print timestamps (Toke Høiland-Jørgensen)
* Fix fping6 build on OS X 10.8 (unknown contributor)
* Fix compatibility issue with FreeBSD (Alexandre Raynaud, Jason Harris, #39)
* Fping.spec: fix setuid permissions and provides fping6 (Marcus Vinicius Ferreira)
* Re-create configure script with autoconf 2.69 for aarch64 support (Chuck Anderson, #45)
2012-09-04 David Schweikert <david@schweikert.ch>
* Version 3.4
* Revert "Output statistics to stdout instead of stderr", because it breaks
tools assuming the output goes to stderr
2012-08-19 David Schweikert <david@schweikert.ch>
* Version 3.3
* Do not output icmp errors with -q (#1)
+1 -1
View File
@@ -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.3])
AC_INIT([fping],[3.4])
dnl make ipv4 and ipv6 options
AC_ARG_ENABLE([ipv4],
+34 -7
View File
@@ -1,10 +1,10 @@
Summary: send ICMP echo probes to multiple hosts
Name: fping
Version: 3.2
Version: 3.4
Release: 1
License: MIT
Group: Applications/System
Source0: %{name}-%{version}.tar.gz
Source0: http://fping.org/dist/%{name}-%{version}.tar.gz
BuildRoot: %{_tmppath}/%{name}-%{version}-%{release}-buildroot
%description
@@ -18,29 +18,56 @@ statistics.
%setup -q
%build
%configure
if [ ! -f ./configure ] ; then
./autogen.sh
fi
# fping
%configure --enable-ipv4
make
# fping6
%configure --enable-ipv6
make
%{__mv} -f src/fping src/fping6
%install
rm -rf $RPM_BUILD_ROOT
make DESTDIR=$RPM_BUILD_ROOT install
# fping6
%{__install} -Dp -m4755 src/fping6 %{buildroot}%{_sbindir}/fping6
%{__ln_s} -f fping.8 %{buildroot}%{_mandir}/man8/fping6.8
%clean
rm -rf $RPM_BUILD_ROOT
%files
%defattr(-,root,root,-)
/usr/sbin/fping
%attr(4755, root, root) /usr/sbin/fping
%attr(4755, root, root) /usr/sbin/fping6
%doc README COPYING ChangeLog
/usr/share/man/man8/fping.8.gz
/usr/share/man/man8/fping6.8.gz
%post
if [ -x /usr/sbin/setcap ]; then
/usr/sbin/setcap cap_net_raw+ep /usr/sbin/fping
else
chmod 1777 /usr/sbin/fping
/bin/chmod 0755 /usr/sbin/fping*
/usr/sbin/setcap cap_net_raw+ep /usr/sbin/fping*
fi
%changelog
* Mon Dec 24 2012 Marcus Vinicius Ferreira <ferreira.mv@gmail.com>
- Missing './configure' script when cloning from master.
- Making 'fping6'.
- Fix setuid permission to 'rwsr-xr-x'.
- doc files.
- Replacing setuid permission if 'setcap' is present on post-install.
- Using 'http://fping.org/dist/' for release source distributions.
* Mon Jul 16 2012 Stephen Schaefer <sschaefer@acm.org>
- Initial build
# vim:ft=spec:
+3 -3
View File
@@ -8,10 +8,10 @@ if IPV6
man_MANS += fping6.8
endif
EXTRA_DIST = $(man_MANS) fping.pod README.1992
EXTRA_DIST = fping.8 fping6.8 fping.pod README.1992
fping.8: fping.pod
pod2man -c "" -s 8 -r "fping $(VERSION)" $< >$@
pod2man -c "" -s 8 -r "fping" $< >$@
fping6.8: fping.pod
pod2man -c "" -s 8 -r "fping $(VERSION)" -n fping6 $< >$@
pod2man -c "" -s 8 -r "fping" -n fping6 $< >$@
+5
View File
@@ -77,6 +77,11 @@ C<-> indicating that no response was received to the fourth request.
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.
=item B<-D>
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>
Show elapsed (round-trip) time of packets.
+82 -69
View File
@@ -54,6 +54,7 @@ extern "C"
#include <getopt.h>
#include <stdarg.h>
#define __APPLE_USE_RFC_3542 1
#include <netinet/in.h>
#include "config.h"
@@ -313,6 +314,7 @@ int verbose_flag, quiet_flag, stats_flag, unreachable_flag, alive_flag;
int elapsed_flag, version_flag, count_flag, loop_flag;
int per_recv_flag, report_all_rtts_flag, name_flag, addr_flag, backoff_flag;
int multif_flag;
int timestamp_flag = 0;
#if defined( DEBUG ) || defined( _DEBUG )
int randomly_lose_flag, sent_times_flag, trace_flag, print_per_system_flag;
int lose_factor;
@@ -491,7 +493,7 @@ int main( int argc, char **argv )
/* get command line options */
while( ( c = getopt( argc, argv, "gedhlmnqusaAvz:t:H:i:p:f:r:c:b:C:Q:B:S:I:T:O:" ) ) != EOF )
while( ( c = getopt( argc, argv, "gedhlmnqusaAvDz:t:H:i:p:f:r:c:b:C:Q:B:S:I:T:O:" ) ) != EOF )
{
switch( c )
{
@@ -582,6 +584,10 @@ int main( int argc, char **argv )
stats_flag = 1;
break;
case 'D':
timestamp_flag = 1;
break;
case 'l':
loop_flag = 1;
backoff_flag = 0;
@@ -683,7 +689,7 @@ int main( int argc, char **argv )
/* validate various option settings */
if (ttl < 0 || ttl > 255) {
if (ttl > 255) {
fprintf(stderr, "ping: ttl %u out of range\n", ttl);
usage(1);
}
@@ -1142,7 +1148,7 @@ void main_loop()
ev_enqueue(h);
}
/* Count mode: schedule timeout after last ping */
else if(count_flag && count_flag && h->num_sent >= count) {
else if(count_flag && h->num_sent >= count) {
h->ev_type = EV_TYPE_TIMEOUT;
h->ev_time.tv_sec = last_send_time.tv_sec;
h->ev_time.tv_usec = last_send_time.tv_usec;
@@ -1305,39 +1311,39 @@ void print_per_system_stats( void )
fflush( stdout );
if( verbose_flag || per_recv_flag )
fprintf( stdout, "\n" );
fprintf( stderr, "\n" );
for( i = 0; i < num_hosts; i++ )
{
h = table[i];
fprintf( stdout, "%s%s :", h->host, h->pad );
fprintf( stderr, "%s%s :", h->host, h->pad );
if( report_all_rtts_flag )
{
for( j = 0; j < h->num_sent; j++ )
{
if( ( resp = h->resp_times[j] ) >= 0 )
fprintf( stdout, " %d.%02d", resp / 100, resp % 100 );
fprintf( stderr, " %d.%02d", resp / 100, resp % 100 );
else
fprintf( stdout, " -" );
fprintf( stderr, " -" );
}/* FOR */
fprintf( stdout, "\n" );
fprintf( stderr, "\n" );
}/* IF */
else
{
if( h->num_recv <= h->num_sent )
{
fprintf( stdout, " xmt/rcv/%%loss = %d/%d/%d%%",
fprintf( stderr, " xmt/rcv/%%loss = %d/%d/%d%%",
h->num_sent, h->num_recv, h->num_sent > 0 ?
( ( h->num_sent - h->num_recv ) * 100 ) / h->num_sent : 0 );
}/* IF */
else
{
fprintf( stdout, " xmt/rcv/%%return = %d/%d/%d%%",
fprintf( stderr, " xmt/rcv/%%return = %d/%d/%d%%",
h->num_sent, h->num_recv,
( ( h->num_recv * 100 ) / h->num_sent ) );
@@ -1346,13 +1352,13 @@ void print_per_system_stats( void )
if( h->num_recv )
{
avg = h->total_time / h->num_recv;
fprintf( stdout, ", min/avg/max = %s", sprint_tm( h->min_reply ) );
fprintf( stdout, "/%s", sprint_tm( avg ) );
fprintf( stdout, "/%s", sprint_tm( h->max_reply ) );
fprintf( stderr, ", min/avg/max = %s", sprint_tm( h->min_reply ) );
fprintf( stderr, "/%s", sprint_tm( avg ) );
fprintf( stderr, "/%s", sprint_tm( h->max_reply ) );
}/* IF */
fprintf(stdout, "\n");
fprintf(stderr, "\n");
}/* ELSE */
@@ -1362,11 +1368,11 @@ void print_per_system_stats( void )
for( j = 0; j < h->num_sent; j++ )
{
if( ( resp = h->sent_times[j] ) >= 0 )
fprintf( stdout, " %s", sprint_tm( resp ) );
fprintf( stderr, " %s", sprint_tm( resp ) );
else
fprintf( stdout, " -" );
fprintf( stderr, " -" );
fprintf( stdout, "\n" );
fprintf( stderr, "\n" );
}/* FOR */
}/* IF */
@@ -1409,27 +1415,27 @@ void print_per_system_splits( void )
fflush( stdout );
if( verbose_flag || per_recv_flag )
fprintf( stdout, "\n" );
fprintf( stderr, "\n" );
curr_tm = localtime( ( time_t* )&current_time.tv_sec );
fprintf( stdout, "[%2.2d:%2.2d:%2.2d]\n", curr_tm->tm_hour,
fprintf( stderr, "[%2.2d:%2.2d:%2.2d]\n", curr_tm->tm_hour,
curr_tm->tm_min, curr_tm->tm_sec );
for( i = 0; i < num_hosts; i++ )
{
h = table[i];
fprintf( stdout, "%s%s :", h->host, h->pad );
fprintf( stderr, "%s%s :", h->host, h->pad );
if( h->num_recv_i <= h->num_sent_i )
{
fprintf( stdout, " xmt/rcv/%%loss = %d/%d/%d%%",
fprintf( stderr, " xmt/rcv/%%loss = %d/%d/%d%%",
h->num_sent_i, h->num_recv_i, h->num_sent_i > 0 ?
( ( h->num_sent_i - h->num_recv_i ) * 100 ) / h->num_sent_i : 0 );
}/* IF */
else
{
fprintf( stdout, " xmt/rcv/%%return = %d/%d/%d%%",
fprintf( stderr, " xmt/rcv/%%return = %d/%d/%d%%",
h->num_sent_i, h->num_recv_i, h->num_sent_i > 0 ?
( ( h->num_recv_i * 100 ) / h->num_sent_i ) : 0 );
@@ -1438,13 +1444,13 @@ void print_per_system_splits( void )
if( h->num_recv_i )
{
avg = h->total_time_i / h->num_recv_i;
fprintf( stdout, ", min/avg/max = %s", sprint_tm( h->min_reply_i ) );
fprintf( stdout, "/%s", sprint_tm( avg ) );
fprintf( stdout, "/%s", sprint_tm( h->max_reply_i ) );
fprintf( stderr, ", min/avg/max = %s", sprint_tm( h->min_reply_i ) );
fprintf( stderr, "/%s", sprint_tm( avg ) );
fprintf( stderr, "/%s", sprint_tm( h->max_reply_i ) );
}/* IF */
fprintf( stdout, "\n" );
fprintf( stderr, "\n" );
h->num_sent_i = h->num_recv_i = h->max_reply_i =
h->min_reply_i = h->total_time_i = 0;
@@ -1471,17 +1477,17 @@ void print_per_system_splits( void )
void print_global_stats( void )
{
fflush( stdout );
fprintf( stdout, "\n" );
fprintf( stdout, " %7d targets\n", num_hosts );
fprintf( stdout, " %7d alive\n", num_alive );
fprintf( stdout, " %7d unreachable\n" ,num_unreachable );
fprintf( stdout, " %7d unknown addresses\n", num_noaddress );
fprintf( stdout, "\n" );
fprintf( stdout, " %7d timeouts (waiting for response)\n", num_timeout );
fprintf( stdout, " %7d ICMP Echos sent\n", num_pingsent );
fprintf( stdout, " %7d ICMP Echo Replies received\n", num_pingreceived );
fprintf( stdout, " %7d other ICMP received\n", num_othericmprcvd );
fprintf( stdout, "\n" );
fprintf( stderr, "\n" );
fprintf( stderr, " %7d targets\n", num_hosts );
fprintf( stderr, " %7d alive\n", num_alive );
fprintf( stderr, " %7d unreachable\n" ,num_unreachable );
fprintf( stderr, " %7d unknown addresses\n", num_noaddress );
fprintf( stderr, "\n" );
fprintf( stderr, " %7d timeouts (waiting for response)\n", num_timeout );
fprintf( stderr, " %7d ICMP Echos sent\n", num_pingsent );
fprintf( stderr, " %7d ICMP Echo Replies received\n", num_pingreceived );
fprintf( stderr, " %7d other ICMP received\n", num_othericmprcvd );
fprintf( stderr, "\n" );
if( total_replies == 0 )
{
@@ -1492,13 +1498,13 @@ void print_global_stats( void )
}/* IF */
fprintf( stdout, " %s ms (min round trip time)\n", sprint_tm( min_reply ) );
fprintf( stdout, " %s ms (avg round trip time)\n",
fprintf( stderr, " %s ms (min round trip time)\n", sprint_tm( min_reply ) );
fprintf( stderr, " %s ms (avg round trip time)\n",
sprint_tm( ( int )( sum_replies / total_replies ) ) );
fprintf( stdout, " %s ms (max round trip time)\n", sprint_tm( max_reply ) );
fprintf( stdout, " %.3f sec (elapsed real time)\n",
fprintf( stderr, " %s ms (max round trip time)\n", sprint_tm( max_reply ) );
fprintf( stderr, " %12.3f sec (elapsed real time)\n",
timeval_diff( &end_time, &start_time ) / 100000.0 );
fprintf( stdout, "\n" );
fprintf( stderr, "\n" );
} /* print_global_stats() */
@@ -1573,7 +1579,12 @@ int send_ping( int s, HOST_ENTRY *h )
( struct sockaddr* )&h->saddr, sizeof( FPING_SOCKADDR ) );
if( n < 0 || n != ping_pkt_size )
{
if(
(n < 0 || n != ping_pkt_size)
#if defined( EHOSTDOWN )
&& errno != EHOSTDOWN
#endif
) {
if( verbose_flag || unreachable_flag )
{
printf( "%s", h->host );
@@ -1822,6 +1833,11 @@ int wait_for_reply(long wait_time)
if( per_recv_flag )
{
if(timestamp_flag) {
printf("[%lu.%06lu] ",
(unsigned long)current_time.tv_sec,
(unsigned long)current_time.tv_usec);
}
avg = h->total_time / h->num_recv;
printf( "%s%s : [%d], %d bytes, %s ms",
h->host, h->pad, this_count, result, sprint_tm( this_reply ) );
@@ -2534,36 +2550,32 @@ char * sprint_tm( int t )
{
static char buf[10];
/* <= 0.99 ms */
if( t < 100 )
{
if( t < 0 ) {
/* negative (unexpected) */
sprintf( buf, "%.2g", (double) t / 100 );
}
else if( t < 100 ) {
/* <= 0.99 ms */
sprintf( buf, "0.%02d", t );
return( buf );
}/* IF */
/* 1.00 - 9.99 ms */
if( t < 1000 )
{
}
else if( t < 1000 ) {
/* 1.00 - 9.99 ms */
sprintf( buf, "%d.%02d", t / 100, t % 100 );
return( buf );
}/* IF */
/* 10.0 - 99.9 ms */
if( t < 10000 )
{
}
else if( t < 10000 ) {
/* 10.0 - 99.9 ms */
sprintf( buf, "%d.%d", t / 100, ( t % 100 ) / 10 );
return( buf );
}/* IF */
/* >= 100 ms */
sprintf( buf, "%d", t / 100 );
}
else if( t < 100000000 ) {
/* 100 - 1'000'000 ms */
sprintf( buf, "%d", t / 100 );
}
else {
sprintf( buf, "%.2e", (double) (t / 100) );
}
return( buf );
} /* sprint_tm() */
}
/************************************************************
@@ -2809,6 +2821,7 @@ void usage(int is_error)
fprintf(out, " -B f set exponential backoff factor to f\n" );
fprintf(out, " -c n count of pings to send to each target (default %d)\n", count );
fprintf(out, " -C n same as -c, report results in verbose format\n" );
fprintf(out, " -D print timestamp before each output line\n" );
fprintf(out, " -e show elapsed time on return packets\n" );
fprintf(out, " -f file read list of targets from a file ( - means stdin) (only if no -g specified)\n" );
fprintf(out, " -g generate target list (only if no -f specified)\n" );