Uploaded image for project: 'Observium'
  1. Observium
  2. OBS-894

app_status field in Applications table does not have a default value

Details

    • Bug
    • Resolution: Done
    • Major
    • None
    • None
    • Poller
    • 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 '{}';

      Attachments

        Activity

          [OBS-894] app_status field in Applications table does not have a default value
          StbX Steffen Brandemann added a comment - - edited

          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 ';

          StbX Steffen Brandemann added a comment - - edited 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 ';

          This is caused by an overly strict setting in your mysql.cnf. Normal installs of MySQL will allow a field with no default to not be set in an INSERT, but there is a setting to disable this behaviour. Yours has it set

          We've seen this set once before on a package from Oracle.

          adama Adam Armstrong added a comment - This is caused by an overly strict setting in your mysql.cnf. Normal installs of MySQL will allow a field with no default to not be set in an INSERT, but there is a setting to disable this behaviour. Yours has it set We've seen this set once before on a package from Oracle.

          People

            adama Adam Armstrong
            gamestuf Jim Johnson
            Votes:
            1 Vote for this issue
            Watchers:
            4 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: