Preamble
If you tried to control services manually on Linux servers then here is the solution for you. First of all you will need to install Monit on Linux.
We can set up Monit to check the Tomcat and MySQL processes. We have to configure for MySQL and Tomcat using Monit. We can also test the Monit and Java processes. We will see how to control MySQL.
It is very easy to configure Monit on Linux and you can find the log file in /var/log/monit. We discussed with you some examples of monitoring using ssh and MySQL services.
SSH configuration
We will create a file to monitor the ssh service using the Monit tool.
[root@andrex ~]# vim /etc/monit.d/ssh.conf
check process sshd with pidfile /var/run/sshd.pid
start program "/usr/sbin/sshd start"
stop program "/usr/sbin/sshd stop"
if failed host 127.0.0.1 port 22 protocol ssh then restart
if 5 restarts within 5 cycles then timeout
The above code will monitor the ssh services and restart the services on failure. It will try 5 times.
You can check the status if it works or is configured correctly using the command.
Process 'sshd'
status OK
monitoring status Monitored
monitoring mode active
on reboot start
pid 7101
parent pid 1
uid 0
effective uid 0
gid 0
uptime 1h 54m
threads 1
children 3
cpu 0.0%
cpu total 0.0%
memory 0.0% [468 kB]
memory total 0.3% [2.8 MB]
security attribute system_u:system_r:sshd_t:s0-s0:c0.c1023
disk read 0 B/s [116.6 MB total]
port response time 34.733 ms to 127.0.0.1:22 type TCP/IP protocol SSH
data collected Tue, 05 May 2020 14:22:32
MySQL configuration
We can also control the MySQL server as well as with this tool. Create a file to monitor MySQL.
- Note:
You can change the location of the configuration file according to your server.
[root@andrex ~]# vim /etc/monit.d/mysql.conf
check process mysqld with pidfile /var/run/mysqld/mysqld.pid
group database
start program = "/etc/init.d/mysqld start"
stop program = "/etc/init.d/mysqld stop"
if failed host 127.0.0.1 port 3306 then restart
if 5 restarts within 5 cycles then timeout
We can also check the configuration before rebooting the monitoring service.
[root@andrex ~]# monit -t # check the configuration before rebooting the service
[root@andrex ~]#get reload # reboot the configuration to make changes
You can check the PID location and run the program, it may be different on your computer.
Check the status by using the monitoring status
Process 'mysqld'
status OK
monitoring status Monitored
monitoring mode active
on reboot start
pid 60708
parent pid 60504
uid 27
effective uid 27
gid 27
uptime 0m
threads 22
children 0
cpu 0.1%
cpu total 0.1%
memory 45.3% [440.2 MB]
memory total 45.3% [440.2 MB]
security attribute system_u:system_r:mysqld_t:s0
disk read 0 B/s [13.7 MB total]
disk write 0 B/s [64 kB total]
port response time 0.924 ms to 127.0.0.1:3306 type TCP/IP protocol DEFAULT
data collected Tue, 05 May 2020 14:22:32
Now we have configured SSH and MySQL services to monitor and automatically restart on failure.
Test configuration
We will stop the MySQL service manually to check if it works or not.
As soon as it is done. You check the status by using the monitoring status
Process 'mysqld'
status Initializing
monitoring status Initializing
monitoring mode active
on reboot start
data collected Tue, 05 May 2020 14:39:08
You will see that it will be in the process of initialization for a few seconds and then you will check the state of MySQL service.
The service will be restarted automatically.
Process 'mysqld'
status OK
monitoring status Monitored
monitoring mode active
on reboot start
pid 61687
parent pid 61482
uid 27
effective uid 27
gid 27
uptime 0m
threads 22
children 0
cpu 0.1%
cpu total 0.1%
memory 45.3% [440.2 MB]
memory total 45.3% [440.2 MB]
security attribute system_u:system_r:mysqld_t:s0
disk write 0 B/s [60 kB total]
port response time 0.566 ms to 127.0.0.1:3306 type TCP/IP protocol DEFAULT
data collected Tue, 05 May 2020 14:40:11
If you have set up access with GUI for Monit monitoring panel. You can also check the status there.

About Enteros
Enteros helps associations of each size with making their cloud data stockrooms work for any usage case and our experts are skilled in the fluctuating nuances of the different data circulation focus courses of action.
The views expressed on this blog are those of the author and do not necessarily reflect the opinions of Enteros Inc. This blog may contain links to the content of third-party sites. By providing such links, Enteros Inc. does not adopt, guarantee, approve, or endorse the information, views, or products available on such sites.
Are you interested in writing for Enteros’ Blog? Please send us a pitch!
RELATED POSTS
How to Accelerate Financial Sector Growth with Enteros Database Software, Cost Attribution, and AI-Driven Root Cause Analysis
- 7 May 2026
- Database Performance Management
Introduction The financial sector is evolving rapidly as digital banking, fintech innovation, AI-powered services, and real-time transactions reshape the industry. Financial institutions are expected to provide seamless customer experiences, maintain high system reliability, and comply with strict regulatory standards—all while managing operational efficiency and controlling costs. However, as financial systems become increasingly data-intensive and distributed, … Continue reading “How to Accelerate Financial Sector Growth with Enteros Database Software, Cost Attribution, and AI-Driven Root Cause Analysis”
How to Drive Technology Sector Growth with Enteros Database Management Platform, Cost Estimation, AI SQL, and Generative AI
Introduction The technology sector is evolving at an unprecedented pace. From cloud-native applications and AI-powered platforms to real-time analytics and digital transformation initiatives, technology companies are under constant pressure to innovate, scale, and deliver exceptional user experiences. However, rapid growth also introduces significant operational challenges. Organizations must manage massive volumes of data, optimize infrastructure performance, … Continue reading “How to Drive Technology Sector Growth with Enteros Database Management Platform, Cost Estimation, AI SQL, and Generative AI”
Improving Database Performance and Reliability in Healthcare Systems with Advanced Analytics
Healthcare systems today are rapidly evolving as hospitals, clinics, and health-tech platforms increasingly rely on digital infrastructure. From electronic health records to telemedicine platforms, nearly every healthcare service depends on fast, secure, and reliable data access. At the center of this digital transformation lies the database. Healthcare organizations manage massive volumes of sensitive patient data, … Continue reading “Improving Database Performance and Reliability in Healthcare Systems with Advanced Analytics”
How Intelligent Database Analytics is Transforming Performance in BFSI Platforms
Introduction The Banking, Financial Services, and Insurance (BFSI) industry is undergoing a massive digital transformation. From mobile banking apps and real-time payment systems to AI-driven fraud detection and personalized financial services, modern financial platforms depend heavily on high-performance data infrastructure. At the center of this infrastructure lies the database layer, which processes millions of transactions, … Continue reading “How Intelligent Database Analytics is Transforming Performance in BFSI Platforms”