Monit: Difference between revisions

From James's Wiki
No edit summary
No edit summary
Line 29: Line 29:
  sudo monit status
  sudo monit status


==Systemd .service file==
monit not starting up correctly on reboot...so I deleted the init.d/monit script and made a monit.service file
# This file is systemd template for monit service. To
 
# register monit with systemd, place the monit.service file
 
# to the /lib/systemd/system/ directory and then start it
# This file is systemd template for monit service. To
# using systemctl (see bellow).
# register monit with systemd, place the monit.service file
#
# to the /lib/systemd/system/ directory and then start it
# Enable monit to start on boot:  
# using systemctl (see bellow).
#        systemctl enable monit.service
#
#
# Enable monit to start on boot:
# Start monit immediately:  
#        systemctl enable monit.service
#        systemctl start monit.service
#
#
# Start monit immediately:
# Stop monit:
#        systemctl start monit.service
#        systemctl stop monit.service
#
#
# Stop monit:
# Status:
#        systemctl stop monit.service
#        systemctl status monit.service
#
# Status:
[Unit]
#        systemctl status monit.service
Description=Pro-active monitoring utility for unix systems
 
After=network.target
[Unit]
Description=Pro-active monitoring utility for unix systems
[Service]
After=network.target
Type=simple
 
KillMode=process
[Service]
ExecStart=/usr/local/bin/monit -I
Type=simple
ExecStop=/usr/local/bin/monit quit
KillMode=process
ExecReload=/usr/local/bin/monit reload
ExecStart=/usr/bin/monit -c /etc/monit/monitrc -I
Restart = on-abnormal
ExecStop=/usr/bin/monit quit
ExecReload=/usr/bin/monit reload
[Install]
Restart = on-abnormal
WantedBy=multi-user.target
 
[Install]
WantedBy=multi-user.target

Revision as of 19:02, 25 February 2018

if installed with apt systemd file is already in.

sudo nano /etc/monit/monitrc

changed:

set alert ractive74@gmail.com
set mailserver smtp.gmail.com port 587 
   username "MYUSER" password "MYPASSWORD"
   using tlsv12
  check system $HOST
    if loadavg (1min) > 4 then alert
    if loadavg (5min) > 2 then alert
    if cpu usage > 95% for 10 cycles then alert
    if memory usage > 75% then alert
    if swap usage > 25% then alert
 check network public with interface eth0
   if failed link then alert


sudo systemctl restart monit
sudo monit -t
sudo monit start all
sudo monit status

monit not starting up correctly on reboot...so I deleted the init.d/monit script and made a monit.service file


  1. This file is systemd template for monit service. To
  2. register monit with systemd, place the monit.service file
  3. to the /lib/systemd/system/ directory and then start it
  4. using systemctl (see bellow).
  5. Enable monit to start on boot:
  6. systemctl enable monit.service
  7. Start monit immediately:
  8. systemctl start monit.service
  9. Stop monit:
  10. systemctl stop monit.service
  11. Status:
  12. systemctl status monit.service

[Unit] Description=Pro-active monitoring utility for unix systems After=network.target

[Service] Type=simple KillMode=process ExecStart=/usr/bin/monit -c /etc/monit/monitrc -I ExecStop=/usr/bin/monit quit ExecReload=/usr/bin/monit reload Restart = on-abnormal

[Install] WantedBy=multi-user.target