Problems importing XML template

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

Moderators: Developers, Moderators

Post Reply
paul.miles01
Posts: 3
Joined: Tue Apr 21, 2009 9:51 am

Problems importing XML template

Post by paul.miles01 »

Hello,

I've written a script to generate XML config files to be imported into cacti.

I'm seeing two issues when I try and import the config :

Error: XML: Cannot locate type code.
Error: XML: Hash version does not exist.

Please see attachment forcopy of my script generated XML file.

I'd welcome any help/comments on this as i'm well stumped.

Thanks,

Paul
Attachments
austria.xml
(22.15 KiB) Downloaded 240 times
User avatar
BSOD2600
Cacti Moderator
Posts: 12171
Joined: Sat May 08, 2004 12:44 pm
Location: USA

Post by BSOD2600 »

Search the forums -- you cannot import a newer template on and old cacti installation.
paul.miles01
Posts: 3
Joined: Tue Apr 21, 2009 9:51 am

Post by paul.miles01 »

Does this mean I can't generate the XML file using a script ?

How are the hash elements constructed ? in my script i'm just using random HEX characters - presumably, though, the hash element is a transformation of some other data.

Is there any documentation on creating XML files (rather than exporting from Cacti) ?
User avatar
BSOD2600
Cacti Moderator
Posts: 12171
Joined: Sat May 08, 2004 12:44 pm
Location: USA

Post by BSOD2600 »

That template was automatically generated by cacti, during a template export. No, you cannot manually make these.

If you want to try and recreate it inside cacti, read through the documentation site.
paul.miles01
Posts: 3
Joined: Tue Apr 21, 2009 9:51 am

Post by paul.miles01 »

Hello,

Sorry to disagree, but that template _was_ created by my rather crude perl script.

However, I've now found the answer to my original question, so incase anyone else ever needs to know :

The hash elements in the XML are formatted (to an extent).

Taken from ~/cacti/include/global_arrays.php

$hash_type_codes = array(
"round_robin_archive" => "15",
"cdef" => "05",
"cdef_item" => "14",
"gprint_preset" => "06",
"data_input_method" => "03",
"data_input_field" => "07",
"data_template" => "01",
"data_template_item" => "08",
"graph_template" => "00",
"graph_template_item" => "10",
"graph_template_input" => "09",
"data_query" => "04",
"data_query_graph" => "11",
"data_query_sv_graph" => "12",
"data_query_sv_data_source" => "13",
"host_template" => "02"
);

and

$hash_version_codes = array(
"0.8.4" => "0000",
"0.8.5" => "0001",
"0.8.5a" => "0002",
"0.8.6" => "0003",
"0.8.6a" => "0004",
"0.8.6b" => "0005",
"0.8.6c" => "0006",
"0.8.6d" => "0007",
"0.8.6e" => "0008",
"0.8.6f" => "0009",
"0.8.6g" => "0010",
"0.8.6h" => "0011",
"0.8.6i" => "0012",
"0.8.6j" => "0013",
"0.8.7" => "0014",
"0.8.7a" => "0015",
"0.8.7b" => "0016"
);

It appears that the hash elements in the XML files are made up of the appropiate two digit $hash_type_codes followed by the four digit version code, finally followed by what looks like 32 random hex characters.

I've got my script generated XML to successfully import into cacti now, although theres something a little wrong, probably with the element linking which i'm working through today. I'll post the completed script once its fully working, even though its totally unique to my environment, and is fairly crudely written, it'll probably be a good starting point for anyone else trying to do something similar.

Regards,

Paul Miles
Post Reply

Who is online

Users browsing this forum: No registered users and 1 guest