Linux Process monitoring
MonitMonit is a small open source tool to manage and monitor UNIX systems. Monit can automatically maintain the process, to avoid the process of abnormal exit and other problems arising.
- System: Monit can monitor the problem, including process status, System CPU load, memory consumption, etc., such as when the Apache service CPU load and memory lock is too high, it will restart the Apache service.
- Process: Monit can monitor daemon processes, including system processes. For example, when one is down, it automatically resumes restarting the process.
- File system:Monit can monitor changes in local files, directories, and file systems, including timestamps, checksum values, and size changes. For example, you can monitor file SHA1 and MD5 values to monitor whether a file has changed.
- Network:Monit can monitor network connections, support TCP, UDP, Unix domain sockets, and HTTP, SMTP, and so on.
- Timed scripts:Monit can be used to test programs and scripts on a timed basis, obtaining output from the program to determine success or otherwise.
Installation:
sudo apt-get install Monit
To edit a configuration:
sudo vim/etc/monit/monitrc
Start, stop, restart:
sudo/etc/init.d//etc/init.d//etc/init.d/monit Restart
To set the page monitoring status:
and 0.0.0.0/0.0.0.0 allowlocalhost
Increased monitoring:
Note that there is a need to add start and stop, missing one is not possible
1. Monitoring according to the program name
" /home/yxd/test.py " "xxxxx"
2. According to PID monitoring
Check process Apache with pidfile/var/run/"/etc/init.d/rcwebserver.sh start https" "/etc/init.d/rcwebserver.sh stop https" if changed PID then Aler
Reference: Monitoring system critical processes with Monit
SupervisordSupervisor is a C/s system that allows users to monitor and control the number of background service processes in a UNIX-like operating system. It is written by Python and is often used for restart protection of process exception exits. Installation:
Pip Install Supervisor
To view the configuration file:
Echo_supervisord_conf
From the results of this command, you can see the configuration information for each module. To create a configuration file:
echo_supervisord_conf >/etc/supervisord.conf
To configure the app:
[Program:test]command=python/root/test_supervisor.pyprocess_name=%(program_name) sstdout_ LogFile=/root/test.logstderr_logfile=/root/test.log
Save, start:
/usr/bin/supervisord-c/etc/supervisord.conf
Reference: Managing Python processes with Supervisord
Linux process Monitoring