NConf cannot delete from DB

Support requests, bug reports, questions etc.
Locked
harison

NConf cannot delete from DB

Post by harison » Tue Oct 20, 2009 00:06

I have Nconf working however, when I attempt to delete entries they do not delete. Take for example some of the default entries in the DB at install time: linksys-srw224p

I select delete but it does not disappear.... I have granted the following:

GRANT ALL ON nconf.* TO 'nconf'@'192.168.1.109';

Any help would be appreciated.

harison

Re: NConf cannot delete from DB

Post by harison » Tue Oct 20, 2009 18:47

I have done some digging, turned on debug and found the following--the overview page for hosts leverages the following query:

mysql> SELECT fk_id_item AS host_id, attr_value AS hostname, (SELECT attr_value FROM ConfigValues,ConfigAttrs WHERE id_attr=fk_id_attr AND attr_name="address" AND fk_id_item=host_id) AS IP, (SELECT INET_ATON(IP) ) AS BIN_IP, (SELECT attr_value FROM ConfigValues,ConfigAttrs,ConfigClasses,ItemLinks WHERE id_attr=ConfigValues.fk_id_attr AND naming_attr="yes" AND ConfigValues.fk_id_item=fk_item_linked2 AND id_class=fk_id_class AND config_class="nagios-collector" AND ItemLinks.fk_id_item=host_id) AS collector, (SELECT attr_value FROM ConfigValues,ItemLinks,ConfigAttrs,ConfigClasses WHERE ConfigValues.fk_id_item=ItemLinks.fk_item_linked2 AND id_attr=ConfigValues.fk_id_attr AND naming_attr="yes" AND id_class=fk_id_class AND config_class="os" AND ItemLinks.fk_id_item=host_id) AS os, (SELECT ConfigValues.fk_id_item FROM ConfigValues,ItemLinks,ConfigAttrs,ConfigClasses WHERE ConfigValues.fk_id_item=ItemLinks.fk_item_linked2 AND id_attr=ConfigValues.fk_id_attr AND naming_attr="yes" AND id_class=fk_id_class AND config_class="os" AND ItemLinks.fk_id_item=host_id) AS os_id, (SELECT attr_value FROM ConfigValues,ItemLinks,ConfigAttrs,ConfigClasses WHERE ConfigValues.fk_id_item=ItemLinks.fk_item_linked2 AND id_attr=ConfigValues.fk_id_attr AND attr_name="icon_image" AND id_class=fk_id_class AND config_class="os" AND ItemLinks.fk_id_item=host_id) AS os_icon FROM ConfigValues,ConfigAttrs,ConfigClasses WHERE id_attr=fk_id_attr AND naming_attr="yes" AND id_class=fk_id_class AND config_class="host" ORDER BY hostname ASC LIMIT 0 , 24;
+---------+-----------------+---------------+------------+----------------+----------------+-------+-----------------------+
| host_id | hostname | IP | BIN_IP | collector | os | os_id | os_icon |
+---------+-----------------+---------------+------------+----------------+----------------+-------+-----------------------+
| 5306 | app1 | 192.168.1.107 | 3232235883 | Default Nagios | Linux | 5 | base/linux40.gif |
| 5297 | app2 | 192.168.1.108 | 3232235884 | Default Nagios | Linux | 5 | base/linux40.gif |
| 5301 | app3 | 192.168.1.110 | 3232235886 | Default Nagios | Linux | 5 | base/linux40.gif |
| 5278 | hplj2605dn | 192.168.1.30 | 3232235806 | NULL | HP Printer | 5277 | base/hp-printer40.gif |
| 5289 | linksys-srw224p | 192.168.1.253 | 3232236029 | NULL | Switch | 5257 | base/switch40.gif |
| 5260 | localhost | 127.0.0.1 | 2130706433 | Default Nagios | Linux | 5 | base/linux40.gif |
| 5268 | winserver | 192.168.1.2 | 3232235778 | NULL | Windows Server | 7 | base/win40.gif |
+---------+-----------------+---------------+------------+----------------+----------------+-------+-----------------------+
7 rows in set (0.00 sec)


As you can see it returns the above list... When I search for the particular host_id 5278 (note SELECT fk_id_item AS host_id)

mysql> SELECT * FROM ConfigItems WHERE id_item=5278;
Empty set (0.00 sec)

Something is amiss. While the id_item is gone the overview page still displays it--it would seem that nconf is not updating all the tables required when a delete is issued.

Here is a record I have NOT deleted that shows up in the overview list:

mysql> SELECT * FROM ConfigItems WHERE id_item=5297;
+---------+-------------+
| id_item | fk_id_class |
+---------+-------------+
| 5297 | 1 |
+---------+-------------+
1 row in set (0.00 sec)


Any thoughts?

harison

Re: NConf cannot delete from DB

Post by harison » Wed Oct 21, 2009 08:04

I can delete contacts, but not hosts...

harison

Re: NConf cannot delete from DB

Post by harison » Wed Oct 21, 2009 08:08

mysql 5.0.84
php 5.2.1
httpd-2.2.3-1
Red Hat Enterprise Linux ES release 4 (Nahant Update 8)
Linux 2.6.9-89.0.11.EL #1 Mon Aug 31 10:56:13 EDT 2009 i686 athlon i386 GNU/Linux

User avatar
agargiulo
NConf developer
NConf developer
Posts: 725
Joined: Fri Mar 06, 2009 17:50
Location: Zurich, Switzerland
Contact:

Re: NConf cannot delete from DB

Post by agargiulo » Tue Oct 27, 2009 12:52

HI.

It seems your MySQL version has problems with referential integrity. NConf relies heavily on InnoDB to make sure all tables are updated properly, when an item is deleted. Please make sure that InnoDB is set up properly and it is working.
As far as I know, the MySQL version supplied with RedHat 4 should be pre-configured properly. I don't know if you have tweaked any of the MySQL settings or if maybe there is a permission issue.

What has helped other users in the past was to delete the database and recreate it using the scipts under nconf/INSTALL/.
Make sure MySQL doesn't throw any errors when creating the tables. Especially check that the following directives are set:

CONSTRAINT ... FOREIGN KEY (...) REFERENCES ... (...) ON DELETE CASCADE ON UPDATE CASCADE

Locked