国产探花免费观看_亚洲丰满少妇自慰呻吟_97日韩有码在线_资源在线日韩欧美_一区二区精品毛片,辰东完美世界有声小说,欢乐颂第一季,yy玄幻小说排行榜完本

首頁 > 系統 > Linux > 正文

用Monit監測Linux 服務器

2020-06-13 12:35:16
字體:
來源:轉載
供稿:網友
Monit 是一個用來監測系統狀態的工具,不但可以用來監視進程、服務、文件、目錄、文件系統,還可以在服務 down 掉的時候自動重啟服務或者當某個進程占用過多的資源的時候自動停掉進程,并且支持 Email 報警功能、遠程服務器監測、web 管理界面等,功能很多很強大。
 
 
monit用 Monit 監測 linux 服務器 
Monit 是一個用來監測系統狀態的工具,不但可以用來監視進程、服務、文件、目錄、文件系統,還可以在服務 down 掉的時候自動重啟服務或者當某個進程占用過多的資源的時候自動停掉進程,并且支持 Email 報警功能、遠程服務器監測、web 管理界面等,功能很多很強大。VPSee 用 monit 來監測多個 VPS 和獨立服務器,如果某個 VPS down 了、某個服務器資源緊張,就能第一時間知道,而且某個服務停了的話可以自動重啟服務。 

安裝 monit 
在 CentOS 下安裝和配置文件: 

復制代碼
代碼如下:

# wget http://packages.sw.be/rpmforge-release/rpmforge-release-0.3.6-1.el5.rf.i386.rpm 
# rpm -Uvh rpmforge-release-0.3.6-1.el5.rf.i386.rpm 
# yum install monit 
# vi /etc/monit.conf 

配置 monit 
修改 monit 的配置文件,/etc/monit.conf(CentOS)或者 /etc/monit/monitrc(Debian),每隔120秒檢查一次系統,如果 httpd/mysql/sshd 服務停掉了就重新啟動相應服務。對于 httpd 服務器,當發現 CPU/MEM 占用過大、loadavg 太高時就執行相應的報警、重啟服務指令。如果使用 Email 報警功能,需要配置 Email 地址、郵件服務器等信息: 

復制代碼
代碼如下:

set daemon 120 
check process sshd with pidfile /var/run/sshd.pid 
start program “/etc/init.d/sshd start” 
stop program “/etc/init.d/sshd stop” 
if failed port 22 protocol ssh then restart 
if 5 restarts within 5 cycles then timeout 
check process mysql 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 
check process nginx with pidfile /var/run/nginx.pid 
start program = “/etc/init.d/nginx start” 
stop program = “/etc/init.d/nginx stop” 
if failed host www.yanghengfei.com port 80 protocol http 
then restart 
check process php_cgi with pidfile /var/run/php_cgi.pid 
start program = “/etc/init.d/php_cgi start” 
stop program = “/etc/init.d/php_cgi stop” 
if failed host 127.0.0.1 port 9000 then restart 
if 5 restarts within 5 cycles then timeout 
check process apache with pidfile /var/run/httpd.pid 
group www 
start program = “/etc/init.d/httpd start” 
stop program = “/etc/init.d/httpd stop” 
if failed host www.yanghengfei.com port 8080 protocol http 
then restart 
if cpu is greater than 80% for 2 cycles then alert 
if cpu > 80% for 5 cycles then restart 
if totalmem > 512 MB for 5 cycles then restart 
if children > 200 then restart 
if loadavg(5min) greater than 10 for 8 cycles then stop 
if 3 restarts within 5 cycles then timeout 

更多詳細信息可以參考配置文件,里面注釋寫得很詳細。 

啟動 monit 
在 CentOS 下啟動并加入到系統啟動腳本: 

復制代碼
代碼如下:

# /etc/init.d/monit start 
# /sbin/chkconfig monit on 


發表評論 共有條評論
用戶名: 密碼:
驗證碼: 匿名發表
主站蜘蛛池模板: 陆河县| 上饶市| 同心县| 黄骅市| 长岛县| 郁南县| 商丘市| 永州市| 兴城市| 扎囊县| 南皮县| 巴里| 梁平县| 讷河市| 乌拉特中旗| 岳普湖县| 尉犁县| 瑞昌市| 香格里拉县| 洛隆县| 大田县| 二连浩特市| 唐海县| 东台市| 临江市| 田阳县| 三穗县| 伽师县| 东乌| 闽侯县| 门头沟区| 和林格尔县| 乐昌市| 车险| 房产| 行唐县| 房产| 即墨市| 镇雄县| 泽普县| 会泽县|