CACTID: Poller[0] Host[1] ERROR: Empty result
Moderators: Developers, Moderators
I am not using any OS commands.
values.txt File contains:
20
5
25
My Script (I am just printing out the first number from the file):
values.txt File contains:
20
5
25
My Script (I am just printing out the first number from the file):
Code: Select all
#!/usr/bin/perl
$stats = "./values.txt";
my $counter = 0;
my $result = "";
@var = ();
open(STATFILE,"< $stats") or die "Can't open $stats for read:$!\n";
while ($line = <STATFILE>) {
chop $line;
# print "$line\n";
$var[$counter] = $line;
$counter++;
}
close(STATFILE);
print $var[0];
- Attachments
-
- dataTemp.JPG (184.47 KiB) Viewed 2957 times
-
- dataInput.JPG (132.28 KiB) Viewed 2958 times
I tried putting my script in the unix_users.pl script (since I am graphing that one), but I still get the errors. What is different between my output and the output from the unix_users script? They both return numbers... Here is the unix_users.pl script (this works, mine above doesn't).
Code: Select all
#!/usr/bin/perl
my $grep_string = $ARGV[0];
chomp $grep_string;
if ($grep_string eq '') {
open(PROCESS, "who | grep -c : |");
}else{
open(PROCESS, "who | grep : | grep -c $grep_string |");
}
$output = <PROCESS>;
close(PROCESS);
chomp($output);
print $output;
Re: CACTID: Poller[0] Host[1] ERROR: Empty result
I had the same problem. I have this problem with CRON jobs as well when I schedule perl scripts.
In our company we are only allowed full access to /apps/local so Perl modules must be installed under /apps/local/perl so I need to run the profile so set environment variables before the script is invoked.
Instead of "/usr/bin/perl /apps/local/cacti/scripts/scriptx.pl" I need to use:
". ~/.profile;/usr/bin/perl /apps/local/cacti/scripts/scriptx.pl"
One of the commands in profile sets the perl library path:
export PERL5LIB=/apps/local/perl/lib/perl5/site_perl/5.8.8:/apps/local/perl/lib64/perl5/site_perl/5.8.8/x86_64-linux-thread-multi
So my scripts fail when I forget to add that line in the Cacti command.
So it is not only rights that stops a perl script from running.
In our company we are only allowed full access to /apps/local so Perl modules must be installed under /apps/local/perl so I need to run the profile so set environment variables before the script is invoked.
Instead of "/usr/bin/perl /apps/local/cacti/scripts/scriptx.pl" I need to use:
". ~/.profile;/usr/bin/perl /apps/local/cacti/scripts/scriptx.pl"
One of the commands in profile sets the perl library path:
export PERL5LIB=/apps/local/perl/lib/perl5/site_perl/5.8.8:/apps/local/perl/lib64/perl5/site_perl/5.8.8/x86_64-linux-thread-multi
So my scripts fail when I forget to add that line in the Cacti command.
So it is not only rights that stops a perl script from running.
Who is online
Users browsing this forum: No registered users and 4 guests