sub tail_logs{
my ($self) = @_;
my $cmd = 'tail -n 500 /a/logs/ipsecd.log | grep NAT';
$self->execute('$cmd');
if ($self->execute($cmd)) {
return $self->get_stdout();
}
else {
die " Failed to execute $cmd";
}
}
####
sub grep {
my ($self,$logLines, @strings) = @_;
for my $string (@strings) {
if ( $logLines =~ /$string/ ) {
INFO("Found $string in ipsecd.log");
}
else {
#return false, we cound find $string
WARN("Not Found $string in ipsecd.log");
return 0;
}
}
# found all strings in the $loglines, return true.
return 1;
}
####
my @checkStrings = ('100.81.2.59:4500', 'dst:172.25.150.190:4500');
$self->{'log'} = $self->{'log_obj'}->tail_logs();
$self->{'log_verify'}= $self->{'log_obj'}->grep($self->{'log'}, @checkStrings);
if ( $self->{'log_verify'} ) {
$self->assert(
$self->{'log_verify'},
'Found info in ipsecd.logs'
);
####
[04-15 21:17:04.614251 (05026) D ipsec_processor.: 496] processOutbound: IPsec EDP-UDP (NAT-T) packet to destination - src addr:100.81.2.59:4500 dst:172.25.150.190:4500
[04-15 21:17:04.821548 (05026) D ipsec_processor.: 496] processOutbound: IPsec EDP-UDP (NAT-T) packet to destination - src addr:100.81.2.59:4500 dst:172.25.150.190:4500
[04-15 21:17:05.029262 (05026) D ipsec_processor.: 496] processOutbound: IPsec EDP-UDP (NAT-T) packet to destination - src addr:100.81.2.59:4500 dst:172.25.150.190:4500
[04-15 21:17:05.237628 (05026) D ipsec_processor.: 496] processOutbound: IPsec EDP-UDP (NAT-T) packet to destination - src addr:100.81.2.59:4500 dst:172.25.150.190:4500
[04-15 21:17:05.444636 (05026) D ipsec_processor.: 496] processOutbound: IPsec EDP-UDP (NAT-T) packet to destination - src addr:100.81.2.59:4500 dst:172.25.150.190:4500