Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

(See bottom for updates...)

I've written a data input method script for Cacti (in Ruby, to collects stats from beanstalkd) and it works from the command line (returning a single simple integer, as documented here) when run as the cacti user account but the Cacti tool itself isn't harvesting any data and there's nothing in the logs.

Here's the Data Input Methods set-up: Cacti Data Input Method

And here's the resulting Graph (after it's been added to a host's chart template and left to run long enough to gather data): Cacti Graph

Update #1: Looks like Cacti might be stripping the environment:

sudo su - cacti -c 'env -i /script/beanstat --host 10.11.12.13 --port 11300 --stat current-waiting'
/script/beanstat:4:in `require': no such file to load -- rubygems (LoadError)
    from /script/beanstat:4

If that's the case, how might I work around it?

Update #2: This response on stackoverflow.com seems to have resolved the environment issue, but still no data in the chart.

Update #3: Thanks to @Heath's suggestion I bumped up the poller logging level and caught this:

WARNING: Result from CMD not valid.  Partial Result: U

Haven't had any luck Googling up what "Partial Result: U" means. The script just prints a single integer value.

Update #4: I did finally get this working. The core issue was the lack of environment when the shell script runs. I had to resolve that by prefixing my Ruby script with the following lines:

#!/bin/sh
PATH=/usr/local/bin:$PATH
exec ruby -x"/full/path/to/script/directory" $0 "$@"
#!/usr/bin/env ruby

And the secondary issue was the proper configuration of the Data Input Methods (one for each separate metric I wanted to collect, even though they all used the same script) which feeds the Data Sources which feeds the Data Templates (or vice versa, I'm still not clear on that) which feeds the Graph Templates which need to be assigned to the Devices then added to the Graph Trees. In summary, it's a major debacle with crap for documentation and I hope to never have to do it again.

Update #5: I've shared my script on GitHub http://github.com/trak3r/cacti-beanstalkd-script

share|improve this question
add comment

1 Answer

up vote 4 down vote accepted
+100

When I was trying to debug a custom script, I found it helpful to have the script append some information to a temp file every time it was run; that way I could make sure it was being called the way I expected. Things like the cmd line args, environment, and what value(s) it was going to return. You also might want to redirect stderr to a log file to catch error output from the script.

I see you made a Data Input Method and a Graph Template; did you also make a Data Template?

share|improve this answer
    
Forgot to mention; have you tried increasing the poller logging level? –  Heath Oct 14 '09 at 15:53
    
Yup I also made a Data Template; IIRC it was a prerequisite to adding the data points to the Graph Template. –  Teflon Ted Oct 14 '09 at 22:04
    
Good idea on the poller logging level; I just bumped it up a notch. Thanks. –  Teflon Ted Oct 14 '09 at 22:05
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.