時(shí)間:2015-06-28 00:00:00 來(lái)源:IT貓撲網(wǎng) 作者:網(wǎng)管聯(lián)盟 我要評(píng)論(1)
Monit 是用于對(duì)系統(tǒng)中的進(jìn)程、文件、目錄、以及設(shè)備等進(jìn)行監(jiān)視和管理的工具。當(dāng)你所指定的server宕機(jī)或者沒(méi)有反應(yīng),monit會(huì)將該進(jìn)程殺死并重啟該server。并通過(guò)郵件進(jìn)行通知。Monit 包含一個(gè)內(nèi)嵌的 HTTP(S) Web 界面,你可以使用瀏覽器方便地查看 Monit 所監(jiān)視的服務(wù)器。
Monit的官方網(wǎng)站: http://www.mmonit.com
下面將介紹monit在CentOS5.3上的安裝和配置:
download:http://mmonit.com/monit/dist/monit-5.1.1.tar.gz
shell >? tar xzvf monit-5.1.1.tar.gz
shell> cd monit-5.*
shell>./configure
shell>make
shell> make install
shell> rm /etc/monitrc
shell> cp monitrc /etc/
在inittab文件中添加下面這句話,使init守護(hù)monit進(jìn)程?。?/p>
shell> vi /etc/inittab
mo:2345:respawn:/usr/local/bin/monit -Ic /etc/monitrc
現(xiàn)在安裝完成了,是不是超簡(jiǎn)單?。?/p>
接下來(lái)就是配置了?。?/p>
Monitrc文件########################################################
set daemon? 120? #設(shè)置monit檢查的間隔時(shí)間,單位是秒?。?/p>
set logfile syslog facility log_daemon? #用syslog來(lái)記錄log
set logfile /var/logs/monit.log #設(shè)置日志路徑
set idfile /var/.monit.id #設(shè)置PID文件的位置
set mailserver? 192.168.0.21,?? # primary mailserver? 郵件服務(wù)器的IP
set mail-format { from: [email protected] }? #設(shè)置你的郵件從哪個(gè)賬號(hào)發(fā)出
set alert [email protected]?? #發(fā)到我的139郵箱,用139郵箱是因?yàn)?39有一個(gè)郵件到達(dá)通知功能
set httpd port 2812 and????? #設(shè)置monit監(jiān)聽的端口號(hào)
use address 192.168.0.21?? # 設(shè)置monit服務(wù)器的IP,可以讓你方便的http訪問(wèn)
allow admin:pass????? #設(shè)置用戶名和密碼
################################# Services? ##############################
監(jiān)控服務(wù)器的磁盤使用情況
check device system with path /dev/mapper/VolGroup00-LogVol00
if space usage > 85% for 5 times within 15 cycles then alert
if space usage > 95% then stop
if inode usage > 85% then alert
if inode usage > 95% then stop
######################################################
#sshd?? 監(jiān)控sshd進(jìn)程
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 host 127.0.0.1 port 22? then restart
if 5 restarts within 5 cycles then timeout
#######################################################
#cron 監(jiān)控crontab進(jìn)程
check process cron with pidfile /var/run/crond.pid
group system
start program = "/etc/init.d/crond start"
stop program = "/etc/init.d/crond stop"
if 5 restarts within 5 cycles then timeout? depends on cron_rc
#########################################################################
#scripts?? 監(jiān)控nginx的日志切割腳本文件
check file cut_nginx_log.sh with path /scripts/cut_nginx_log.sh
group scripts
if failed checksum then unmonitor
if failed permission 755 then unmonitor
if failed uid root then unmonitor
if failed gid root then unmonitor
##########################################################################
#systemfile??? 監(jiān)控passwd文件和group文件
check file passwd with path /etc/passwd
group system
if failed checksum then unmonitor
if failed permission 644 then unmonitor
if failed uid root then unmonitor
if failed gid root then unmonitor
check file group with path /etc/group
group system
if failed checksum then unmonitor
if failed permission 644 then unmonitor
if failed uid root then unmonitor
if failed gid root then unmonitor
##############################################################
# 監(jiān)控本機(jī)的25,110端口號(hào)
check host localhost with address 127.0.0.1
if failed port 25? with timeout 15 seconds then exec "/usr/bin/qmailctl restart"
if failed port 110 protocol pop with timeout 15 seconds then exec "/usr/bin/vpopmailctl restart"
基本的配置就是這樣子,剩下的就是根據(jù)各自的實(shí)際情況進(jìn)行修改!??!,配置好從瀏覽器登錄查看下是否成功,接下來(lái)就是輕松的喝喝茶,逛逛論壇了!! 哈哈
關(guān)鍵詞標(biāo)簽:linux系統(tǒng)監(jiān)控利器
相關(guān)閱讀
熱門文章 安裝紅帽子RedHat Linux9.0操作系統(tǒng)教程 Tomcat9.0如何安裝_Tomcat9.0環(huán)境變量配置方法 多種操作系統(tǒng)NTP客戶端配置 Linux操作系統(tǒng)修改IP
人氣排行 Linux下獲取CPUID、硬盤序列號(hào)與MAC地址 dmidecode命令查看內(nèi)存型號(hào) linux tc實(shí)現(xiàn)ip流量限制 安裝紅帽子RedHat Linux9.0操作系統(tǒng)教程 linux下解壓rar文件 lcx.exe、nc.exe、sc.exe入侵中的使用方法 Ubuntu linux 關(guān)機(jī)、重啟、注銷 命令 查看linux服務(wù)器硬盤IO讀寫負(fù)載