Req: Template for querying URL and returning number

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

Moderators: Developers, Moderators

Post Reply
Colosus
Posts: 13
Joined: Wed May 16, 2007 4:58 am

Req: Template for querying URL and returning number

Post by Colosus »

Hello,

I have a custom request that I haven't been able to figure out. I'm not very good at creating data queries and the templates required for this so I am hoping someone's already done something similar...

I basically need to query a URL of a host passing a parameter in the URL which will then return a single integer. I then need to graph that integer. It seemed easy to me, but I am at a loss at how to do it. Thanks.

For example... You request http://10.0.0.1/test.cgi?param=testing and it returns "3". That's it. I just need to graph that 3 every polling interval.
User avatar
gandalf
Developer
Posts: 22383
Joined: Thu Dec 02, 2004 2:46 am
Location: Muenster, Germany
Contact:

Post by gandalf »

Please find attached a script that requires wget to be installed at /usr/bin/wget (else please change the code accordingly).
It will work, if the called remote cgi script returns either a single number or a string according to cacti's rules for Data Input Methods

Code: Select all

var1:<val1> var2:<val2>
See first link of my signature for more and how to define a data template and a graph template
Reinhard
Attachments
http_get_script.pl
A perl script to call remote cgi scripts
(1.25 KiB) Downloaded 193 times
Colosus
Posts: 13
Joined: Wed May 16, 2007 4:58 am

Post by Colosus »

Thanks Gandalf. I'll give it a shot.
Colosus
Posts: 13
Joined: Wed May 16, 2007 4:58 am

Post by Colosus »

So I added all the templates and the script (which works great btw), but no RRD is being created. I added the graph template to a host and it shows up as a non-image (just the little icons and alt-text) on the host, but no graph.

I changed my log output and I don't even see the query attempt and the number of data sources hasn't changed. Any idea what I could be doing wrong?

Edit: Nevermind. Changed it to a gauge and now I'm getting some errors. I think I can get it from here.
Colosus
Posts: 13
Joined: Wed May 16, 2007 4:58 am

Post by Colosus »

Yep. All is good now. Thanks for your help and documentation Gandalf.
Post Reply

Who is online

Users browsing this forum: No registered users and 0 guests