Hi,
I have a really simple check that runs an SSH command.
#!/usr/bin/perl
use strict;
use warnings;
#open(my $fh, '>>', 'log.txt') or die "Could not open file log.txt $!";
#print `ssh $ARGV[1]\@$ARGV[0] < sx20.txt`;
my @output = `ssh $ARGV[1]\@$ARGV[0] < sx20.txt`;
#say $fh @output;
#close $fh;
my $line;
my $result = 'UnRegistered';
foreach $line (@output) {
if ($line=~/: Registered/) {
$result='Registered';
}
}
system ("echo $result");
Really simple. It works perfectly when logged in as Zabbix from command-line, but for some reason when running as an external check in Zabbix the SSH doesn't work and returns UnRegistered.
I've set the correct rights on the script and on the directory as a whole. I've seen some posts saying to use a wrapper script to set up environmental variables, but I can't find a good example anywhere. Anyone have any pointers as to what I'm doing wrong or missing?
I have a really simple check that runs an SSH command.
#!/usr/bin/perl
use strict;
use warnings;
#open(my $fh, '>>', 'log.txt') or die "Could not open file log.txt $!";
#print `ssh $ARGV[1]\@$ARGV[0] < sx20.txt`;
my @output = `ssh $ARGV[1]\@$ARGV[0] < sx20.txt`;
#say $fh @output;
#close $fh;
my $line;
my $result = 'UnRegistered';
foreach $line (@output) {
if ($line=~/: Registered/) {
$result='Registered';
}
}
system ("echo $result");
Really simple. It works perfectly when logged in as Zabbix from command-line, but for some reason when running as an external check in Zabbix the SSH doesn't work and returns UnRegistered.
I've set the correct rights on the script and on the directory as a whole. I've seen some posts saying to use a wrapper script to set up environmental variables, but I can't find a good example anywhere. Anyone have any pointers as to what I'm doing wrong or missing?
Comment