Script to create weather map config files

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

Moderators: Developers, Moderators

Post Reply
SirSwearsAlot
Posts: 1
Joined: Wed Jul 08, 2015 7:25 pm

Script to create weather map config files

Post by SirSwearsAlot »

New to Cacti...

I wish to write a script to generate Cacti weather map configuration files. I have all the data that I need - the nodes, the links between them, etc. Currently the process is being done manually and takes a lot of time. We use the port-name to get the LINK attributes TARGET, INFOURL and OVERLIBGRAPH from Cacti.

But to write a script, I am having trouble with the LINK attributes i.e. TARGET, INFOURL and OVERLIBGRAPH. What will be my local_graph_id for INFOURL and OVERLIBGRAPH? And which .rrd file from .../cacti/rra should I choose?
No one can help everyone, but everyone can help someone.
User avatar
Happiness0
Cacti User
Posts: 63
Joined: Wed Oct 29, 2014 5:01 am
Contact:

Re: Script to create weather map config files

Post by Happiness0 »

SirSwearsAlot wrote: What will be my local_graph_id for INFOURL and OVERLIBGRAPH? And which .rrd file from .../cacti/rra should I choose?
I've done a similar task, for INFOURL, you could use the id in graph_tree_items and use an url like "graph_view.php?action=tree_content&tree_id=2&leaf_id=xxx&host_group_data=" where xxx is the id in graph_tree_items. For OVERLIBGRAPH you should indeed use local_graph_id and select a particular id by filtering with the template being used by the graph you want to be displayed.

Code: Select all

        . "\tINFOURL /cacti/graph_view.php?action=tree_content&tree_id=2&leaf_id=" . $row[2]. "&host_group_data=\n"
        . "\tOVERLIBGRAPH /cacti/graph_image.php?rra_id=0&graph_height=200&graph_width=500&local_graph_id=". $row[3] . "\n"

Here is mysql query I run in my script to select the stuff I need for the hosts

Code: Select all

SELECT DISTINCT (b.id), (b.hostname), (a.id), (c.id)
       FROM graph_tree_items AS a
       LEFT OUTER JOIN host AS b
       ON b.id = a.host_id
       LEFT JOIN graph_local AS c
       ON b.id = c.host_id
       WHERE c.graph_template_id = 43 OR c.graph_template_id = 52
       ORDER BY b.hostname';
To select the proper rrd, you should use the data_local table to extract the id. Personally, I sym-linked the rrd files to have a convenient name for them to avoid having to run another MySQL query.
Post Reply

Who is online

Users browsing this forum: No registered users and 5 guests