I have a perl code for searching sites from apache2 server and checking ssl certificate expiration days for each site.
code gives right result if I run it on node shell but running from solarwinds SAM templates scrip editor (GET SCRIPT OUTPUT), i'll get error "No fields were recognized in the script output:" and then desired result. On Component Monitor page i'll get same error.
Here is my code. I have stripped all logic for discovering sites off to keep code as simple as possible.
Does anybody know what this error mean? Or any hint for debugging since code itself works on shell?
My guess is that there is something wrong in foreach loop.
#!/usr/bin/perl
use warnings;
my $sites = 'alxx.xx.xxet.fi asxx.xx.xxet.fi dixx.xx.xxet.fi kaxx.xx.xxet.fi';
my $PORT = 443;
foreach my $i (split /\s+/, $sites) {
my $target_date = `echo Q | openssl s_client -servername localhost -connect $i:443 2>/dev/null | openssl x509 -noout -dates | sed -n -e 's/^.*notAfter=//p'`;
chomp $target_date;
my $target = int(`date -u --date "$target_date" +%s`);
my $today = time();
my $days = int (($target - $today)/86400) ;
print "Statistic.$i: $days\n";
print "Message.$i: Cert expires in $days days\n";
}
exit 0;