summaryrefslogtreecommitdiffstats
path: root/config-model/src/main/perl/vespa-replicate-log-stream
blob: 194d1d3ff7407334e7a17d34c601117ad8838ee3 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
#!/usr/bin/env perl
# Copyright 2017 Yahoo Holdings. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
use IO::Socket::IP;

my $cmd = "vespa-model-inspect -t logtp -t telnet -t replicator filter:ports";

print STDERR "Looking for logserver port ($cmd)\n";

my $vmiout = `$cmd`;
my $host = "";
my $port = "";

if ( $vmiout =~ m{^\s*tcp/(\S+):(\d+)\s*$/} ) {
	$host = $1;
	$port = $2;
	print STDERR "following logserver at '${host}:${port}'\n";
} else {
	die "FAILED finding host and port for logserver replication\n";
}

my $net = new IO::Socket::IP(PeerAddr => "${host}:${port}",
                             Proto    => 'tcp',
                             Timeout  => 10);
if (!$net) {
        die "could not contact logserver at ${host}:${port}\n";
}

print $net "use system.all\r\n";

while (<$net>) {
	if (m/^#/) {
		print STDERR;
	} else {
		print;
	}
}
exit(0);