To list the graph and data source properties for a specific Graph Id:

select d.title as 'Graph Name',a.local_graph_id as 'Graph Id',c.name as 'Data Source Name',b.local_data_id as 'Data Source Id',c.active as 'Active',c.data_source_path as 'RRD File'
from graph_templates_item a
left join data_template_rrd b on (b.id = a.task_item_id)
left join graph_templates_graph d on (d.local_graph_id = a.local_graph_id)
left join data_template_data c on (c.local_data_id = b.local_data_id)
where a.local_graph_id = 22093
group by a.local_graph_id;

** Please note the local_graph_id value


To list the graph and data source properties for a specific Data Source Id:

select d.title as 'Graph Name',a.local_graph_id as 'Graph Id',c.name as 'Data Source Name',b.local_data_id as 'Data Source Id',c.active as 'Active',c.data_source_path as 'RRD File'
from graph_templates_item a
left join data_template_rrd b on (b.id = a.task_item_id)
left join graph_templates_graph d on (d.local_graph_id = a.local_graph_id)
left join data_template_data c on (c.local_data_id = b.local_data_id)
where b.local_data_id = 22023
group by b.local_data_id;

** Please note the local_data_id value


Tidying Up Archived BOD Requests

To 'turn off' data sources of graphs that have been moved to the Archive_BOD_Requests graph tree

update data_template_data
set active = ''
where local_data_id in (select `Data Source Id` from archived_bod_request_view);

*** Note that the view archived_bod_request_view is created with the following query:

select d.title as 'Graph Name',a.local_graph_id as 'Graph Id',c.name as 'Data Source Name',b.local_data_id as 'Data Source Id',c.active as 'Active',c.data_source_path as 'RRD File'
from graph_templates_item a
left join data_template_rrd b on (b.id = a.task_item_id)
left join graph_templates_graph d on (d.local_graph_id = a.local_graph_id)
left join data_template_data c on (c.local_data_id = b.local_data_id)
where a.local_graph_id in (select local_graph_id from graph_tree_items where graph_tree_id = 38 and rra_id <> 0 order by local_graph_id)
group by a.local_graph_id;

followed by:

select concat("rm -f /opt/cacti/rra/",SUBSTRING_INDEX(data_source_path,'/',-1)) as 'command'
from data_template_data
where name like '%_BoD_urn_uuid%'
and active <> 'on';

Export the data into a file called cleanup.sh and copy this into the /tmp folder on both production servers. Login to both servers and sudo as root. Navigate to the /tmp folder and change the chmod of the file to 755 then execute ./cleanup.sh. This will delete all the RRD files of the Archived BoD Requests.


  • No labels