author | Florian Forster <ff@octo.it> | |
Thu, 18 Aug 2016 04:58:53 +0000 (06:58 +0200) | ||
committer | Florian Forster <ff@octo.it> | |
Thu, 18 Aug 2016 04:58:53 +0000 (06:58 +0200) |
src/mans/oping.pod | patch | blob | history | |
src/oping.c | patch | blob | history |
diff --git a/src/mans/oping.pod b/src/mans/oping.pod
index 6f1f5c300721580f5d72c6c7b4d99338e84fe913..f1e08071d1119311caf0f791507475e3bddb272e 100644 (file)
--- a/src/mans/oping.pod
+++ b/src/mans/oping.pod
=back
+=item B<-b>
+
+Audible bell. Print a ASCII BEL character (\a or 0x07) when a packet
+is received before the timeout occurs. This can be useful in order to
+monitory hosts' connectivity without looking physically at the
+console, for example to trace network cables (start audible beep,
+disconnect cable N: if beep stops, the cable was in use) or to tell
+when a host returns from a reboot.
+
+This relies on the terminal bell to be functional. To enable the
+terminal bell, use the following instructions.
+
+=over 4
+
+=item
+
+the visual bell is disabled in your terminal emulator, with the +vb
+commandline flag or the following in your .Xresources:
+
+ XTerm*visualBell: false
+
+=item
+
+the PC speaker module is loaded in your kernel:
+
+ modprobe pcspkr
+
+=item
+
+X11 has the terminal bell enabled:
+
+ xset b on; xset b 100
+
+=item
+
+and finally, if you are using PulseAudio, that the module-x11-bell
+module is loaded with a pre-loaded sample defined in your pulseaudio
+configuration:
+
+ load-sample-lazy x11-bell /usr/share/sounds/freedesktop/stereo/complete.oga
+ load-module module-x11-bell sample=x11-bell
+
+=back
+
=item B<-P> I<percent>
Configures the latency percentile to report. I<percent> must be a number
diff --git a/src/oping.c b/src/oping.c
index 883c86227c6713f33247548136ee3d81c899aefa..0cfe64672065c0a99dd3a1d2e9ca8bc9bd5763ce 100644 (file)
--- a/src/oping.c
+++ b/src/oping.c
static int opt_utf8 = 0;
#endif
static char *opt_outfile = NULL;
+static int opt_bell = 0;
static int host_num = 0;
static FILE *outfile = NULL;
while (1)
{
- optchar = getopt (argc, argv, "46c:hi:I:t:Q:f:D:Z:O:P:m:w:"
+ optchar = getopt (argc, argv, "46c:hi:I:t:Q:f:D:Z:O:P:m:w:b"
#if USE_NCURSES
"uUg:"
#endif
opt_utf8 = 1;
break;
#endif
+ case 'b':
+ opt_bell = 1;
+ break;
case 'Z':
{
#if USE_NCURSES
}
#endif
+ if (opt_bell) {
+#if USE_NCURSES
+ beep();
+#else
+ HOST_PRINTF ("\a");
+#endif
+ }
}
else /* if (!(latency > 0.0)) */
{