I have searched through the forum, but didn't find any solution to this problem. It would be really a pain to associate each graph with corresponding datasources in 2000+ graphs or to restore from outdated backup, so I made quick and dirty fixer on top of repair_templates.php.
May be it will save a day for someone like me, so here it is.
It should be placed in cacti/cli directory and called like this:
Code: Select all
php repair_graphs.php --check --host-id=658 --data-template-id=41 --graph-template-id=2
--recreate - Delete and recreate graph items (USE THIS OPTION WITH CAUTION! Data should not be deleted, but you may corrupt all your graphs if something go wrong)
--host-id - id of desired host, can be empty to check every graph in cacti database.
--data-template-id - id of data template, required, can be viewed at cacti/data_templates.php page.
--graph-template-id - id of graph template, required, can be viewed at cacti/graph_templates.php page.
For example, I used Interface - Traffic (bits/sec) graph template (id=2) with Interface - Traffic data template (id=41).
If you are familiar with SQL, you can add --show-sql parameter to see the SQL queries which will be executed.
Use with caution! There are not much error-checking!
Cacti database backup before execution is strongly advised. (db only, rra files are intact)