Skip to content

Instantly share code, notes, and snippets.

@tokhi
Last active August 29, 2015 14:05
Show Gist options
  • Save tokhi/919a07fec5d5080743a1 to your computer and use it in GitHub Desktop.
Save tokhi/919a07fec5d5080743a1 to your computer and use it in GitHub Desktop.
monit installation on gentoo

Monit Documentation

Note
Monit has to be configured through the root user.
Use sudo su - to login as root user.

Monit Installation

Install monit on Gentoo with the following command:

emerge monit

On Gentoo You can always do a dry-run:

emerge --pretend monit

Note This basically says what would happen if You would install the given package

After monit is installed create the /etc/monit/ directory and change it's file permissions:

mkdir /etc/monit/
chmod 755 /etc/monit/

Then copy the repository into the /etc/monit/ directory.

Link the monitrc configuration file from the repository to the default location with the following command:

ln -s /etc/monit/monitrc /etc/monitrc

Installation Testing

If You are not familiar with Gentoo or emerge You can test the installation process inside a docker container.

Start the docker container:

docker run -it tianon/gentoo /bin/bash

Then execute the following commands:

# Install monit
emerge --sync
emerge monit

# Cehck if monit was successfully installed
monit -V

File Structure

/etc/monit/conf.d
├── conf.d
│   ├── 3rd-party - services monitoring scripts
│   │   ├── nginx.conf
│   │   ├── php-fpm
│   │   │   └── php-fpm-5.conf
│   │   └── ...
│   ├── apps - application monitoring scripts
│   │   ├── api
│   │   │   ├── cac-adscale-api.conf
│   │   │   └── ...
│   │   ├── bannertool.conf
│   │   ├── reporting-gui.conf
│   │   └── ...
│   ├── disable - all disabled monitoring scripts
│   │   └── memory.conf
│   └── sys - system related monitoring scripts
│       ├── cpu.conf
│       ├── fs.conf
│       └── network.conf
├── monitrc - main monit configuration file
└── templates - reusable configuration templates
    ├── api-logs-file-perm-775
    ├── bin-dir-perm-644-castaclip
    ├── bin-dir-perm-644-exozet
    └── ...

The monitoring scripts inside the sys directory focus on the following:

  • filesystem checks
  • network monitoring
  • CPU monitoring

Monitoring Script Structure

A typical monit scripts consists of the following parts:

  • binaries monitoring
  • configuration files monitoring
  • log files monitoring

Usefull Commands

  • List all commands

    monit -h
    
  • Get monit summary

    monit summary
    
  • Disable/unmonitor a service

    monit unmonitor <service name>
    

    If You want to disable the service permanently You can move the appropriate file to the /etc/monit/conf.d/conf.d/disable directory and then reload monit with

      monit reload
    
  • View monit logs

    tail -f /var/log/monit.log
    
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment