Note
Monit has to be configured through theroot
user.
Usesudo su -
to login as root user.
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
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
/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
A typical monit scripts consists of the following parts:
- binaries monitoring
- configuration files monitoring
- log files monitoring
-
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 withmonit reload
-
View monit logs
tail -f /var/log/monit.log