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

Script Agent - MySQL - Undefined array key "client"

Details

    • Bug
    • Resolution: Unresolved
    • Blocker
    • None
    • None
    • Default
    • None

    Description

      Run Script:

       

      ./mysql
      PHP Warning:  Undefined array key "client" in /usr/lib/observium_agent/local/mysql.cnf on line 19
      PHP Warning:  Trying to access array offset on value of type null in /usr/lib/observium_agent/local/mysql.cnf on line 19
      PHP Warning:  Undefined array key "client" in /usr/lib/observium_agent/local/mysql.cnf on line 20
      PHP Warning:  Trying to access array offset on value of type null in /usr/lib/observium_agent/local/mysql.cnf on line 20
      

      SO:

      cat /etc/os-release
      PRETTY_NAME="Debian GNU/Linux 12 (bookworm)"
      NAME="Debian GNU/Linux"
      VERSION_ID="12"
      VERSION="12 (bookworm)"
      VERSION_CODENAME=bookworm
      ID=debian
      HOME_URL="https://www.debian.org/"
      SUPPORT_URL="https://www.debian.org/support"
      BUG_REPORT_URL="https://bugs.debian.org/"

      MySQL Config:

      cat /etc/mysql/debian.cnf
      # THIS FILE IS OBSOLETE. STOP USING IT IF POSSIBLE.
      # This file exists only for backwards compatibility for
      # tools that run '--defaults-file=/etc/mysql/debian.cnf'
      # and have root level access to the local filesystem.
      # With those permissions one can run 'mariadb' directly
      # anyway thanks to unix socket authentication and hence
      # this file is useless. See package README for more info.
      [client]
      host     = localhost
      user     = root
      [mysql_upgrade]
      host     = localhost
      user     = root
      # THIS FILE WILL BE REMOVED IN A FUTURE DEBIAN RELEASE.
      

      Attachments

        Activity

          [OBS-4946] Script Agent - MySQL - Undefined array key "client"

          Sorry, the php version was missing.

          php -v
          PHP 8.2.26 (cli) (built: Nov 25 2024 17:21:51) (NTS)
          Copyright (c) The PHP Group
          Zend Engine v4.2.26, Copyright (c) Zend Technologies
              with Zend OPcache v8.2.26, Copyright (c), by Zend Technologies

          vsc55 Javier Pastor added a comment - Sorry, the php version was missing. php -v PHP 8.2 . 26 (cli) (built: Nov 25 2024 17 : 21 : 51 ) (NTS) Copyright (c) The PHP Group Zend Engine v4. 2.26 , Copyright (c) Zend Technologies     with Zend OPcache v8. 2.26 , Copyright (c), by Zend Technologies
          vsc55 Javier Pastor added a comment - - edited

          Fix:

          Edit file /usr/lib/observium_agent/local/mysql.cnf

          <?php
          // Observium MySQL Agent Script -> Config File
          // (c) 2012, Tom Laermans for Observium (www.observium.org)
          // Autodetect user/pass on Debian, please configure if other distro.
          $mysql_ini  = null;
          if (is_readable('/etc/mysql/debian.cnf'))
          {
                  $mysql_ini = preg_replace('/^\s*#/', ';', file_get_contents('/etc/mysql/debian.cnf'));
          }
          else if (is_readable('/root/.my.cnf'))
          {
                  $mysql_ini = preg_replace('/^\s*#/', ';', file_get_contents('/root/.my.cnf'));
          }
          $mysql_cnf  = $mysql_ini ? parse_ini_string($mysql_ini, true) : [];
          $mysql_user = $mysql_cnf['client']['user'] ?? 'root';
          $mysql_pass = $mysql_cnf['client']['password'] ?? ($mysql_cnf['client']['pass'] ?? '');
          // EOF
          

           

           

          vsc55 Javier Pastor added a comment - - edited Fix: Edit file /usr/lib/observium_agent/local/mysql.cnf <?php // Observium MySQL Agent Script -> Config File // (c) 2012, Tom Laermans for Observium (www.observium.org) // Autodetect user/pass on Debian, please configure if other distro. $mysql_ini  = null ; if (is_readable( '/etc/mysql/debian.cnf' )) {         $mysql_ini = preg_replace( '/^\s*#/' , ';' , file_get_contents( '/etc/mysql/debian.cnf' )); } else if (is_readable( '/root/.my.cnf' )) {         $mysql_ini = preg_replace( '/^\s*#/' , ';' , file_get_contents( '/root/.my.cnf' )); } $mysql_cnf  = $mysql_ini ? parse_ini_string($mysql_ini, true ) : []; $mysql_user = $mysql_cnf[ 'client' ][ 'user' ] ?? 'root' ; $mysql_pass = $mysql_cnf[ 'client' ][ 'password' ] ?? ($mysql_cnf[ 'client' ][ 'pass' ] ?? '' ); // EOF    

          General questions and device support can be discussed in our Discord channel, click here to join.


          Please make and attach additional information about the device:

          • full snmp dump from device:

            snmpwalk -v2c -c <community> -t 3 -Cc --hexOutputLength=0 -Ih -ObentxU <hostname> .1 > myagent.snmpwalk
            snmpwalk -v2c -c <community> -t 3 -Cc --hexOutputLength=0 -Ih -ObentxU <hostname> .1.3.6.1.4.1 >> myagent.snmpwalk

            If device not support SNMP version 2c, replace -v2c with -v1.

          • If you have problems with discovery or poller processes, please do and attach these debugs:

            ./discovery.php -d -h <device>
            ./poller.php -d -h <device>

          • additionally attach device and/or vendor specific MIB files

          This comment is added automatically.

          bot Observium Bot added a comment - General questions and device support can be discussed in our Discord channel, click here to join . Please make and attach additional information about the device: full snmp dump from device: snmpwalk -v2c -c <community> -t 3 -Cc --hexOutputLength=0 -Ih -ObentxU <hostname> .1 > myagent.snmpwalk snmpwalk -v2c -c <community> -t 3 -Cc --hexOutputLength=0 -Ih -ObentxU <hostname> .1.3.6.1.4.1 >> myagent.snmpwalk If device not support SNMP version 2c, replace -v2c with -v1. If you have problems with discovery or poller processes, please do and attach these debugs: ./discovery.php -d -h <device> ./poller.php -d -h <device> additionally attach device and/or vendor specific MIB files This comment is added automatically.

          People

            landy Mike Stupalov
            vsc55 Javier Pastor
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

            Dates

              Created:
              Updated: