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

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 #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 chmod +x alma-rocky9-ast16.sh ./alma-rocky9-ast16.sh Or the Asterisk 18 version: chmod +x alma-rocky9-ast18.sh ./alma-rocky9-ast18.sh ####For PHP 8 use this script. chmod +x main-installer-php8.sh ./main-installer-php8.sh

How to delete old call logs and other logs in vicidial or goautodial.

Step 1 : SSH to the server using the Putty Step 2:   login to mysql by typing   mysql -p                    (if you dont know password try below command )               mysql -ucron -p1234 Step 3 : select the asterisk database by typing               use asterisk step 4: Run the below command to check total disk occupied by asterisk database                SELECT table_schema AS "asterisk", ROUND(SUM(data_length + index_length) / 1024 / 1024, 2) AS "Size (MB)" FROM information_schema.TABLES GROUP BY table_schema; Step 5 : Run the below command to check disk space consumed by each table in asterisk database SELECT table_name AS "Table", ROUND(((data_length + index_length) / 1024 / 1024), 2) AS "Size (MB)" FROM information_schema.TABLES WHERE table_schema = "asterisk" ORDER BY (data_length + inde...

Install the No-IP client (Dynamic Update Client) on AlmaLinux 9

 Install the No-IP client (Dynamic Update Client) on AlmaLinux 9 1. Install Required Packages First, install the necessary packages to compile the client from source. sudo dnf install gcc make wget tar 2. Download the No-IP DUC (Dynamic Update Client) Download the latest version of the No-IP DUC. cd /opt wget https://www.noip.com/client/linux/noip-duc-linux.tar.gz 3. Extract the Downloaded File Extract the downloaded tarball. tar -zxvf noip-duc-linux.tar.gz cd noip-2.1.9-1/ 4. Compile the Client Run the following commands to compile the client. sudo make install 5. Configure the No-IP Client After installation, you’ll be prompted to enter your No-IP account credentials (email and password) and choose the hostname(s) to update. If not, you can manually run the configuration: sudo /usr/local/bin/noip2 -C 6. Start the No-IP Client To start the client: sudo /usr/local/bin/noip2 7. Verify Installation To confirm that the No-IP DUC is running, use: sudo /usr/local/bin/noip2 -S 8. Set Up...