1# The client writes a message to Sys::Syslog native method. 2# The syslogd writes it into a file and through a pipe. 3# The syslogd passes it via UDP to the loghost. 4# The server receives the message on its UDP socket. 5# Find the message in client, file, pipe, syslogd, server log. 6# Check that a SIGHUP reopens logfile and restarts pipe. 7 8use strict; 9use warnings; 10 11our %args = ( 12 client => { 13 func => sub { write_between2logs(shift, sub { 14 my $self = shift; 15 ${$self->{server}}->loggrep("Signal", 8) 16 or die ref($self), " no 'Signal' between logs"; 17 })}, 18 loggrep => { get_between2loggrep() }, 19 }, 20 syslogd => { 21 ktrace => { 22 qr/syslogd PSIG SIGHUP caught handler/ => 1, 23 qr/syslogd RET execve 0/ => 2, 24 }, 25 loggrep => { 26 qr/config file changed: dying/ => 0, 27 qr/config file modified: restarting/ => 0, 28 qr/syslogd: restarted/ => 1, 29 get_between2loggrep(), 30 }, 31 }, 32 server => { 33 func => sub { read_between2logs(shift, sub { 34 my $self = shift; 35 ${$self->{syslogd}}->rotate(); 36 ${$self->{syslogd}}->kill_syslogd('HUP'); 37 ${$self->{syslogd}}->loggrep("syslogd: restarted", 5) 38 or die ref($self), " no 'syslogd: restarted' between logs"; 39 print STDERR "Signal\n"; 40 })}, 41 loggrep => { 42 get_between2loggrep(), 43 qr/Signal/ => 1, 44 qr/Accepted/ => 1, 45 }, 46 }, 47 check => sub { 48 my $self = shift; 49 my $r = $self->{syslogd}; 50 $r->loggrep("bytes transferred", 1, 2) or sleep 1; 51 foreach my $name (qw(file pipe)) { 52 my $file = $r->{"out$name"}.".0"; 53 my $pattern = (get_between2loggrep())[0]; 54 check_pattern($name, $file, $pattern, \&filegrep); 55 } 56 }, 57 file => { 58 loggrep => { 59 qr/syslogd\[\d+\]: start/ => 0, 60 qr/syslogd\[\d+\]: restart/ => 1, 61 qr/syslogd\[\d+\]: exiting/ => 1, 62 }, 63 }, 64); 65 661; 67