Monit can't detect MySQL

The Monit webinterfcae is showing: Execution failed | Does not exist

netstat is giving me:

sudo netstat -lnp | grep mysql
tcp        0      0 127.0.0.1:33060         0.0.0.0:*               LISTEN      4643/mysqld
tcp        0      0 127.0.0.1:3306          0.0.0.0:*               LISTEN      4643/mysqld
unix  2      [ ACC ]     STREAM     LISTENING     90220    4643/mysqld          /var/run/mysqld/mysqlx.sock
unix  2      [ ACC ]     STREAM     LISTENING     90222    4643/mysqld          /var/run/mysqld/mysqld.sock

And monit -v (if this helps):

Process Name          = mysqld
 Group                = mysql, database
 Pid file             = /var/run/mysqld/mysqld.pid
 Monitoring mode      = active
 On reboot            = start
 Start program        = '/etc/init.d/mysql start' timeout 30 s
 Stop program         = '/etc/init.d/mysql stop' timeout 30 s
 Existence            = if does not exist then restart
 Depends on Service   = mysql_rc
 Depends on Service   = mysql_bin
 Port                 = if failed [localhost]:3306 type TCP/IP protocol MYSQL with timeout 15 s for 3 times within 4 cycles then restart
 Unix Socket          = if failed /var/run/mysqld/mysqld.sock type TCP protocol MYSQL with timeout 5 s for 3 times within 4 cycles then restart
 Timeout              = If restarted 5 times within 5 cycle(s) then unmonitor

File Name             = mysql_bin
 Group                = mysql
 Path                 = /usr/sbin/mysqld
 Monitoring mode      = active
 On reboot            = start
 Existence            = if does not exist then restart
 Checksum             = if failed defc97a98deb37905c97d9b5a09f9f13(MD5) then unmonitor
 Permission           = if failed 0755 then unmonitor
 UID                  = if failed 0 then unmonitor
 GID                  = if failed 0 then unmonitor

File Name             = mysql_rc
 Group                = mysql
 Path                 = /etc/init.d/mysql
 Monitoring mode      = active
 On reboot            = start
 Existence            = if does not exist then restart
 Checksum             = if failed 89a1a5b6ad710389112802fc3fbb81e1(MD5) then unmonitor
 Permission           = if failed 0755 then unmonitor
 UID                  = if failed 0 then unmonitor
 GID                  = if failed 0 then unmonitor

So even if mysql is running and active Monit can't detect it. I set the symlink with:

sudo ln -s /etc/monit/conf-available/mysql /etc/monit/conf-enabled/

Using Ubuntu 20.04

EDIT :

monit status:

Process 'mysqld'
  status                       Not monitored
  monitoring status            Not monitored
  monitoring mode              active
  on reboot                    start
  data collected               Sun, 20 Dec 2020 00:00:29

File 'mysql_bin'
  status                       OK
  monitoring status            Monitored
  monitoring mode              active
  on reboot                    start
  permission                   755
  uid                          0
  gid                          0
  size                         63.7 MB
  access timestamp             Mon, 21 Dec 2020 11:53:36
  change timestamp             Thu, 17 Dec 2020 11:52:00
  modify timestamp             Thu, 26 Nov 2020 12:03:42
  checksum                     defc97a98deb37905c97d9b5a09f9f13 (MD5)
  data collected               Mon, 21 Dec 2020 16:32:35

File 'mysql_rc'
  status                       OK
  monitoring status            Monitored
  monitoring mode              active
  on reboot                    start
  permission                   755
  uid                          0
  gid                          0
  size                         5.5 kB
  access timestamp             Mon, 21 Dec 2020 11:53:37
  change timestamp             Thu, 17 Dec 2020 11:52:05
  modify timestamp             Wed, 06 Nov 2019 18:34:43
  checksum                     89a1a5b6ad710389112802fc3fbb81e1 (MD5)
  data collected               Mon, 21 Dec 2020 16:32:35

The monit logs show as follows, nothing irregular to me. Ignore the mail error:

[UTC Dec 21 16:37:10] info     : 'apache' monitor on user request
[UTC Dec 21 16:37:10] info     : 'mysqld' monitor on user request
[UTC Dec 21 16:37:10] info     : 'nginx' monitor on user request
[UTC Dec 21 16:37:10] info     : 'inf-education-67' monitor on user request
[UTC Dec 21 16:37:10] info     : 'apache_rc' monitor on user request
[UTC Dec 21 16:37:10] info     : 'apache_bin' monitor on user request
[UTC Dec 21 16:37:10] info     : 'mysql_rc' monitor on user request
[UTC Dec 21 16:37:10] info     : 'mysql_bin' monitor on user request
[UTC Dec 21 16:37:10] info     : 'nginx_rc' monitor on user request
[UTC Dec 21 16:37:10] info     : 'nginx_bin' monitor on user request
[UTC Dec 21 16:37:10] info     : Monit daemon with PID 900 awakened
[UTC Dec 21 16:37:10] info     : Awakened by User defined signal 1
[UTC Dec 21 16:37:10] error    : Mail: Mailserver response error -- 535-5.7.8 Username and Password not accepted. Learn more at
[UTC Dec 21 16:37:10] error    : SMTP: Mailserver response error -- 535 5.7.8  https://support.google.com/mail/?p=BadCredentials f77sm22188901wmf.42 - gsmtp
[UTC Dec 21 16:37:10] error    : Alert handler failed, retry scheduled for next cycle
[UTC Dec 21 16:37:10] info     : 'nginx_bin' monitor action done
[UTC Dec 21 16:37:11] error    : Mail: Mailserver response error -- 535-5.7.8 Username and Password not accepted. Learn more at
[UTC Dec 21 16:37:11] error    : SMTP: Mailserver response error -- 535 5.7.8  https://support.google.com/mail/?p=BadCredentials y63sm24571380wmd.21 - gsmtp
[UTC Dec 21 16:37:11] error    : Event queue is full
[UTC Dec 21 16:37:11] error    : Aborting event - queue over quota
[UTC Dec 21 16:37:11] info     : 'nginx_rc' monitor action done
[UTC Dec 21 16:37:11] error    : Mail: Mailserver response error -- 535-5.7.8 Username and Password not accepted. Learn more at
[UTC Dec 21 16:37:11] error    : SMTP: Mailserver response error -- 535 5.7.8  https://support.google.com/mail/?p=BadCredentials o125sm24541891wmo.30 - gsmtp
[UTC Dec 21 16:37:11] error    : Event queue is full
[UTC Dec 21 16:37:11] error    : Aborting event - queue over quota
[UTC Dec 21 16:37:11] info     : 'mysql_bin' monitor action done
[UTC Dec 21 16:37:11] error    : Mail: Mailserver response error -- 535-5.7.8 Username and Password not accepted. Learn more at
[UTC Dec 21 16:37:11] error    : SMTP: Mailserver response error -- 535 5.7.8  https://support.google.com/mail/?p=BadCredentials m2sm22734832wml.34 - gsmtp
[UTC Dec 21 16:37:11] error    : Event queue is full
[UTC Dec 21 16:37:11] error    : Aborting event - queue over quota
[UTC Dec 21 16:37:11] info     : 'mysql_rc' monitor action done
[UTC Dec 21 16:37:11] error    : Mail: Mailserver response error -- 535-5.7.8 Username and Password not accepted. Learn more at
[UTC Dec 21 16:37:11] error    : SMTP: Mailserver response error -- 535 5.7.8  https://support.google.com/mail/?p=BadCredentials s3sm2848477wmc.44 - gsmtp
[UTC Dec 21 16:37:11] error    : Event queue is full
[UTC Dec 21 16:37:11] error    : Aborting event - queue over quota
[UTC Dec 21 16:37:11] info     : 'apache_bin' monitor action done
[UTC Dec 21 16:37:12] error    : Mail: Mailserver response error -- 535-5.7.8 Username and Password not accepted. Learn more at
[UTC Dec 21 16:37:12] error    : SMTP: Mailserver response error -- 535 5.7.8  https://support.google.com/mail/?p=BadCredentials 125sm22297314wmc.27 - gsmtp
[UTC Dec 21 16:37:12] error    : Event queue is full
[UTC Dec 21 16:37:12] error    : Aborting event - queue over quota
[UTC Dec 21 16:37:12] info     : 'apache_rc' monitor action done
[UTC Dec 21 16:37:12] error    : Mail: Mailserver response error -- 535-5.7.8 Username and Password not accepted. Learn more at
[UTC Dec 21 16:37:12] error    : SMTP: Mailserver response error -- 535 5.7.8  https://support.google.com/mail/?p=BadCredentials o23sm30549332wro.57 - gsmtp
[UTC Dec 21 16:37:12] error    : Event queue is full
[UTC Dec 21 16:37:12] error    : Aborting event - queue over quota
[UTC Dec 21 16:37:12] info     : 'inf-education-67' monitor action done
[UTC Dec 21 16:37:12] error    : Mail: Mailserver response error -- 535-5.7.8 Username and Password not accepted. Learn more at
[UTC Dec 21 16:37:12] error    : SMTP: Mailserver response error -- 535 5.7.8  https://support.google.com/mail/?p=BadCredentials v20sm28999905wra.19 - gsmtp
[UTC Dec 21 16:37:12] error    : Event queue is full
[UTC Dec 21 16:37:12] error    : Aborting event - queue over quota
[UTC Dec 21 16:37:12] info     : 'nginx' monitor action done
[UTC Dec 21 16:37:12] error    : Mail: Mailserver response error -- 535-5.7.8 Username and Password not accepted. Learn more at
[UTC Dec 21 16:37:12] error    : SMTP: Mailserver response error -- 535 5.7.8  https://support.google.com/mail/?p=BadCredentials k1sm27935712wrn.46 - gsmtp
[UTC Dec 21 16:37:12] error    : Event queue is full
[UTC Dec 21 16:37:12] error    : Aborting event - queue over quota
[UTC Dec 21 16:37:12] info     : 'mysqld' monitor action done

Solution 1:

Tyler answers on another question about this:

On Ubuntu 20.04 LTS, I found that pid-file and socket were commented out in /etc/mysql/mysql.conf.d/mysqld.cnf. I uncommented those two lines then restarted mysql with service mysql restart and monit with service monit restart and monit was successfully able to monitor the mysqld process.

It's worked for me, BTW Thank you @Tyler (I can't upvote and comment there)