2

I am trying to setup monit for my debian server. I have a main monitrc file in /etc/monit which at the end has include /etc/monit/conf.d/*.

In conf.d I have two files for my apache and mysql servers:

# ls -al /etc/monit/conf.d
total 16
drwxr-xr-x 2 root root 4096 Apr 15 16:03 .
drwxr-xr-x 3 root root 4096 Apr 15 16:02 ..
-rwx------ 1 root root  272 Apr 15 15:38 apache2.conf
-rwx------ 1 root root  264 Apr 15 15:47 mysql.conf

When I run monit -t (to test the configuration syntax) I get:

/etc/monit/conf.d/apache2.conf:1: Error: syntax error 'check process '

The same error occurs for the mysql configuration file if I delete/move the apache2.conf file.

# cat apache2.conf
check process apache2 with pidfile /var/run/apache2.pid
  start program = "/usr/sbin/service apache2 start"
  stop program = "/usr/sbin/service apache2 stop"
  if failed
    host localhost
    port 80
    protocol http
    request "/catalog/"
    then restart and alert

And the contents of mysql.conf

# cat mysql.conf


  check process mysqld with pidfile /var/run/mysqld/mysqld.pid
    group database
    start program = "/usr/sbin/service mysqld start"
    stop program = "/usr/sbin/service mysqld stop"
    if failed host localhost port 3306 protocol mysql then restart and alert

I have:

  • tried many variations of the conf file
  • looked at the documentation 20 times over
  • substituting in a mysqld.conf file from a public repository of common monit config files and removing the apache2 config file
  • looked over the files in hex, there's no funny characters.
  • tried both tabs and spaces.
  • removing all but the first line.
  • double-checked that /var/run/mysqld/mysqld.pid does indeed exist.
  • made sure the permissions on both monitrc and both conf.d file are 0700.

At this point I am completely perplexed as to what could possibly be causing the (not very helpful) error message, /etc/monit/conf.d/apache2.conf:1: Error: syntax error 'check process '

Shelvacu
  • 670
  • 3
  • 8
  • 17
  • It looks like you are not using any of the default locations for `monitrc`. Did you run `monit -c insert_your_monitrc_path_here` before executing `monit -t`? – Timothy Martin Apr 15 '15 at 23:51
  • @TimothyMartin I just tried that, no change. Monit does seem to be finding the files, since it reports the location of them accurately and is able to read them. – Shelvacu Apr 16 '15 at 00:09
  • I'm having the exact same issue here. – TCB13 May 24 '15 at 18:29

2 Answers2

2

I ran into this issue today. I was able to track the issue down to a second monit config file. It appears as of 5.17.1 that if a config file does not close correctly that it will throw a syntax error immediately when it tries to load the next file.

In my case I had an alert that ended with repeat every 10 and was missing the "cycles" after the number. Even though this file was invalid, it was causing a completely different file to appear as invalid.

1

Old question, and don't know if it's related, but I'm not sure you can write then restart and alert.

Pretty sure alert is already an implicit as part of restart anyways and therefore not needed.

Svish
  • 111
  • 3