Details
-
Bug
-
Resolution: Done
-
Major
-
None
-
None
-
Observium 0.14.6.5583
CentOS 6.5
MySQL 5.6.19
PHP 5.3.3
Description
The poller.php script is unable to add applications from the unix-agent. The problem is the app_status field in the Applications table is marked as NOT NULL and does not define a default value. The insert statement from the unix-agent.inc.php does not include the app_status field.
Debug output from poller.php:
SQL[SELECT COUNT(*) FROM `applications` WHERE `device_id` = '12' AND `app_type` = 'apache']
Found new application 'Apache'
SQL[INSERT INTO `applications` (`device_id`,`app_type`) VALUES ('12','apache')]
SQL[SELECT COUNT(*) FROM `applications` WHERE `device_id` = '12' AND `app_type` = 'mysql']
Found new application 'MySQL'
SQL[INSERT INTO `applications` (`device_id`,`app_type`) VALUES ('12','mysql')]
Output from MySQL:
mysql> INSERT INTO `applications` (`device_id`,`app_type`) VALUES ('12','apache');
ERROR 1364 (HY000): Field 'app_status' doesn't have a default value
Possible fix:
I was unable to find the app_status field used anywhere within the system and so set a default value as follows:
ALTER TABLE applications MODIFY COLUMN app_status VARCHAR(8) NOT NULL DEFAULT '{}';
i got this error in other cases, too. but i won't change the database.
there is'n another possible fix:
includes/dbFacile.php:
78c78
< $sql = 'INSERT INTO `' . $table . '` (`' . implode('`,`', array_keys($data)) . '`) VALUES (' . implode(',', dbPlaceHolders($data)) . ')';
—
> $sql = 'INSERT IGNORE INTO `' . $table . '` (`' . implode('`,`', array_keys($data)) . '`) VALUES (' . implode(',', dbPlaceHolders($data)) . ')';
125c125
< $sql = 'UPDATE `' . $table . '` set ';
—
> $sql = 'UPDATE IGNORE `' . $table . '` set ';