Commit c17d17da authored by Robert Ricci's avatar Robert Ricci

Add a new 'eventdebug' script, the event system version of tcpdump

parent 1e4785a6
......@@ -1213,6 +1213,7 @@ else
event/tbgen/GNUmakefile event/tbgen/tevd.restart \
event/example/GNUmakefile event/example/tbsend.pl \
event/example/tbrecv.pl event/example/tbsend-short.pl \
event/example/eventdebug.pl \
event/trafgen/GNUmakefile \
event/proxy/GNUmakefile \
event/nsetrafgen/GNUmakefile \
......@@ -1286,7 +1287,7 @@ fi
# SVR4 /usr/ucb/install, which tries to use the nonexistent group "staff"
# ./install, which can be erroneously created by make from ./install.sh.
echo $ac_n "checking for a BSD compatible install""... $ac_c" 1>&6
echo "configure:1290: checking for a BSD compatible install" >&5
echo "configure:1291: checking for a BSD compatible install" >&5
if test -z "$INSTALL"; then
if eval "test \"`echo '$''{'ac_cv_path_install'+set}'`\" = set"; then
echo $ac_n "(cached) $ac_c" 1>&6
......
......@@ -326,6 +326,7 @@ else
event/tbgen/GNUmakefile event/tbgen/tevd.restart \
event/example/GNUmakefile event/example/tbsend.pl \
event/example/tbrecv.pl event/example/tbsend-short.pl \
event/example/eventdebug.pl \
event/trafgen/GNUmakefile \
event/proxy/GNUmakefile \
event/nsetrafgen/GNUmakefile \
......
#!/usr/bin/perl
#
# Debug the event system by subscribing to and printing all events - event
# system analog of tcpdump. An trivial modification of tbrecv.pl
#
#
# Configure variables
#
use lib '@prefix@/lib';
use event;
use Getopt::Std;
use strict;
sub usage {
warn "Usage: $0 [-s server] [-p port] <event>\n";
return 1;
}
my %opt = ();
getopt(\%opt,"s:p:h");
if ($opt{h}) { exit &usage; }
if (@ARGV) { exit &usage; }
my ($server,$port);
if ($opt{s}) { $server = $opt{s}; } else { $server = "boss"; }
if ($opt{p}) { $port = $opt{p}; }
my $URL = "elvin://$server";
if ($port) { $URL .= ":$port"; }
my $handle = event_register($URL,0);
if (!$handle) { die "Unable to register with event system\n"; }
my $tuple = address_tuple_alloc();
if (!$tuple) { die "Could not allocate an address tuple\n"; }
if (!event_subscribe($handle,\&callbackFunc,$tuple)) {
die "Could not subscribe to event\n";
}
#
# Note a difference from tbrecv.c - we don't yet have event_main() functional
# in perl, so we have to poll. (Nothing special about the select, it's just
# a wacky way to get usleep() )
#
while (1) {
event_poll($handle);
select(undef, undef, undef, 0.25);
}
if (event_unregister($handle) == 0) {
die "Unable to unregister with event system\n";
}
exit(0);
sub callbackFunc($$$) {
my ($handle,$notification,$data) = @_;
my $time = time();
my $site = event_notification_get_site($handle, $notification);
my $expt = event_notification_get_expt($handle, $notification);
my $group = event_notification_get_group($handle, $notification);
my $host = event_notification_get_host($handle, $notification);
my $objtype = event_notification_get_objtype($handle, $notification);
my $objname = event_notification_get_objname($handle, $notification);
my $eventtype = event_notification_get_eventtype($handle,
$notification);
print "Event: $time $site $expt $group $host $objtype $objname " .
"$eventtype\n";
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment