script for add graph_item

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

Moderators: Developers, Moderators

Post Reply
inge
Posts: 19
Joined: Thu Dec 21, 2006 5:40 am
Location: germany

script for add graph_item

Post by inge »

Hello all there,

I am trying to write a PHP script.
it should automatically adjust graphing when the network environment is changing.

For example, add a new line in an existing graph when a new entry in an snmp table is resulted by an snmp query.

Or add a new stack in an existing graph which e. g. accumulates some values of some devices, when a new device is added to Cacti.

Is there a possible or even a given way to do this within Cacti?

Do I have to insert data into some mysql tables from Cacti scheme or can i use the PHP API for that?

Thanks for any suggestions
i.
inge
Posts: 19
Joined: Thu Dec 21, 2006 5:40 am
Location: germany

Post by inge »

maybe an appropriate insert for the existing local_graph_id in the graph_templates_item table is the best way to automatically add new lines/stacks to existing graphs by script when the environment is changing.

(or delete if observed network-objects were dropped out)


cu in the core
i.
bitgod
Posts: 25
Joined: Thu Mar 31, 2005 2:03 pm
Location: Texas, USA

Post by bitgod »

Just jumpin in to say I'm going to be looking into this as well.

my goal is to script something (or find an existing script) that will "auto-magically" add a new graph to a device if a snmp query discovers that a new interface or a new rule has been created that isnt already being graphed under the device.

When you help manage thousands of devices that can change daily, its a bit difficult to update a device manually each time it changes... boo.

Might I add it seems this would be a useful optional function of cacti. :) "Auto update changes made to device. yes/no"
cigamit
Developer
Posts: 3369
Joined: Thu Apr 07, 2005 3:29 pm
Location: B/CS Texas
Contact:

Post by cigamit »

Look at the discovery plugin, as it sort of does this. It can apply a host template to a device, and then query all datasources for that template, and create all graphs. I haven't tested it, but you should be able to "re-query" the device and create all new graphs.
inge
Posts: 19
Joined: Thu Dec 21, 2006 5:40 am
Location: germany

thx

Post by inge »

thx cigamit,
i tried the discovery plugin but only the graphs for the Associated Graph Templates were created. The Associated Data Queries were not executed and no graphs for them were build.
inge
Posts: 19
Joined: Thu Dec 21, 2006 5:40 am
Location: germany

Post by inge »

overhasty. :oops:
Maybe the queries were executed but the result was empty ?!?
cigamit
Developer
Posts: 3369
Joined: Thu Apr 07, 2005 3:29 pm
Location: B/CS Texas
Contact:

Post by cigamit »

I have been able to create graphs using both. Does running the query manually give you graphs?
inge
Posts: 19
Joined: Thu Dec 21, 2006 5:40 am
Location: germany

Post by inge »

no, running the query just tells what graphs are possible.
i have the automatic graphs now :)

but What i don't understand enough is the relation between query result and graph template.

i used a host template with the associated query, and with some graph templates associated to that query.

do i have to associate the wanted graph template to that host template when using the discovery template?

i thought so, but in addition to the wanted graphs, one broken graph was created, missing the data source.
:roll:

br
i.
bitgod
Posts: 25
Joined: Thu Mar 31, 2005 2:03 pm
Location: Texas, USA

Post by bitgod »

Thank you, cigamit. Sounds like just the thing i needed.

edit: dang, i jumped the gun. This locates new devices on a subnet but I didn't read anywhere that it will discover new interfaces on an existing device.
cigamit
Developer
Posts: 3369
Joined: Thu Apr 07, 2005 3:29 pm
Location: B/CS Texas
Contact:

Post by cigamit »

bitgod wrote:Thank you, cigamit. Sounds like just the thing i needed.

edit: dang, i jumped the gun. This locates new devices on a subnet but I didn't read anywhere that it will discover new interfaces on an existing device.
In its present form it will not do that, but the internal function will if you use them in your own plugin. Instead of having it loop through a subnet, have it loop through the current devices and re-poll each one.
Post Reply

Who is online

Users browsing this forum: No registered users and 2 guests