Sparrow6.git | examples/tasks/logrorate/01/ | task.check
note: =============================================
between: { '/var/log/mariadb/mariadb.log' \s+ '{' \s* $$ } { ^^ \s* '}' \s* $$}
note: look up /var/log/mariadb/mariadb.log postrotate section
postrotate
end:
generator: <<RAKU
!raku
say "note: ", captures-full();
if matched().elems {
my $start = captures-full()[0]<index>;
say "note: postrotate section found";
say "note: \{ :{$start}: \} \{ endscript \}";
say "between: \{ :{$start}: \} \{ endscript \}";
say "note: look up mysqladmin flush-logs";
say "/usr/bin/mysqladmin flush-logs";
say "end:";
}
RAKU
between: { '/var/log/logstash-forwarder/*.err' \s+ '{' \s* $$ } { ^^ \s* '}' \s* $$}
note: look up /var/log/logstash-forwarder/*.err postrotate section
postrotate
end:
note: =============================================
generator: <<RAKU
!raku
say "note: ", captures-full();
if matched().elems {
my $start = captures-full()[0]<index>;
say "note: postrotate section found";
say "note: \{ :{$start}: \} \{ endscript \}";
say "between: \{ :{$start}: \} \{ endscript \}";
say "note: look up logstash-forwarder/*.err restart command";
say "service logstash-forwarder restart";
say "end:";
}
RAKU
between: { '/var/log/mariadb/mariadb.log' \s+ '{' \s* $$ } { ^^ \s* '}' \s* $$}
note: look up /var/log/mariadb/mariadb.log rotate parameter
regexp: ^^ \s* rotate \s+ (\d+) \s* $$
regexp: ^^ \s* rotate \s+ (\d+) \s* $$
end:
code: <<RAKU
!raku
say matched()
RAKU
generator: <<RAKU
!raku
#say "note: ", captures-full();
if matched().elems {
my $num = captures[0][0];
say "note: rotate param found, value = $num";
if $num > 1 {
say "assert: 1 rotate > 1"
} else {
say "assert: 0 rotate > 1"
}
} else {
say "note: rotate param not found";
}
RAKU