--- /dev/null
+# The client connects with TCP.
+# The syslogd writes local messages into multiple files depending on priority.
+# The syslogd writes it into a file and through a pipe.
+# The syslogd passes it via UDP to the loghost.
+# The server receives the message on its UDP socket.
+# Find the message in client, file, pipe, syslogd, server log.
+# Check that local syslog messages end up the correct priority file.
+
+use strict;
+use warnings;
+use Sys::Syslog;
+
+my %selector2messages = (
+ "syslog.*" => [qw{ start .*accepted .*close exiting.* }],
+ "syslog.debug" => [qw{ start .*accepted .*close exiting.* }],
+ "syslog.info" => [qw{ start .*accepted .*close exiting.* }],
+ "syslog.notice" => [qw{ exiting.* }],
+ "syslog.warning" => [qw{ exiting.* }],
+ "syslog.err" => [qw{ exiting.* }],
+ "syslog.crit" => [],
+ "syslog.alert" => [],
+ "syslog.emerg" => [],
+ "syslog.none" => [],
+);
+
+our %args = (
+ client => {
+ logsock => { type => "tcp", host => "127.0.0.1", port => 514 },
+ },
+ syslogd => {
+ options => ["-T", "127.0.0.1:514"],
+ conf => selector2config(%selector2messages),
+ },
+ multifile => [
+ (map { { loggrep => $_ } } (selector2loggrep(%selector2messages))),
+ ],
+);
+
+1;
"*.*;local6,local7.none" => [qw(local5.notice local5.warning local5.err)],
);
-sub selector2config {
- my %s2m = @_;
- my $conf = "";
- my $i = 0;
- foreach my $sel (sort keys %s2m) {
- $conf .= "$sel\t\$objdir/file-$i.log\n";
- $i++;
- }
- return $conf;
-}
-
-sub messages2loggrep {
- my %s2m = @_;
- my @loggrep;
- foreach my $sel (sort keys %s2m) {
- my @m = @{$s2m{$sel}};
- my (%msg, %nomsg);
- @msg{@m} = ();
- @nomsg{@messages} = ();
- delete @nomsg{@m};
- push @loggrep, {
- (map { qr/: $_$/ => 1 } sort keys %msg),
- (map { qr/: $_$/ => 0 } sort keys %nomsg),
- };
- }
- return @loggrep;
-}
-
our %args = (
client => {
func => sub {
conf => selector2config(%selector2messages),
},
multifile => [
- (map { { loggrep => $_ } } (messages2loggrep(%selector2messages))),
+ (map { { loggrep => $_ } } (selector2loggrep(%selector2messages))),
],
server => {
loggrep => { map { qr/ <$_>/ => 1 } @priorities },
-# $OpenBSD: funcs.pl,v 1.30 2016/03/21 23:23:15 bluhm Exp $
+# $OpenBSD: funcs.pl,v 1.31 2017/04/06 16:56:44 bluhm Exp $
# Copyright (c) 2010-2015 Alexander Bluhm <bluhm@openbsd.org>
#
return $downlog;
}
+sub selector2config {
+ my %s2m = @_;
+ my $conf = "";
+ my $i = 0;
+ foreach my $sel (sort keys %s2m) {
+ $conf .= "$sel\t\$objdir/file-$i.log\n";
+ $i++;
+ }
+ return $conf;
+}
+
+sub selector2loggrep {
+ my %s2m = @_;
+ my %allmsg;
+ @allmsg{map { @$_} values %s2m} = ();
+ my @loggrep;
+ foreach my $sel (sort keys %s2m) {
+ my @m = @{$s2m{$sel}};
+ my %msg;
+ @msg{@m} = ();
+ my %nomsg = %allmsg;
+ delete @nomsg{@m};
+ push @loggrep, {
+ (map { qr/: $_$/ => 1 } sort keys %msg),
+ (map { qr/: $_$/ => 0 } sort keys %nomsg),
+ };
+ }
+ return @loggrep;
+}
+
sub check_logs {
my ($c, $r, $s, $m, %args) = @_;