Help with multiple-output script

Templates, scripts for templates, scripts and requests for templates.

Moderators: Developers, Moderators

Post Reply
slack
Posts: 17
Joined: Thu May 18, 2006 12:52 pm

Help with multiple-output script

Post by slack »

Total newbie here.

I wrote a script that queries an unmanaged switch via HTTP to get RX, TX, RX Error, and TX Error for 26 ports.

The output of my script looks like this:

NSSTX01:0 NSSRX01:0 NSSTXError01:0 NSSRXError01:0 NSSTX13:0 NSSRX13:0 NSSTXError13:0 NSSRXError13:0 NSSTX02:0 NSSRX02:0 NSSTXError02:0 NSSRXError02:0 NSSTX14:0 NSSRX14:0 NSSTXError14:0 NSSRXError14:0 NSSTX03:0 NSSRX03:0 NSSTXError03:0 NSSRXError03:0 NSSTX15:0 NSSRX15:0 NSSTXError15:0 NSSRXError15:0 NSSTX04:0 NSSRX04:0 NSSTXError04:0 NSSRXError04:0 NSSTX16:0 NSSRX16:0 NSSTXError16:0 NSSRXError16:0 NSSTX05:0 NSSRX05:0 NSSTXError05:0 NSSRXError05:0 NSSTX17:3393512 NSSRX17:1891439 NSSTXError17:0 NSSRXError17:0 NSSTX06:0 NSSRX06:0 NSSTXError06:0 NSSRXError06:0 NSSTX18:0 NSSRX18:0 NSSTXError18:0 NSSRXError18:0 NSSTX07:0 NSSRX07:0 NSSTXError07:0 NSSRXError07:0 NSSTX19:37316883 NSSRX19:14657267 NSSTXError19:0 NSSRXError19:0 NSSTX08:0 NSSRX08:0 NSSTXError08:0 NSSRXError08:0 NSSTX20:28942902 NSSRX20:7633842 NSSTXError20:0 NSSRXError20:51 NSSTX09:0 NSSRX09:0 NSSTXError09:0 NSSRXError09:0 NSSTX21:8489458 NSSRX21:1812190 NSSTXError21:0 NSSRXError21:0 NSSTX10:0 NSSRX10:0 NSSTXError10:0 NSSRXError10:0 NSSTX22:4228496 NSSRX22:2097353 NSSTXError22:0 NSSRXError22:0 NSSTX11:0 NSSRX11:0 NSSTXError11:0 NSSRXError11:0 NSSTX23:0 NSSRX23:0 NSSTXError23:0 NSSRXError23:0 NSSTX12:0 NSSRX12:0 NSSTXError12:0 NSSRXError12:0 NSSTX24:32239881 NSSRX24:6384027 NSSTXError24:0 NSSRXError24:0 NSSTX25:89787012 NSSRX25:129053169 NSSTXError25:0 NSSRXError25:0 NSSTX26:95460716 NSSRX26:57135811 NSSTXError26:0 NSSRXError26:0

The values for each key are counters representing total bytes (for RX and TX) and total errors (TXError, RXError).

I created a script data input method in Cacti, and created output fields that match every single field above (which took forever). I'm not even sure that I needed to do that.

Now I'm lost in a maze of templates. I was able to create one graph of...well...nothing.

I would eventually like a graph for each port showing at least bytes in and out per second, five minute average, over the course of a day. I would really be happy to just get the counters to show on a graph at all.

It's important that I be able to do this without calling the script for each value. I could read the values into a file and have another script that pulls values from a specific port if that would help.

Do I have to create a data template with data source items for every single input that I specified in my data input method? Hmm, I better not ask any questions. Please advise. I've been reading the manual and following a tutorial but I'm just not getting something very basic....
slack
Posts: 17
Joined: Thu May 18, 2006 12:52 pm

Post by slack »

Is there something broken with Cacti's data input method feature?

If I just create graphs using the templates already in cacti for various devices around here, everything works like a charm.

However, when I setup my data input method and try to get this custom script running, all the sudden rrd can't create new files, even for items included in cacti (like this one, free memory on localhost: ERROR: opening '/usr/share/cacti/site/rra/localhost_mem_free_18.rrd': No such file or directory).

Not only that, but adding data sources from the defaults included with cacti stops working as well. The path to rrd files stops being filled in on the form, and I get lovely PHP errors like: Notice: Undefined variable: local_data_id in /usr/share/cacti/site/data_sources.php on line 226

I've completely uninstalled both rrdtool and cacti *twice* now, making sure all files were completely removed and the database dropped, and each time it works just fine right up until the point I start messing with the data input method. I'm not mucking from the shell at all, except to copy my one script file into the scripts directory...that's it.

I dunno what version I'm using. I don't see where it says that. It's whichever is in the stable debian repo at this time.
User avatar
BSOD2600
Cacti Moderator
Posts: 12171
Joined: Sat May 08, 2004 12:44 pm
Location: USA

Post by BSOD2600 »

User avatar
gandalf
Developer
Posts: 22383
Joined: Thu Dec 02, 2004 2:46 am
Location: Muenster, Germany
Contact:

Re: Help with multiple-output script

Post by gandalf »

slack wrote:Total newbie here.

I wrote a script that queries an unmanaged switch via HTTP to get RX, TX, RX Error, and TX Error for 26 ports.
I'd recommend to solve this using a Script Query. HAndling of all those data sources for the lot of 26 interface would bother me. Refer to http://www.cacti.net/downloads/docs/htm ... y_xml.html
Reinhard
slack
Posts: 17
Joined: Thu May 18, 2006 12:52 pm

Post by slack »

I read through your tutorial a bit before I posted.

It seems to me that if I used a data query I'd have to call my script once for each port, so 26 times. Due to the nature of cheap switches, I'd rather have the script called once. Perhaps I'll have to cron my script to dump the data to disk and then use a query against the saved data...although timing could be an issue.

Regardless though, a real show stopper seems to be that Cacti is breaking whenever I use a custom script, and the only way I can fix it is to uninstall/reinstall. Whatever happens seems to break the ability to create any new rrd. Running the debug output from the command line gives me duplicate data source errors.
User avatar
gandalf
Developer
Posts: 22383
Joined: Thu Dec 02, 2004 2:46 am
Location: Muenster, Germany
Contact:

Post by gandalf »

Not sure on this, but there may be a command line size restriction. The rrdtool create statement (see: Data Sources, turn on DEBUG mode) would be rather big. You may run this from cli as a test. But the rrdtool update statements won't be of other size. I never saw such a huge rrd file, so I can't compare
Reinhard
slack
Posts: 17
Joined: Thu May 18, 2006 12:52 pm

Post by slack »

Looks like there are specific bugs in the change log that have been fixed by newer versions of cacti (I'm using c). I'm going to grab h right now from the debian unstable branch.
User avatar
gandalf
Developer
Posts: 22383
Joined: Thu Dec 02, 2004 2:46 am
Location: Muenster, Germany
Contact:

Post by gandalf »

I would prefer the packages on the original cacti site. Some distro's had rather weird packages. Or take the SRC package, it's all php ...
Please pay attention to http://forums.cacti.net/viewtopic.php?t=13619
Reinhard
Post Reply

Who is online

Users browsing this forum: No registered users and 2 guests