Scripts just wont work, frustrated

Post support questions that directly relate to Linux/Unix operating systems.

Moderators: Developers, Moderators

Post Reply
stealthllama
Posts: 6
Joined: Thu Jul 21, 2005 10:30 am

Scripts just wont work, frustrated

Post by stealthllama »

I made a copy of the unix_processes.pl (which works just fine) and just replaced the ps command with a "cat" command. It just cats a txt file with one number in it.



you can see here that the number is 3000 -

[root@host scripts]# ./jcy_int.pl
3000[root@host scripts]#

As you can see it returns the data the same exact way that the native script does -

[root@host scripts]# ./unix_processes.pl
132[root@host scripts]#


Here is the script

#!/usr/bin/perl

#open(PROCESS, "ps ax | grep -c : |");
open(PROCESS, "cat /home/user/txt |");
$output = <PROCESS>;
close(PROCESS);
chomp($output);
print $output;

yet, no matter what i do I get -


02/28/2010 03:25:02 PM - SPINE: Poller[0] Host[18] ERROR: Empty result [jcyindex]: '/usr/bin/perl /var/www/cacti/scripts/jcy_int.pl'
02/28/2010 03:25:02 PM - SPINE: Poller[0] Host[18] DS[240] SCRIPT: /usr/bin/perl /var/www/cacti/scripts/jcy_int.pl, output: U


I just dont understand what the problem is here, no matter how I setup the data source, it always gives me this error, this is why i finally copied one of cacti's native scripts and tried it with a simple cat and it still didnt work.

I have tried everything, disabling selinux, both pollers, using the full path etc...

Please help!
User avatar
phalek
Developer
Posts: 2838
Joined: Thu Jan 31, 2008 6:39 am
Location: Kressbronn, Germany
Contact:

Post by phalek »

The poller is probably running as the "cacti" user who may not have the acess right for that txt file in the perl script.

To check if the script is actually called corectly try the following:

Code: Select all

#!/usr/bin/perl

#open(PROCESS, "ps ax | grep -c : |");
open(PROCESS, "echo 1234 |");
$output = <PROCESS>;
close(PROCESS);
chomp($output);
print $output;
Greetings,
Phalek
---
Need more help ? Read the Cacti documentation or my new Cacti 1.x Book
Need on-site support ? Look here Cacti Workshop
Need professional Cacti support ? Look here CereusService
---
Plugins : CereusReporting
User avatar
Howie
Cacti Guru User
Posts: 5508
Joined: Thu Sep 16, 2004 5:53 am
Location: United Kingdom
Contact:

Post by Howie »

Also, for situations like cron and the cacti poller, where you don't know exactyl what the environment is, it's a good idea to use the full path for things like cat and grep, just in case.

Also, you don't need the cat at all if all you are doing is reading from a file.

Code: Select all

open(PROCESS, "/home/user/txt") || die($!);
$output = <PROCESS>;
close(PROCESS);

chomp($output);
print $output; 
Weathermap 0.98a is out! & QuickTree 1.0. Superlinks is over there now (and built-in to Cacti 1.x).
Some Other Cacti tweaks, including strip-graphs, icons and snmp/netflow stuff.
(Let me know if you have UK DevOps or Network Ops opportunities, too!)
stealthllama
Posts: 6
Joined: Thu Jul 21, 2005 10:30 am

Post by stealthllama »

thanks for the info! I will try this out.
stealthllama
Posts: 6
Joined: Thu Jul 21, 2005 10:30 am

Post by stealthllama »

phalek wrote:The poller is probably running as the "cacti" user who may not have the acess right for that txt file in the perl script.

sigh, sometimes its the simplest things that slip by, I can't believe that I didn't realize this earlier.... Rookie mistake. 2 hours down the tubes, lol.
Post Reply

Who is online

Users browsing this forum: No registered users and 0 guests