monit example tutorial how to enable status checking and manipulation

You need to enable the httpd daemon with monit to actually view the status and control, it's not only for the web interface since the httpd is the ONLY way of controlling monit and viewing the status.

monit monitor all will also reinstate disabled services if they've timed out too much.  Just restarting the service will do nothing to re-monitor a service that monit has stopped monitoring due to too many failures.

*Also note that /etc/monit.conf is what is used for configuring all parameters, the monitrc file seems to be deprecated, this includes setting the daemon time:

monit -c /etc/monitrc status
monit: The control file '/etc/monitrc' must have permissions no more than -rwx------ (0700); right now permissions are -rw-r--r-- (0644).
[root@boxhost vhosts]# chmod 700 /etc/monitrc
[root@boxhost vhosts]# monit -c /etc/monitrc status
monit: generated unique Monit id f9a36510746eba21b0ec9418de8850d5 and stored to '/root/.monit.id'
monit: error connecting to the monit daemon
[root@boxhost vhosts]# monit -c /etc/monitrc status
monit: error connecting to the monit daemon

edit /etc/monit.conf (change the paths as appropriate too):


set httpd port 2812
  allow localhost

 set daemon  60           # check services at 2-minute intervals
set idfile /var/monit/id
set statefile /var/monit/state
 set mailserver localhost               # primary mailserver
 set alert youremail@host.com
  check file apache_bin with path /usr/sbin/httpd
  check process apache with pidfile /usr/local/apache/logs/httpd.pid every 2 cycles
    start program = "/etc/init.d/httpd start" with timeout 60 seconds
    stop program  = "/etc/init.d/httpd stop"
    #if cpu > 60% for 2 cycles then alert
    #if cpu > 80% for 5 cycles then restart
    #if totalmem > 200.0 MB for 5 cycles then restart
    #if children > 250 then restart
    #if loadavg(5min) greater than 10 for 8 cycles then stop
    if failed host yourserver.com port 80 protocol http
       and request "/"
       with timeout 15 seconds
       then restart
    #if failed port 443 type tcpssl protocol http
    #   with timeout 15 seconds
    #   then restart
    if 2 restarts within 2 cycles then exec "/usr/bin/killall -9 httpd;/sbin/service httpd restart"
    depends on apache_bin
    group server
include /etc/monit.d/*

service monit restart
 


Tags:

monit, tutorial, enable, manipulationyou, httpd, daemon, interface, controlling, viewing, reinstate, disabled, ve, timed, restarting, monitoring, failures, etc, conf, configuring, parameters, monitrc, deprecated, includes, permissions, rwx, rw, boxhost, vhosts, chmod, generated, eba, ec, stored, connecting, edit, paths, localhost, intervals, idfile, var, statefile, mailserver, primary, youremail, apache_bin, usr, sbin, apache, pidfile, logs, pid, cycles, quot, init, timeout, cpu, restart, totalmem, mb, loadavg, min, yourserver, protocol, http, tcpssl, restarts, exec, bin, killall, server,

Latest Articles

  • Cloned VM/Server/Computer in Linux won't boot and goes to initramfs busybox Solution
  • How To Add Windows 7 8 10 11 to GRUB Boot List Dual Booting
  • How to configure OpenDKIM on Linux with Postfix and setup bind zonefile
  • Debian Ubuntu 10/11/12 Linux how to get tftpd-hpa server setup tutorial
  • efibootmgr: option requires an argument -- 'd' efibootmgr version 15 grub-install.real: error: efibootmgr failed to register the boot entry: Operation not permitted.
  • Apache Error Won't start SSL Cert Issue Solution Unable to configure verify locations for client authentication SSL Library Error: 151441510 error:0906D066:PEM routines:PEM_read_bio:bad end line SSL Library Error: 185090057 error:0B084009:x509 certif
  • Linux Debian Mint Ubuntu Bridge br0 gets random IP
  • redis requirements
  • How to kill a docker swarm
  • docker swarm silly issues
  • isc-dhcp-server dhcpd how to get longer lease
  • nvidia cannot resume from sleep Comm: nvidia-sleep.sh Tainted: Linux Ubuntu Mint Debian
  • zfs and LUKS how to recover in Linux
  • [error] (28)No space left on device: Cannot create SSLMutex Apache Solution Linux CentOS Ubuntu Debian Mint
  • Save money on bandwidth by disabling reflective rpc queries in Linux CentOS RHEL Ubuntu Debian
  • How to access a disk with bad superblock Linux Ubuntu Debian Redhat CentOS ext3 ext4
  • ImageMagick error convert solution - convert-im6.q16: cache resources exhausted
  • PTY allocation request failed on channel 0 solution
  • docker error not supported as upperdir failed to start daemon: error initializing graphdriver: driver not supported
  • Migrated Linux Ubuntu Mint not starting services due to broken /var/run and dbus - Failed to connect to bus: No such file or directory solution