1# The client writes messages with various methods. 2# The syslogd writes them into a file and through a pipe and to tty. 3# The syslogd is run with -h, adds a hostname, and passes them to loghost. 4# The server receives the messages on its UDP socket. 5# Find the message in client, file, pipe, console, user, syslogd, server log. 6# Check that the hostname in file and server log is correct. 7 8use strict; 9use warnings; 10use Socket; 11use Sys::Hostname; 12 13(my $host = hostname()) =~ s/\..*//; 14 15our %args = ( 16 client => { 17 redo => [ 18 { connect => { 19 proto => "udp", 20 domain => AF_INET, 21 addr => "127.0.0.1", 22 port => 514, 23 }}, 24 { connect => { 25 proto => "tcp", 26 domain => AF_INET, 27 addr => "127.0.0.1", 28 port => 514, 29 }}, 30 { connect => { 31 proto => "tls", 32 domain => AF_INET, 33 addr => "127.0.0.1", 34 port => 6514, 35 }}, 36 { logsock => { 37 type => "native", 38 }}, 39 { logsock => { 40 type => "unix", 41 }}, 42 { logsock => { 43 type => "udp", 44 host => "127.0.0.1", 45 port => 514, 46 }}, 47 { logsock => { 48 type => "tcp", 49 host => "127.0.0.1", 50 port => 514, 51 }}, 52 ], 53 func => sub { redo_connect(shift, sub { 54 my $self = shift; 55 write_message($self, "client connect proto: ". 56 $self->{connectproto}) if $self->{connectproto}; 57 write_message($self, "client logsock type: ". 58 $self->{logsock}{type}) if $self->{logsock}; 59 })}, 60 }, 61 syslogd => { 62 options => [qw(-h -n -rr 63 -U 127.0.0.1:514 -T 127.0.0.1:514 -S 127.0.0.1:6514)], 64 }, 65 server => { 66 loggrep => { 67 qr/ client connect / => 3, 68 qr/:\d\d $host client connect proto: udp$/ => 1, 69 qr/:\d\d $host client connect proto: tcp$/ => 1, 70 qr/:\d\d $host client connect proto: tls$/ => 1, 71 qr/ client logsock / => 4, 72 qr/:\d\d $host syslogd-.*: client logsock type: native/ => 1, 73 qr/:\d\d $host syslogd-.*: client logsock type: unix/ => 1, 74 qr/:\d\d $host syslogd-.*: client logsock type: udp/ => 1, 75 qr/:\d\d $host syslogd-.*: client logsock type: tcp/ => 1, 76 }, 77 }, 78 file => { 79 loggrep => { 80 qr/ client connect / => 3, 81 qr/:\d\d 127.0.0.1 client connect proto: udp$/ => 1, 82 qr/:\d\d 127.0.0.1 client connect proto: tcp$/ => 1, 83 qr/:\d\d 127.0.0.1 client connect proto: tls$/ => 1, 84 qr/ client logsock / => 4, 85 qr/:\d\d $host syslogd-.*: client logsock type: native/ => 1, 86 qr/:\d\d $host syslogd-.*: client logsock type: unix/ => 1, 87 qr/:\d\d 127.0.0.1 syslogd-.*: client logsock type: udp/ => 1, 88 qr/:\d\d 127.0.0.1 syslogd-.*: client logsock type: tcp/ => 1, 89 }, 90 }, 91); 92 931; 94