1# The client writes message with different timestamps to /dev/log. 2# The syslogd runs with -Z to translate them to iso time. 3# The syslogd writes it into a file and through a pipe and to tty. 4# The syslogd passes it via UDP to the loghost. 5# The server receives the message on its UDP socket. 6# Find the message in client, file, pipe, console, user, syslogd, server log. 7# Check for the correct time conversion in file and server log. 8 9use strict; 10use warnings; 11use Socket; 12use Sys::Hostname; 13 14(my $host = hostname()) =~ s/\..*//; 15 16# 2016-09-28T15:38:09Z 17my $iso = qr/20\d\d-\d\d-\d\dT\d\d:\d\d:\d\d\.\d\d\dZ/; 18my $bsd = qr/\w\w\w [ \d]\d \d\d:\d\d:\d\d/; 19 20our %args = ( 21 client => { 22 connect => { domain => AF_UNIX }, 23 func => sub { 24 my $self = shift; 25 write_message($self, "no time"); 26 write_message($self, "Oct 11 22:14:15 bsd time"); 27 write_message($self, "1985-04-12T23:20:50Z iso time"); 28 write_message($self, "1985-04-12T23:20:50.52Z iso frac"); 29 write_message($self, "1985-04-12T19:20:50.52-04:00 iso offset"); 30 write_message($self, "2003-10-11T22:14:15.003Z iso milisec"); 31 write_message($self, "2003-08-24T05:14:15.000003-07:00 iso full"); 32 write_message($self, "2003-08-24T05:14:15.000000003-07:00 invalid"); 33 write_message($self, "- nil time"); 34 write_message($self, "2003-08-24T05:14:15.000003-07:00space"); 35 write_message($self, "2003-08-24T05:14:15.-07:00 nofrac"); 36 write_message($self, "2003-08-24T05:14:15.1234567-07:00 longfrac"); 37 write_message($self, "1985-04-12T23:20:50X zulu"); 38 write_log($self); 39 }, 40 }, 41 syslogd => { 42 options => ["-Z"], 43 }, 44 server => { 45 loggrep => { 46 qr/>$iso no time$/ => 1, 47 qr/>$iso bsd time$/ => 1, 48 qr/>1985-04-12T23:20:50Z iso time$/ => 1, 49 qr/>1985-04-12T23:20:50.52Z iso frac$/ => 1, 50 qr/>1985-04-12T19:20:50.52-04:00 iso offset$/ => 1, 51 qr/>2003-10-11T22:14:15.003Z iso milisec$/ => 1, 52 qr/>2003-08-24T05:14:15.000003-07:00 iso full$/ => 1, 53 qr/>$iso 2003-08-24T05:14:15.000000003-07:00 invalid$/ => 1, 54 qr/>$iso nil time$/ => 1, 55 qr/>$iso 2003-08-24T05:14:15.000003-07:00space$/ => 1, 56 qr/>$iso 2003-08-24T05:14:15.-07:00 nofrac$/ => 1, 57 qr/>$iso 2003-08-24T05:14:15.1234567-07:00 longfrac$/ => 1, 58 qr/>$iso 1985-04-12T23:20:50X zulu$/ => 1, 59 }, 60 }, 61 file => { 62 loggrep => { 63 qr/^$iso $host no time$/ => 1, 64 qr/^$iso $host bsd time$/ => 1, 65 qr/^1985-04-12T23:20:50Z $host iso time$/ => 1, 66 qr/^1985-04-12T23:20:50.52Z $host iso frac$/ => 1, 67 qr/^1985-04-12T19:20:50.52-04:00 $host iso offset$/ => 1, 68 qr/^2003-10-11T22:14:15.003Z $host iso milisec$/ => 1, 69 qr/^2003-08-24T05:14:15.000003-07:00 $host iso full$/ => 1, 70 qr/^$iso $host 2003-08-24T05:14:15.000000003-07:00 invalid$/ => 1, 71 qr/^$iso $host nil time$/ => 1, 72 qr/^$iso $host 2003-08-24T05:14:15.000003-07:00space$/ => 1, 73 qr/^$iso $host 2003-08-24T05:14:15.-07:00 nofrac$/ => 1, 74 qr/^$iso $host 2003-08-24T05:14:15.1234567-07:00 longfrac$/ => 1, 75 qr/^$iso $host 1985-04-12T23:20:50X zulu$/ => 1, 76 }, 77 }, 78); 79 801; 81