URLs for Cacti Hosts

General discussion about Plugins for Cacti

Moderators: Moderators, Developers

Post Reply
Author
Message
mactfines
Posts: 9
Joined: Thu Apr 20, 2006 4:09 pm

URLs for Cacti Hosts

#1 Post by mactfines » Sat Apr 29, 2006 9:34 am

I have made a handy change to Cacti which allows you to specify a URL for a Device, which is clickable when you're looking at Graphs.

For instance, when you're in Graphs looking at "Tree: Internet Connection Systems-> Host: Internet Router", the text 'Internet Router' will be a link which will open to the URL you specified for that Device.

Download the .tgz file here, save it to your cacti directory, un-tar-gzip it, and read the readme.txt file. (The .tgz file just contains the patch .diff file and a readme.txt file). Make sure you read the readme.txt file, as you have to add a field to the host table in the cacti database for the host's url.

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

#2 Post by gandalf » Sat Apr 29, 2006 10:53 am

I love the idea and tried your patch.
When patching using the given instructions, the pgm pathc asks me for the "real" file to be patched (nothing, that worries me, but may disturb others). And the instruction for changing the db should read

Code: Select all

mysql -u cactiuser -p cacti
instead of

Code: Select all

mysql -u cactiuser -p
(or use cacti is required).
And I should mention, that the URL to be entered into the Devices Section must look like http://..., else it would simply be appended to cacti's own URL.
Did you already think about using cacti's variables for that? E.g. sth like http://|host_hostname|. This might as well be a nice default?

As I'm thinking about such an Add-On since ages, I'd also like some feature like appending the Data Template Name/Graph Template Name/Host Template Name etc. in building the requested URL, so to say http://|host_hostname|/|host_hosttemplate| or http://|host_hostname|/|host_graphtemplate|. http://|host_graphtemplate| would be nice as an additional link to reference e.g. some nice texts describing this very Graph Template and so on.

Of course, all this ideas lack some fundamental design.
Would like to hear your ideas!

Reinhard

mactfines
Posts: 9
Joined: Thu Apr 20, 2006 4:09 pm

#3 Post by mactfines » Sat Apr 29, 2006 4:42 pm

Thanks for taking the time to look at it.

I fixed the instructions in the readme file for the MySQL commands.
I also fixed the instructions and the patch for the patch command so users won't get prompted for a filename.
I also modified the description for the URL field on the web page so it specifically states the URL has to begin with http:// or ftp://, etc.

I also changed it so that by default, http://<hostname> will be set as the URL if it is left blank, and created a checkbox just below that to disable URLs completely.

Thanks for the suggestions, I put them all in. Please take another look and tell me what you think!

Ted

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

#4 Post by gandalf » Sun Apr 30, 2006 4:56 am

I forwarded your Add-On to the devs to get their response. They suggest to create a plugin for this. So I will add this to the list of To-Do's but will wait for cacti 0.9.0 to become available as some more hooks are needed for this. Let me have a look at your last changes
Reinhard

PS: It would be nice to publish the tgz as an attachment to your post to keep all resources within this forum

mactfines
Posts: 9
Joined: Thu Apr 20, 2006 4:09 pm

#5 Post by mactfines » Sun Apr 30, 2006 7:57 am

OK, great. Here is the latest .tar file (this forum wouldn't allow .tgz files for some reason).
Attachments
cacti_with_urls_0.8.6h.tar
(10 KiB) Downloaded 260 times

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

#6 Post by gandalf » Sun Apr 30, 2006 9:39 am

I did check this. But as I had already applied your first patch. there was some manual intervention required. Now this works fine. But the new feature to take the hostname as default URL does not work (or did I mis sth?)
Reinhard

mactfines
Posts: 9
Joined: Thu Apr 20, 2006 4:09 pm

#7 Post by mactfines » Sun Apr 30, 2006 9:58 am

I think you may have missed it. I tried out the new patch on a clean install and everything seemed to work.

Try restoring the original versions of these files and running the patch again:
host.php
lib/api_device.php
lib/html_tree.php
include/config_form.php

I'll upload a tar of just these files, taken straight from the cacti download file.
Attachments
origfiles.tar
(110 KiB) Downloaded 306 times

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

#8 Post by gandalf » Sun Apr 30, 2006 11:39 am

Now I realized my error. The replacement id done when editing the device, not when calling the Graphs Tree for that Device. Sorry for my mistake. I confirm your feature.
Reinhard

Post Reply