Cannot delete data template, says data sources using it

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

Moderators: Developers, Moderators

Post Reply
sbotnick
Posts: 38
Joined: Tue Sep 10, 2019 12:55 am

Cannot delete data template, says data sources using it

Post by sbotnick »

Hello,

I was doing some cleanup on one of my systems and I deleted some devices and their data sources when prompted. The data source template is no longer needed but I cannot delete it, it says there are two data sources using it. When you look for data sources using that template, there are none. I have run the mysqlcheck on the DB and cacti's repair_database and repair_templates, no change, no error when running the utilities. Any ideas?
netniV
Cacti Guru User
Posts: 3440
Joined: Sun Aug 27, 2017 12:05 am

Re: Cannot delete data template, says data sources using it

Post by netniV »

Did you click on the number 2 under the data sources column ? You may get the same results but it does specifically filter to the template's own sources. If it does, you'll have to do some mysql level querying to see what local data id is using that template.

Edit your data template, grab the ID from the URL
run

Code: Select all

SELECT id, data_template_id, host_id, snmp_query_id, snmp_index, orphan
FROM
	cacti_develop.data_local l where data_template_id = ?
Replace the question mark with the template id and this will give you a list of data sources. What you can then do is edit a data source, then change the ID on the end to the one from the SQL list.
Cacti Developer & Release Manager
The Cacti Group

Director
BV IT Solutions Ltd

+--------------------------------------------------------------------------+

Cacti Resources:
Cacti Website (including releases)
Cacti Issues
Cacti Development Releases
Cacti Development Documentation
sbotnick
Posts: 38
Joined: Tue Sep 10, 2019 12:55 am

Re: Cannot delete data template, says data sources using it

Post by sbotnick »

Thanks.

Yes, when I click on the "2" there are no data sources even when I look for orphaned. Looks like I've got some corruption going on in the database; I have 3 host IDs showing with that SELECT that do not appear in the GUI. I suspect this might be related to a php-fpm hang or crash I had the other day while I was working on things.
netniV
Cacti Guru User
Posts: 3440
Joined: Sun Aug 27, 2017 12:05 am

Re: Cannot delete data template, says data sources using it

Post by netniV »

Code: Select all

SELECT l.id data_local_id, l.data_template_id, l.snmp_query_id, l.snmp_index, l.orphan, l.host_id, h.id as linked_host_id, h.hostname, h.description
FROM data_local l 
LEFT JOIN host h on h.id = l.host_id
where data_template_id = ?
This should determine if there is a host or not.
Cacti Developer & Release Manager
The Cacti Group

Director
BV IT Solutions Ltd

+--------------------------------------------------------------------------+

Cacti Resources:
Cacti Website (including releases)
Cacti Issues
Cacti Development Releases
Cacti Development Documentation
sbotnick
Posts: 38
Joined: Tue Sep 10, 2019 12:55 am

Re: Cannot delete data template, says data sources using it

Post by sbotnick »

That came up empty on the problem template. To be sure, I tested against a template known to have hosts and received expected results.
netniV
Cacti Guru User
Posts: 3440
Joined: Sun Aug 27, 2017 12:05 am

Re: Cannot delete data template, says data sources using it

Post by netniV »

Then it sounds like you will have some issues with those orphaned sources. You could just remove those entries from data_local but then you'd likely have others referring to it from other tables too.
Cacti Developer & Release Manager
The Cacti Group

Director
BV IT Solutions Ltd

+--------------------------------------------------------------------------+

Cacti Resources:
Cacti Website (including releases)
Cacti Issues
Cacti Development Releases
Cacti Development Documentation
Post Reply

Who is online

Users browsing this forum: No registered users and 13 guests