#1
  1. Known to taste like chicken
    Devshed Newbie (0 - 499 posts)

    Join Date
    Aug 2003
    Location
    In front of my computer
    Posts
    399
    Rep Power
    311

    Cacti custom perl script


    Hey guys,

    I've done a lot of coding over the years, however I am currently working on my 2nd ever perl script.

    What I am doing is building a custom Cacti graph which gets it's data from my perl script. When I run my script at the command line it works fine, however when it is called from cacti it graphs the result as 0.

    I have narrowed the issue down to an SSH call in the script that looks like the below:

    Code:
    my $result = `/usr/bin/ssh -i /path/to/dsa_key root\@x.x.x.x "/path/to/remote/script | /bin/grep my_data"`;
    #my $result = "data I should get back from the above line";
    if I use the commented line everything works fine in Cacti and I get my nice shiny graph. If I use the SSH command line it works fine from the command line, but does not work when Cacti calls the script. I am completely at a loss as to what is wrong, and I'm not overly sure if it's my lack of knowledge in perl, or lack of knowledge in Cacti that's causing me problems.

    I thought it may have been a permissions issue on the script, but I have tried 0644, 0755 and 0777 and all of them give me a 0 result in the graph.

    Any help is much appreciated.
    "Take thy beak from out my heart, and take thy form from off my door" - Homer J Simpson / Edgar Allan Poe

    Looking for a project Idea?
  2. #2
  3. Known to taste like chicken
    Devshed Newbie (0 - 499 posts)

    Join Date
    Aug 2003
    Location
    In front of my computer
    Posts
    399
    Rep Power
    311

    Thumbs up


    I'd obviously spent too long looking at this last night, when I looked with fresh eyes this morning I found the problem pretty easily.

    The problem was with the SSH key being used, or more accurately I forgot that the script would be called by the www-data user when cacti ran, and as root when I ran it in the command line. I su'd to www-data and found the issue, generated a new key pair for that user and BAM, nice shiny stats in Cacti.
    "Take thy beak from out my heart, and take thy form from off my door" - Homer J Simpson / Edgar Allan Poe

    Looking for a project Idea?

IMN logo majestic logo threadwatch logo seochat tools logo