aboutsummaryrefslogtreecommitdiff
path: root/contrib/scripts/gnunet-logread/gnunet-logread-ipc-sdedit
diff options
context:
space:
mode:
Diffstat (limited to 'contrib/scripts/gnunet-logread/gnunet-logread-ipc-sdedit')
-rwxr-xr-xcontrib/scripts/gnunet-logread/gnunet-logread-ipc-sdedit60
1 files changed, 60 insertions, 0 deletions
diff --git a/contrib/scripts/gnunet-logread/gnunet-logread-ipc-sdedit b/contrib/scripts/gnunet-logread/gnunet-logread-ipc-sdedit
new file mode 100755
index 000000000..f8b7dc735
--- /dev/null
+++ b/contrib/scripts/gnunet-logread/gnunet-logread-ipc-sdedit
@@ -0,0 +1,60 @@
1#!@PERL@
2
3# 1. Start sdedit and enable 'RT diagram server' in 'Global preferences'.
4#
5# 2. Start this tool (see defaults below):
6# gnunet-logread-ipc-sdedit -n buffer-name -i /path/to/ipc.sock -h <sdedit-host> -p <sdedit-port>
7#
8# 3. Start a gnunet-logread instance for each component with the -n <component_name> option
9
10use strict;
11use warnings;
12
13use Getopt::Std;
14use IO::Socket::INET;
15use POSIX qw(mkfifo);
16
17my %opts;
18getopts ('i:n:h:p:', \%opts);
19
20my $ipc = $opts{i} || '/tmp/gnunet-logread-ipc.sock';
21my $name = $opts{n} || 'gnunet';
22my $host = $opts{h} || 'localhost';
23my $port = $opts{p} || 16001;
24my %svcs = map { $_ => 1 } @ARGV;
25
26my $sdedit = IO::Socket::INET->new(PeerAddr => $host,
27 PeerPort => $port,
28 Proto => 'tcp')
29 or die "Cannot connect to $host:$port: $!\n";
30
31print $sdedit "$name\n";
32print $sdedit "_t:time[e]\n";
33print $sdedit "$_:$_\[ap\] \"$_\"\n" for @ARGV;
34print $sdedit "_e:ext[e]\n";
35print $sdedit "\n";
36
37mkfifo $ipc, 0600 or die "$ipc: $!\n" unless -e $ipc;
38open IPC, '<', $ipc or die "$ipc: $!\n";
39$| = 1;
40while (<IPC>)
41{
42 print;
43 my ($time, $from, $to, $msg, $svc);
44 if (my ($time, $from, $to, $msg) =
45 /^([A-Z][a-z]{2}\ .[0-9]\ [0-9:]{8}(?:-[0-9]{6})?)\s+
46 (\S+)\s+ -> \s+(\S+)\s+ (\S+\s+ \(\d+\))/x)
47 {
48 $from = '_e' unless exists $svcs{$from};
49 $to = '_e' unless exists $svcs{$to};
50 print $sdedit "*0 _t\n$time\n*0\n", "$from:$to.$msg\n"
51 }
52 elsif (($time, $svc, $msg) =
53 /^([A-Z][a-z]{2}\ .[0-9]\ [0-9:]{8}(?:-[0-9]{6})?)\s+
54 (\S+)\s+(.+)/x)
55 {
56 print $sdedit "*0 _t\n$time\n*0\n", "*0 $svc\n$msg\n*0\n"
57 }
58}
59
60close IPC;