Database schema... WTF?

Post general support questions here that do not specifically fall into the Linux or Windows categories.

Moderators: Developers, Moderators

Post Reply
z0s0
Posts: 5
Joined: Mon Feb 13, 2006 12:17 am

Database schema... WTF?

Post by z0s0 »

I'm trying to get my head around Cacti's DB, as my attempts to use the api_* functions have proved futile. (I need to automatically generate hosts, data sources and graphs from templates, and independently. All non SNMP, too)

Correct me if I'm wrong, but do the data_template_data and graph_templates_graph tables store both the templated data/graphs and the actual in-use data/graphs?

If yes, does that also explain how every column of note is duplicated withe a t_ prefix?

It's getting kind of late here and my brain cells are fighting eachother for oxygen... ;-)

To even get this far I had to do SQL dumps after each operation and use DIFF to work out what changes had actually been made.
User avatar
rony
Developer/Forum Admin
Posts: 6022
Joined: Mon Nov 17, 2003 6:35 pm
Location: Michigan, USA
Contact:

Post by rony »

You are correct, template and regular data is stored in the same tables. We have realised that this is an issue and next major version of cacti does this completely differently.

Also, API functions in 0.9.0 of cacti will be fully documented for developers to use.
[size=117][i][b]Tony Roman[/b][/i][/size]
[size=84][i]Experience is what causes a person to make new mistakes instead of old ones.[/i][/size]
[size=84][i]There are only 3 way to complete a project: Good, Fast or Cheap, pick two.[/i][/size]
[size=84][i]With age comes wisdom, what you choose to do with it determines whether or not you are wise.[/i][/size]
User avatar
rony
Developer/Forum Admin
Posts: 6022
Joined: Mon Nov 17, 2003 6:35 pm
Location: Michigan, USA
Contact:

Post by rony »

Also, database schema is here: http://www.cacti.net/downloads/docs/sql/
[size=117][i][b]Tony Roman[/b][/i][/size]
[size=84][i]Experience is what causes a person to make new mistakes instead of old ones.[/i][/size]
[size=84][i]There are only 3 way to complete a project: Good, Fast or Cheap, pick two.[/i][/size]
[size=84][i]With age comes wisdom, what you choose to do with it determines whether or not you are wise.[/i][/size]
addlema
Cacti User
Posts: 81
Joined: Wed Aug 18, 2004 8:26 am
Location: Bloomington, IN
Contact:

Post by addlema »

Wow.. Thats exactly what I need! Thanks for the schema!
Sherm
Posts: 5
Joined: Wed Aug 16, 2006 3:57 pm

Post by Sherm »

z0s0,

Did you ever figure out how to automatically generate data sources, hosts, and graphs from templates? I would love to know how you did it, if so.

Thanks.
wriley
Posts: 16
Joined: Fri May 19, 2006 1:17 pm
Location: Lake St Louis, MO USA
Contact:

Post by wriley »

Sherm wrote:z0s0,

Did you ever figure out how to automatically generate data sources, hosts, and graphs from templates? I would love to know how you did it, if so.

Thanks.
It's rough and ugly, but check out my post here: http://forums.cacti.net/viewtopic.php?t=14673

I used some perl and PHP to automate adding devices to cacti. It sounds like cacti 0.9 will support this in a much cleaner way.
cigamit
Developer
Posts: 3367
Joined: Thu Apr 07, 2005 3:29 pm
Location: B/CS Texas
Contact:

Post by cigamit »

Sherm wrote:z0s0,

Did you ever figure out how to automatically generate data sources, hosts, and graphs from templates? I would love to know how you did it, if so.

Thanks.
I've actually done this already for an unreleased version of my discovery plugin. Basically you create a "Discovery" template, and input the host template to use, the sysDescr string to match it with, and where into the tree to insert the host. When it scans your subnet, it finds a host, checks the sysDescr string, and if it finds a match, it applies the host template, which runs it queries, then it selects all graphs that are now possible from that host (thanks to the template) and creates them. It then inserts it into the tree for you at the specified spot.

I have alot more options I want to add before release, like for discovery templates, have the ability to match to "service checks" (ex: check if specific ports are open, certain OIDs exist, etc...). Pair this with the ability to apply multiple templates to 1 host, and you have a great "custom" host.

As an example of its usefulness in a Windows Enviroment. Say I create a template for Windows hosts. It has the basic disk and network graphs assigned and is matched via the sysDescr. Then I create a host template for "Domain Controllers" which just has a graph for the Kerberos Service. I then create a Discovery Template that checks for the Kerberos Service OID (sysDescr is blank in this template, or it can be the same as the windows template). The same thing is done for DNS Servers, HTTP server, SQL severs, etc... So now if a host is found that is both a Windows and Domain Controller, it gets all the normal graphs, and the extra service graphs that it has.

The main thing left to work out is the priority order of which one is applied last, and which tree location to place it in.

Once its done and released to the world, I also plan on taking the same concept and writing a "bulk add" plugin, which allows you to do the same thing, but with a CVS file or hosts entered by hand. At that point, if you still want something else, feel free to rip the specific functions out of the code and use it however you wish.
venkatpandiri
Posts: 9
Joined: Thu Nov 06, 2008 10:18 am

Please tell us which table the data is stored in mysql DB

Post by venkatpandiri »

Can you please tell us which table in mysql has the data of cpu, memory,network etc..,
For example if I am monitoing host1's cpu usage.
Which table does Cacti store in the mysql DB. Does it save as text format or hash format of the data.

I am new to cacti if it has been already answered please point to the link which has the information.
Thanks a lot for fast respone...
cigamit
Developer
Posts: 3367
Joined: Thu Apr 07, 2005 3:29 pm
Location: B/CS Texas
Contact:

Post by cigamit »

Its is not stored in MySQL, the actual data is stored in the RRD files in the /rra/ directory of your cacti install.
venkatpandiri
Posts: 9
Joined: Thu Nov 06, 2008 10:18 am

I need to create custom graphs using the data from cacti

Post by venkatpandiri »

Iam new to cacti. So please bear with me.
I need to create custom graphs using the data from cacti. Like overlaying the graphs from different times.
I am trying to put together a graphing solution for comparing grpahs of cpu, memory, network bandwith and other monitors usages during multiple load tests.
For example I need to compare cpu usage from test from last week to another cpu usage this week.
For doing that I was thinking of creating some custom grpahs using the cacti collected data.
Can you please advise if there is a way of accomplishing it. If there can anybody point me to the documents or links which will help in getting it done.
I would greatly appreciate if anyone answer quickly...
Thnaks a lot again.
User avatar
gandalf
Developer
Posts: 22383
Joined: Thu Dec 02, 2004 2:46 am
Location: Muenster, Germany
Contact:

Post by gandalf »

You will want to use the SHIFT option of rrdtool to overlay different timespans. Unfortunately, cacti does not support this currently. All you can do is use the timeshifter
Reinhard
Post Reply

Who is online

Users browsing this forum: No registered users and 2 guests