Skip to main content

How To Install Monit on CentOS 7 / Debian 11

What is Monit?

Monit is a free, open-source process supervision tool for Unix and Linux. With Monit, system status can be viewed directly from the command line, or via the native HTTP web server. Monit is able to do automatic maintenance, repair, and run meaningful causal actions in error situations.


How To Install Monit on CentOS 7 / Debian 11


##For CentOS 7 


yum install -y https://dl.fedoraproject.org/pub/epel/epel-release-latest-7.noarch.rpm


yum -y install monit


##



##For Debian 11


apt-get update

apt-get -y install monit


cp /etc/monit/monitrc /etc/monit/monitrc_bkp


nano /etc/monit/monitrc


##Copy paste##


####Copy from here#####


###############################################################################

## Monit control file

###############################################################################

##

## Comments begin with a '#' and extend through the end of the line. Keywords

## are case insensitive. All path's MUST BE FULLY QUALIFIED, starting with '/'.

##

## Below you will find examples of some frequently used statements. For

## information about the control file and a complete list of statements and

## options, please have a look in the Monit manual.

##

##

###############################################################################

## Global section

###############################################################################

set daemon 120            # check services at 2-minute intervals

set logfile /var/log/monit.log

set idfile /var/lib/monit/id

set statefile /var/lib/monit/state

set mailserver localhost               # primary mailserver

set eventqueue

basedir /var/lib/monit/events # set the base directory where events will be stored

slots 100                     # optionally limit the queue size

set mail-format {

   subject: monit alert on {your servername or IP}  --  $EVENT $SERVICE

 }

set alert icallify.logs@gmail.com

include /etc/monit/conf.d/*

include /etc/monit/conf-enabled/*


## Chekck mariadb service running status

check process mysqld with pidfile /var/run/mysqld/mysql.pid

start program = "/bin/systemctl start mariadb"

stop program = "/bin/systemctl stop mariadb"

if failed host 127.0.0.1 port 3306 then restart

if 5 restarts within 5 cycles then timeout


## Check fail2ban service running status

check process fail2ban with pidfile /var/run/fail2ban/fail2ban.pid 

start program = "/bin/systemctl start fail2ban"

stop program = "/bin/systemctl stop fail2ban"


## Check asterisk service running status

check process asterisk with pidfile /var/run/asterisk/asterisk.pid  

start program = "/bin/systemctl start asterisk"

stop program  = "/bin/systemctl stop asterisk"


## Check apache service running service status

check process apache2 with pidfile /var/run/apache2/apache2.pid      

start program = "/bin/systemctl start apache2" with timeout 30 seconds

stop program  = "/bin/systemctl stop apache2"


## Check overall system performance

check system localhost

if loadavg (5min) > 8 for 4 cycles then alert

if loadavg (15min) > 8 for 4 cycles then alert

if memory usage > 80% for 4 cycles then alert

if swap usage > 20% for 4 cycles then alert

if cpu usage (user) > 80% for 4 cycles then alert

if cpu usage (system) > 20% for 4 cycles then alert

if cpu usage (wait) > 20% for 4 cycles then alert

check filesystem "root" with path /

if space usage > 80% for 1 cycles then alert




######EOF##########


#Logrotaion configuration


sed -i -e 's/weekly/size 30M/g' /etc/logrotate.d/monit


#Enable service on startup

systemctl restart monit

systemctl enable monit



Comments

Popular posts from this blog

Vicidial Scratch installation Alma -9/10

Step 1 – Download the dependencies   hostnamectl set-hostname xxxxxx.xxxxx.xxx ### Use YOUR SubDomain vi /etc/hosts ##Change domain name for actual server ip (xxx.xxx.xxx.xxx   complete domain name    subdomain only) timedatectl set-timezone Asia/Kolkata yum check-update yum update -y yum -y install epel-release yum update -y yum install git -y yum install -y kernel* sudo dnf install kernel-devel-$(uname -r) -y # Install english language pack dnf install -y glibc-langpack-en # Configure new locale. This basically just edits /etc/locale.conf localectl set-locale en_US.UTF-8 #Disable SELINUX sed -i 's/SELINUX=enforcing/SELINUX=disabled/g' /etc/selinux/config     reboot Step 2 – Run the Script cd /usr/src/ git clone https://github.com/manish23k/vicidial-install-scripts cd vicidial-install-scripts ####For PHP 7.4 use this script. chmod +x alma-rocky9-ast16.sh ./alma-rocky9-ast16.sh Or the Asterisk 18 version: chmod +x alma-rocky9-ast18.sh ./alma-rock...

Alma 9 Vicidial Selfsign Webrtc

I am going to provide step by step guide to integrate, enable and configure the viciphone(a webrtc phone) in vicidial (also applicable to any vicidial based system) using the Self Signed SSL Certificate ,ie without a public-ip and FQDN or accessing the vicidial with internal LAN IP. 1️⃣ Install OpenSSL (if not installed) sudo dnf install -y openssl 2️⃣ Generate a Private Key openssl genpkey -algorithm RSA -out selfsigned.key -pkeyopt rsa_keygen_bits:2048 3️⃣ Create a Certificate Signing Request (CSR) openssl req -new -key selfsigned.key -out selfsigned.csr It will prompt you for details like: Country Name (e.g., IN ) State or Province (e.g., Gujarat ) Locality (City) Organization Name Common Name (Domain, e.g., example.com or your server IP) Email Address You can use localhost or an IP address if needed. 4️⃣ Generate a Self-Signed Certificate openssl x509 -req -days 365 -in selfsigned.csr -signkey selfsigned.key -out selfsigned.crt -days 365 → Valid for 1 year (Adjust as needed) ...

Install OpenVPN on AlmaLinux 9.5

 To install OpenVPN on AlmaLinux 9.5, you can follow these steps: 1. Update the System : Before installing any software, it's a good idea to update your system: sudo dnf update -y 2. Install EPEL Repository : OpenVPN is available in the EPEL (Extra Packages for Enterprise Linux) repository. First, install the EPEL repository: sudo dnf install epel-release -y 3. Install OpenVPN : After enabling the EPEL repository, install OpenVPN: sudo dnf install openvpn -y 4. Install NetworkManager (Optional) : If you are using NetworkManager for managing network connections, you can install the OpenVPN plugin for NetworkManager: sudo dnf install NetworkManager-openvpn -y 5. Configure OpenVPN : Once installed, you need to configure OpenVPN by copying your .ovpn configuration file to the /etc/openvpn/ directory: sudo cp /path/to/your/config.ovpn /etc/openvpn/ 6. Start OpenVPN : You can start OpenVPN by specifying the configuration file directly: sudo openvpn --config /etc...