Adding new data template destroys params of all data sources

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

Moderators: Developers, Moderators

Post Reply
opornik
Posts: 15
Joined: Thu Apr 13, 2006 8:00 am
Location: Poland/Warsaw

Adding new data template destroys params of all data sources

Post by opornik »

Hi,
I have a problem when trying to add a data template. I never used it before - data sources were enough for my purposes.
Now after creating some data template (after clicking save) all my data sources' data input methods change to the same data input method as the newly created data template. But this is only on the display because all data sources work correctly.

Attached two screenshots:
before:
Image

and after adding a data template:
Image


Fortunatelly I wrote a script to make a database and files backup every day. Otherwise I would have to change manually a few hundrets data sources and replace them correct data input methods.

My Cacti version is 0.8.6h.

At home I have Cacti 0.8.7 and almost default database with only two test datasources and have the same problem when creating new data template.

Any ideas, please?
User avatar
rony
Developer/Forum Admin
Posts: 6022
Joined: Mon Nov 17, 2003 6:35 pm
Location: Michigan, USA
Contact:

Post by rony »

Do you have all patches?

This sounds like a mysql 5.x issue that we have an offical patch for.
[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]
opornik
Posts: 15
Joined: Thu Apr 13, 2006 8:00 am
Location: Poland/Warsaw

Post by opornik »

I've solved the problem.
Actually it is the bug in Cacti documentation. There is a section named "Simplest Method of Going from Script to Graph (Walkthrough)" and there is no Data Temlates used there. I made every Data Source (over 300) without Data Temlates - I didn't need this. Now I need and when I tried to create a Data Template all my Data Source's input methods changed.
Why?
Because all of them have empty Data Template so its index is 0. Cacti have a small bug in the file "data_templates.php". It updates all data sources having the same data template index that the created one. But the created one has always index 0 at the beginning. So all data sources referenced data template index 0 are modified.
The solution is to patch one line in function form_save() in data_templates.php like this:
original one:

Code: Select all

/* update actual host template information for live hosts */
if (!is_error_message()) {
   db_execute("update data_template_data set.......
new one:

Code: Select all

if (!is_error_message() && $save2["id"]>0) {
   db_execute("update data_template_data set.......
It simple doesn't allow to update data sources during creation of data template. When data template is edited later it has index > 0 so the database can be updated.

That all.
Regards!
User avatar
TheWitness
Developer
Posts: 17007
Joined: Tue May 14, 2002 5:08 pm
Location: MI, USA
Contact:

Post by TheWitness »

Can you please open a bug at http://bugs.cacti.net? This we need a bug report to fix this properly. You can reference this post, but's it's better if you simply add the content there.

TheWitness
True understanding begins only when we realize how little we truly understand...

Life is an adventure, let yours begin with Cacti!

Author of dozens of Cacti plugins and customization's. Advocate of LAMP, MariaDB, IBM Spectrum LSF and the world of batch. Creator of IBM Spectrum RTM, author of quite a bit of unpublished work and most of Cacti's bugs.
_________________
Official Cacti Documentation
GitHub Repository with Supported Plugins
Percona Device Packages (no support)
Interesting Device Packages


For those wondering, I'm still here, but lost in the shadows. Yearning for less bugs. Who want's a Cacti 1.3/2.0? Streams anyone?
User avatar
rony
Developer/Forum Admin
Posts: 6022
Joined: Mon Nov 17, 2003 6:35 pm
Location: Michigan, USA
Contact:

Post by rony »

Accually, I will request that you add the content in the bug report. :)
[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]
opornik
Posts: 15
Joined: Thu Apr 13, 2006 8:00 am
Location: Poland/Warsaw

Post by opornik »

Post Reply

Who is online

Users browsing this forum: No registered users and 2 guests