Index: trunk/webstatscollector/generate-test-data.pl |
— | — | @@ -0,0 +1,32 @@ |
| 2 | +# Generates test data for the collector and flings it at port 3815, |
| 3 | +# written for testing a memory leak |
| 4 | +use strict; |
| 5 | +use IO::Socket::INET; |
| 6 | + |
| 7 | +my $socket = IO::Socket::INET->new( |
| 8 | + PeerAddr => 'localhost:3815', |
| 9 | + Proto => 'tcp', |
| 10 | +) or die "Can't open socket"; |
| 11 | + |
| 12 | +# This is here because the collector keeps closing my connection, so I |
| 13 | +# can run it as while 1; do perl generate-test-data.pl; done and it'll |
| 14 | +# send the correct serial |
| 15 | +my $serial = do { local (@ARGV) = 'serial'; <> }; |
| 16 | + |
| 17 | +while (1) |
| 18 | +{ |
| 19 | + $serial++; |
| 20 | + open my $fh, ">", 'serial' or die $!; |
| 21 | + print $fh $serial; |
| 22 | + close $fh; |
| 23 | + |
| 24 | + my $project = 'iswiki'; |
| 25 | + my $count = 1; |
| 26 | + my $bytes = 10 + int rand 2**8; |
| 27 | + my $page = 'Foo'; |
| 28 | + |
| 29 | + my $msg = sprintf "%d %s %d %s\n", $serial, 'iswiki', $bytes, $page; |
| 30 | + |
| 31 | + print $msg; |
| 32 | + $socket->print($msg); |
| 33 | +} |