1

I'm trying to configure monit on my server using chef solo. When I visit port 2812 response saying this webpage is not availble.

config/chef/files/default/monitrc

set daemon 30
set pidfile /var/run/monit_real.pid
set logfile syslog facility log_daemon
set idfile /var/monit/id
set statefile /var/monit/state
set eventqueue
    basedir /var/monit/events
    slots 100
set httpd port 2812
    allow admin:"secret"
include /etc/monit/conf.d/*

monit recipe

package 'monit' do
  action :install
end

service "monit" do
  supports :status => true, :restart => true, :start => true,:stop => true
  action [ :enable, :start ]
end

directory '/etc/monit' do
  owner 'deploy'
  group 'deploy'
  mode '0755'
  recursive true
  action :create
  notifies :restart, resources(:service => "monit"), :immediate
end

cookbook_file '/etc/monit/monitrc' do
  source 'monitrc'
  owner 'deploy'
  group 'deploy'
  mode '0755'
  action :create
end

cookbook_file '/etc/monit/conf.d/puma.conf' do
  source 'monit-puma'
  owner 'deploy'
  group 'deploy'
  mode '0755'
  action :create
end

cookbook_file '/etc/monit/conf.d/nginx.conf' do
  source 'monit-nginx'
  owner 'deploy'
  group 'deploy'
  mode '0755'
  action :create
end

execute 'sudo monit reload'
execute 'sudo monit start all'

1 Answer 1

1

Part of this is debugging why monit won't start up.

With the log statement of logfile syslog... you should look at your syslog daemon's output for logging details. I modified the monitrc to use a file for simpler debugging, like so:

set logfile /var/log/monit.log

The output shows:

[UTC Mar  3 13:13:14] info     : Starting monit daemon with http interface at [*:2812]
[UTC Mar  3 13:13:14] error    : Cannot open for write -- No such file or directory

So one of the configuration directives is pointing at a path that does not exist.

You can also run the monit command interactively to get more details.

/usr/bin/monit -c /etc/monit/monitrc -I -vv

This will emit a lot of great debug information.

In this case, we can see that the same message is repeated:

Cannot open for write -- No such file or directory

Unfortunately, the output doesn't tell us which file or directory is being attempted.

Looking at the config, we can see paths that start with /var/monit/ - but no associated resource to create these paths in your Chef recipe.

# ls /var/monit
ls: cannot access /var/monit: No such file or directory

So this would indicate that the monit daemon is trying to open/write state, id, and queue files in a path that doesn't exist.

The default paths used in the Ubuntu package for monit use /var/lib/monit/ - you can change your config to use that path, or you can add another resource to your recipe to create the desired path.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .