一、Supervisor
1、安裝
宿主機環境:( Centos 6.5 )
pip2.7 install supervisor
2、創建配置文件
通過 echo_supervisord_conf 命令來創建配置文件:
echo_supervisord_conf >/etc/supervisord.conf
3、主配置文件基本參數
[unix_http_server] file=/var/run/supervisor/supervisor.sock chmod=0700 chown=www:www username=admin password=123456 [supervisord] logfile=/var/log/supervisord.log logfile_maxbytes=50MB logfile_backups=10 loglevel=info pidfile=/var/run/supervisor/supervisord.pid nodaemon=false minfds=1024 minprocs=200 [rpcinterface:supervisor] supervisor.rpcinterface_factory = supervisor.rpcinterface:make_main_rpcinterface [supervisorctl] serverurl=unix:///var/run/supervisor/supervisor.sock [include] files=/etc/supervisord_child/*.ini
4、配置一個進程監控
[program:CommentMsg] command= /bin/php /test/art Comment:msg process_name=%(process_num)02d numprocs=5 autostart=true autorestart=true startsecs=2 startretries=10 redirect_stderr=true stdout_logfile=/var/log/supervisor/CommentMsg.log stdout_logfile_maxbytes=10MB stdout_logfile_backups=10
配置多個進程監控
[program:CommentMsg] command= /bin/php /test/art Comment:msg process_name=%(process_num)02d numprocs=5 autostart=true autorestart=true startsecs=2 startretries=10 redirect_stderr=true stdout_logfile=/var/log/supervisor/CommentMsg.log stdout_logfile_maxbytes=10MB stdout_logfile_backups=10 [program:showAdd] command= /bin/php /test/artg showAdd process_name=%(process_num)02d numprocs=5 autostart=true autorestart=true startsecs=2 startretries=10 redirect_stderr=true stdout_logfile=/var/log/supervisor/showAdd.log stdout_logfile_maxbytes=10MB stdout_logfile_backups=10
啓動服務
supervisord -c /etc/supervisord.conf
5、supervisorctl 常用指令
update :重新讀取配置文件,且不會影響正在運行的程序;
start :啓用進程
stop :停止進程
restart :重啓進程
reload :重新載入配置文件,並重啓所有管理的進程。
status :查看狀態
6、配置文件所有參數詳解
引用:http://lixcto.blog.51cto.com/4834175/1539136
[unix_http_server] file=/tmp/supervisor.sock ; socket文件的路徑,supervisorctl用XML_RPC和supervisord通信就是通過它進行 的。如果不設置的話,supervisorctl也就不能用了 不設置的話,默認爲none。 非必須設置 ;chmod=0700 ; 這個簡單,就是修改上面的那個socket文件的權限爲0700 不設置的話,默認爲0700。 非必須設置 ;chown=nobody:nogroup ; 這個一樣,修改上面的那個socket文件的屬組爲user.group 不設置的話,默認爲啓動supervisord進程的用戶及屬組。非必須設置 ;username=user ; 使用supervisorctl連接的時候,認證的用戶 不設置的話,默認爲不需要用戶。 非必須設置 ;password=123 ; 和上面的用戶名對應的密碼,可以直接使用明碼,也可以使用SHA加密 如:{SHA}82ab876d1387bfafe46cc1c8a2ef074eae50cb1d 默認不設置。。。非必須設置 ;[inet_http_server] ; 偵聽在TCP上的socket,Web Server和遠程的supervisorctl都要用到他 不設置的話,默認爲不開啓。非必須設置 ;port=127.0.0.1:9001 ; 這個是偵聽的IP和端口,偵聽所有IP用 :9001或*:9001。 這個必須設置,只要上面的[inet_http_server]開啓了,就必須設置它 ;username=user ; 這個和上面的uinx_http_server一個樣。非必須設置 ;password=123 ; 這個也一個樣。非必須設置 [supervisord] ;這個主要是定義supervisord這個服務端進程的一些參數的 這個必須設置,不設置,supervisor就不用幹活了 logfile=/tmp/supervisord.log ; 這個是supervisord這個主進程的日誌路徑,注意和子進程的日誌不搭嘎。 默認路徑$CWD/supervisord.log,$CWD是當前目錄。。非必須設置 logfile_maxbytes=50MB ; 這個是上面那個日誌文件的最大的大小,當超過50M的時候,會生成一個新的日 志文件。當設置爲0時,表示不限制文件大小 默認值是50M,非必須設置。 logfile_backups=10 ; 日誌文件保持的數量,上面的日誌文件大於50M時,就會生成一個新文件。文件 數量大於10時,最初的老文件被新文件覆蓋,文件數量將保持爲10 當設置爲0時,表示不限制文件的數量。 默認情況下爲10。。。非必須設置 loglevel=info ; 日誌級別,有critical, error, warn, info, debug, trace, or blather等 默認爲info。。。非必須設置項 pidfile=/tmp/supervisord.pid ; supervisord的pid文件路徑。 默認爲$CWD/supervisord.pid。。。非必須設置 nodaemon=false ; 如果是true,supervisord進程將在前臺運行 默認爲false,也就是後臺以守護進程運行。。。非必須設置 minfds=1024 ; 這個是最少系統空閒的文件描述符,低於這個值supervisor將不會啓動。 系統的文件描述符在這裏設置cat /proc/sys/fs/file-max 默認情況下爲1024。。。非必須設置 minprocs=200 ; 最小可用的進程描述符,低於這個值supervisor也將不會正常啓動。 ulimit -u這個命令,可以查看linux下面用戶的最大進程數 默認爲200。。。非必須設置 ;umask=022 ; 進程創建文件的掩碼 默認爲022。。非必須設置項 ;user=chrism ; 這個參數可以設置一個非root用戶,當我們以root用戶啓動supervisord之後。 我這裏面設置的這個用戶,也可以對supervisord進行管理 默認情況是不設置。。。非必須設置項 ;identifier=supervisor ; 這個參數是supervisord的標識符,主要是給XML_RPC用的。當你有多個 supervisor的時候,而且想調用XML_RPC統一管理,就需要爲每個 supervisor設置不同的標識符了 默認是supervisord。。。非必需設置 ;directory=/tmp ; 這個參數是當supervisord作爲守護進程運行的時候,設置這個參數的話,啓動 supervisord進程之前,會先切換到這個目錄 默認不設置。。。非必須設置 ;nocleanup=true ; 這個參數當爲false的時候,會在supervisord進程啓動的時候,把以前子進程 產生的日誌文件(路徑爲AUTO的情況下)清除掉。有時候咱們想要看歷史日誌,當 然不想日誌被清除了。所以可以設置爲true 默認是false,有調試需求的同學可以設置爲true。。。非必須設置 ;childlogdir=/tmp ; 當子進程日誌路徑爲AUTO的時候,子進程日誌文件的存放路徑。 默認路徑是這個東西,執行下面的這個命令看看就OK了,處理的東西就默認路徑 python -c "import tempfile;print tempfile.gettempdir()" 非必須設置 ;environment=KEY="value" ; 這個是用來設置環境變量的,supervisord在linux中啓動默認繼承了linux的 環境變量,在這裏可以設置supervisord進程特有的其他環境變量。 supervisord啓動子進程時,子進程會拷貝父進程的內存空間內容。 所以設置的 這些環境變量也會被子進程繼承。 小例子:environment=name="haha",age="hehe" 默認爲不設置。。。非必須設置 ;strip_ansi=false ; 這個選項如果設置爲true,會清除子進程日誌中的所有ANSI 序列。什麼是ANSI 序列呢?就是我們的\n,\t這些東西。 默認爲false。。。非必須設置 ; the below section must remain in the config file for RPC ; (supervisorctl/web interface) to work, additional interfaces may be ; added by defining them in separate rpcinterface: sections [rpcinterface:supervisor] ;這個選項是給XML_RPC用的,當然你如果想使用supervisord或者web server 這 個選項必須要開啓的 supervisor.rpcinterface_factory = supervisor.rpcinterface:make_main_rpcinterface [supervisorctl] ;這個主要是針對supervisorctl的一些配置 serverurl=unix:///tmp/supervisor.sock ; 這個是supervisorctl本地連接supervisord的時候,本地UNIX socket 路徑,注意這個是和前面的[unix_http_server]對應的 默認值就是unix:///tmp/supervisor.sock。。非必須設置 ;serverurl=http://127.0.0.1:9001 ; 這個是supervisorctl遠程連接supervisord的時候,用到的TCP socket路徑 注意這個和前面的[inet_http_server]對應 默認就是http://127.0.0.1:9001。。。非必須項 ;username=chris ; 用戶名 默認空。。非必須設置 ;password=123 ; 密碼 默認空。。非必須設置 ;prompt=mysupervisor ; 輸入用戶名密碼時候的提示符 默認supervisor。。非必須設置 ;history_file=~/.sc_history ; 這個參數和shell中的history類似,我們可以用上下鍵來查找前面執行過的命令 默認是no file的。。所以我們想要有這種功能,必須指定一個文件。。。非 必須設置 ; The below sample program section shows all possible program subsection values, ; create one or more 'real' program: sections to be able to control them under ; supervisor. ;[program:theprogramname] ;這個就是咱們要管理的子進程了,":"後面的是名字,最好別亂寫和實際進程 有點關聯最好。這樣的program我們可以設置一個或多個,一個program就是 要被管理的一個進程 ;command=/bin/cat ; 這個就是我們的要啓動進程的命令路徑了,可以帶參數 例子:/home/test.py -a 'hehe' 有一點需要注意的是,我們的command只能是那種在終端運行的進程,不能是 守護進程。這個想想也知道了,比如說command=service httpd start。 httpd這個進程被linux的service管理了,我們的supervisor再去啓動這個命令 這已經不是嚴格意義的子進程了。 這個是個必須設置的項 ;process_name=%(program_name)s ; 這個是進程名,如果我們下面的numprocs參數爲1的話,就不用管這個參數 了,它默認值%(program_name)s也就是上面的那個program冒號後面的名字, 但是如果numprocs爲多個的話,那就不能這麼幹了。想想也知道,不可能每個 進程都用同一個進程名吧。 ;numprocs=1 ; 啓動進程的數目。當不爲1時,就是進程池的概念,注意process_name的設置 默認爲1 。。非必須設置 ;directory=/tmp ; 進程運行前,會前切換到這個目錄 默認不設置。。。非必須設置 ;umask=022 ; 進程掩碼,默認none,非必須 ;priority=999 ; 子進程啓動關閉優先級,優先級低的,最先啓動,關閉的時候最後關閉 默認值爲999 。。非必須設置 ;autostart=true ; 如果是true的話,子進程將在supervisord啓動後被自動啓動 默認就是true 。。非必須設置 ;autorestart=unexpected ; 這個是設置子進程掛掉後自動重啓的情況,有三個選項,false,unexpected 和true。如果爲false的時候,無論什麼情況下,都不會被重新啓動, 如果爲unexpected,只有當進程的退出碼不在下面的exitcodes裏面定義的退 出碼的時候,纔會被自動重啓。當爲true的時候,只要子進程掛掉,將會被無 條件的重啓 ;startsecs=1 ; 這個選項是子進程啓動多少秒之後,此時狀態如果是running,則我們認爲啓 動成功了 默認值爲1 。。非必須設置 ;startretries=3 ; 當進程啓動失敗後,最大嘗試啓動的次數。。當超過3次後,supervisor將把 此進程的狀態置爲FAIL 默認值爲3 。。非必須設置 ;exitcodes=0,2 ; 注意和上面的的autorestart=unexpected對應。。exitcodes裏面的定義的 退出碼是expected的。 ;stopsignal=QUIT ; 進程停止信號,可以爲TERM, HUP, INT, QUIT, KILL, USR1, or USR2等信號 默認爲TERM 。。當用設定的信號去幹掉進程,退出碼會被認爲是expected 非必須設置 ;stopwaitsecs=10 ; 這個是當我們向子進程發送stopsignal信號後,到系統返回信息 給supervisord,所等待的最大時間。 超過這個時間,supervisord會向該 子進程發送一個強制kill的信號。 默認爲10秒。。非必須設置 ;stopasgroup=false ; 這個東西主要用於,supervisord管理的子進程,這個子進程本身還有 子進程。那麼我們如果僅僅幹掉supervisord的子進程的話,子進程的子進程 有可能會變成孤兒進程。所以咱們可以設置可個選項,把整個該子進程的 整個進程組都幹掉。 設置爲true的話,一般killasgroup也會被設置爲true。 需要注意的是,該選項發送的是stop信號 默認爲false。。非必須設置。。 ;killasgroup=false ; 這個和上面的stopasgroup類似,不過發送的是kill信號 ;user=chrism ; 如果supervisord是root啓動,我們在這裏設置這個非root用戶,可以用來 管理該program 默認不設置。。。非必須設置項 ;redirect_stderr=true ; 如果爲true,則stderr的日誌會被寫入stdout日誌文件中 默認爲false,非必須設置 ;stdout_logfile=/a/path ; 子進程的stdout的日誌路徑,可以指定路徑,AUTO,none等三個選項。 設置爲none的話,將沒有日誌產生。設置爲AUTO的話,將隨機找一個地方 生成日誌文件,而且當supervisord重新啓動的時候,以前的日誌文件會被 清空。當 redirect_stderr=true的時候,sterr也會寫進這個日誌文件 ;stdout_logfile_maxbytes=1MB ; 日誌文件最大大小,和[supervisord]中定義的一樣。默認爲50 ;stdout_logfile_backups=10 ; 和[supervisord]定義的一樣。默認10 ;stdout_capture_maxbytes=1MB ; 這個東西是設定capture管道的大小,當值不爲0的時候,子進程可以從stdout 發送信息,而supervisor可以根據信息,發送相應的event。 默認爲0,爲0的時候表達關閉管道。。。非必須項 ;stdout_events_enabled=false ; 當設置爲ture的時候,當子進程由stdout向文件描述符中寫日誌的時候,將 觸發supervisord發送PROCESS_LOG_STDOUT類型的event 默認爲false。。。非必須設置 ;stderr_logfile=/a/path ; 這個東西是設置stderr寫的日誌路徑,當redirect_stderr=true。這個就不用 設置了,設置了也是白搭。因爲它會被寫入stdout_logfile的同一個文件中 默認爲AUTO,也就是隨便找個地存,supervisord重啓被清空。。非必須設置 ;stderr_logfile_maxbytes=1MB ; 這個出現好幾次了,就不重複了 ;stderr_logfile_backups=10 ; 這個也是 ;stderr_capture_maxbytes=1MB ; 這個一樣,和stdout_capture一樣。 默認爲0,關閉狀態 ;stderr_events_enabled=false ; 這個也是一樣,默認爲false ;environment=A="1",B="2" ; 這個是該子進程的環境變量,和別的子進程是不共享的 ;serverurl=AUTO ; ; The below sample eventlistener section shows all possible ; eventlistener subsection values, create one or more 'real' ; eventlistener: sections to be able to handle event notifications ; sent by supervisor. ;[eventlistener:theeventlistenername] ;這個東西其實和program的地位是一樣的,也是suopervisor啓動的子進 程,不過它乾的活是訂閱supervisord發送的event。他的名字就叫 listener了。我們可以在listener裏面做一系列處理,比如報警等等 樓主這兩天干的活,就是弄的這玩意 ;command=/bin/eventlistener ; 這個和上面的program一樣,表示listener的可執行文件的路徑 ;process_name=%(program_name)s ; 這個也一樣,進程名,當下面的numprocs爲多個的時候,才需要。否則默認就 OK了 ;numprocs=1 ; 相同的listener啓動的個數 ;events=EVENT ; event事件的類型,也就是說,只有寫在這個地方的事件類型。纔會被髮送 ;buffer_size=10 ; 這個是event隊列緩存大小,單位不太清楚,樓主猜測應該是個吧。當buffer 超過10的時候,最舊的event將會被清除,並把新的event放進去。 默認值爲10。。非必須選項 ;directory=/tmp ; 進程執行前,會切換到這個目錄下執行 默認爲不切換。。。非必須 ;umask=022 ; 淹沒,默認爲none,不說了 ;priority=-1 ; 啓動優先級,默認-1,也不扯了 ;autostart=true ; 是否隨supervisord啓動一起啓動,默認true ;autorestart=unexpected ; 是否自動重啓,和program一個樣,分true,false,unexpected等,注意 unexpected和exitcodes的關係 ;startsecs=1 ; 也是一樣,進程啓動後跑了幾秒鐘,才被認定爲成功啓動,默認1 ;startretries=3 ; 失敗最大嘗試次數,默認3 ;exitcodes=0,2 ; 期望或者說預料中的進程退出碼, ;stopsignal=QUIT ; 幹掉進程的信號,默認爲TERM,比如設置爲QUIT,那麼如果QUIT來幹這個進程 那麼會被認爲是正常維護,退出碼也被認爲是expected中的 ;stopwaitsecs=10 ; max num secs to wait b4 SIGKILL (default 10) ;stopasgroup=false ; send stop signal to the UNIX process group (default false) ;killasgroup=false ; SIGKILL the UNIX process group (def false) ;user=chrism ;設置普通用戶,可以用來管理該listener進程。 默認爲空。。非必須設置 ;redirect_stderr=true ; 爲true的話,stderr的log會併入stdout的log裏面 默認爲false。。。非必須設置 ;stdout_logfile=/a/path ; 這個不說了,好幾遍了 ;stdout_logfile_maxbytes=1MB ; 這個也是 ;stdout_logfile_backups=10 ; 這個也是 ;stdout_events_enabled=false ; 這個其實是錯的,listener是不能發送event ;stderr_logfile=/a/path ; 這個也是 ;stderr_logfile_maxbytes=1MB ; 這個也是 ;stderr_logfile_backups ; 這個不說了 ;stderr_events_enabled=false ; 這個也是錯的,listener不能發送event ;environment=A="1",B="2" ; 這個是該子進程的環境變量 默認爲空。。。非必須設置 ;serverurl=AUTO ; override serverurl computation (childutils) ; The below sample group section shows all possible group values, ; create one or more 'real' group: sections to create "heterogeneous" ; process groups. ;[group:thegroupname] ;這個東西就是給programs分組,劃分到組裏面的program。我們就不用一個一個去操作了 我們可以對組名進行統一的操作。 注意:program被劃分到組裏面之後,就相當於原來 的配置從supervisor的配置文件裏消失了。。。supervisor只會對組進行管理,而不再 會對組裏面的單個program進行管理了 ;programs=progname1,progname2 ; 組成員,用逗號分開 這個是個必須的設置項 ;priority=999 ; 優先級,相對於組和組之間說的 默認999。。非必須選項 ; The [include] section can just contain the "files" setting. This ; setting can list multiple files (separated by whitespace or ; newlines). It can also contain wildcards. The filenames are ; interpreted as relative to this file. Included files *cannot* ; include files themselves. ;[include] ;這個東西挺有用的,當我們要管理的進程很多的時候,寫在一個文件裏面 就有點大了。我們可以把配置信息寫到多個文件中,然後include過來 ;files = relative/directory/*.ini
7、常見錯誤總結
BACKOFF Exited too quickly (process log may have details)
由於supervisor 比較適合監控業務應用,且只能監控前臺程序,php fork方式實現的daemon和其他的daemon程序不能用它監控,否則就會出現偶爾報錯。
假如 redis 需要用supervisor監控,需要在redis主配置文件中,將其修改爲非daemon模式啓動。
更多詳細用法見官網: http://supervisord.org/
二、Monit
monit是一個開源的輕量級監控工具,功能十分強大。可以從多個層面進行監控,可以自動維護進程,發送郵件報警等。
系統監控:進程狀態,系統負載,cpu負載,內存佔用等。
進程監控:monit可以監控守護進程,當被監控進程異常退出時,可以自動被拉起。
文件系統:Monit可以監控本地文件、目錄、文件系統的變化,包括時間戳、校驗值、大小的變化。例如,可以監控文件sha1以及md5的值,來監控文件是否發生變化
網絡監控:monit可以監控網絡連接,支持TCP、UDP、Unix domain sockets以及HTTP、SMTP等。
monit 官網:https://mmonit.com/monit/
1、程序安裝
# 安裝方式分爲兩種 # 使用 yum 安裝 yum install monit -y # 源碼安裝 tar xf monit-5.18.tar.gz cd monit-5.18 ./configure --prefix=/usr/local/monit make && make install # 提供主配置文件 cp monitrc /etc/monitrc
2、配置應用解析
主配置文件:/etc/monitrc
############################################################################### ## Monit control file ############################################################################### # 檢查週期,默認爲2分鐘,可以根據需要自行調節,這裏改成30秒。 set daemon 30 # 日誌文件 set logfile /var/log/monit.log # 設置郵件服務器 set mailserver 'smtp.163.com' # 指定郵件服務器地址,IP or HostName port 465 using ssl username '[email protected]' password '123456' # 設置告警郵件的接收地址 set alert [email protected] # 設置郵件格式 set mail-format { from: [email protected] # 郵件發送人 — 如果使用網易郵箱,郵件發送人必須爲郵箱賬號,或者包含郵箱賬號 subject: monit alert -- $EVENT $SERVICE message: $EVENT Service $SERVICE Date: $DATE Action: $ACTION Host: $HOST Description: $DESCRIPTION Your faithful employee, Monit } # monit內置了一個Web頁面的狀態監視 set httpd port 2812 and use address 0.0.0.0 # 設置監聽的IP allow 115.116.139.162 # 設置允許訪問的IP allow localhost allow 192.168.0.0/16 allow admin:monit # 設置用於訪問驗證的用戶名:密碼 # 可以包含擴展配置文件,便於配置的分類管理 include /etc/monit.d/*
系統運行狀況監控
system_base.conf
# 主機名,可以是IP或者域名(其他爲默認參數,可以根據自己需求微調) check system www.example.com if loadavg (1min) > 4 then alert if loadavg (5min) > 2 then alert if memory usage > 75% then alert if cpu usage (user) > 70% then alert if cpu usage (system) > 30% then alert if cpu usage (wait) > 20% then alert
監控Nginx
nginx_monit.conf
# 提供主進程pid文件 check process nginx with pidfile /alidata/server/nginx/logs/nginx.pid # 進程啓動命令,必須寫絕對路徑 start program = "/etc/init.d/nginx start" with timeout 30 seconds # 進程關閉命令 stop program = "/etc/init.d/nginx stop" # 端口狀態檢測,當狀態返回異常,則重啓服務。 if failed host 115.116.139.162 port 8081 protocol http then restart # 當端口狀態異常,報警 if failed host 115.116.139.162 port 8081 protocol http then alert # 在5個監視週期中,重啓了服務3次,則超時不再監視。 因爲如果重啓了多次不成功,很有可能繼續重啓下去也不會成功,避免一直無效的重啓,白白消耗系統資源影響主機上其他進程的工作,這時應該通知人工處理。 if 3 restarts within 5 cycles then timeout # 如果在5個監視週期內,該服務的CPU使用率都超過90%則告警。 if cpu usage > 90% for 5 cycles then alert # 設置分組,可選 group server # 可選的ssl端口的監控,如果有的話 # if failed port 443 type tcpssl protocol http # with timeout 15 seconds # then restart
監控Apache
apache_monit.conf
check process apache with pidfile /var/run/apache2.pid start program = "/etc/init.d/apache2 start" stop program = "/etc/init.d/apache2 stop" # Apache 耗系統資源比較厲害,額外添加一些關於這方面的監控設置 if cpu > 50% for 2 cycles then alert if cpu > 70% for 5 cycles then restart if totalmem > 1500 MB for 10 cycles then restart if children > 250 then restart if loadavg(5min) greater than 10 for 20 cycles then stop if failed host www.example.com port 8080 protocol http then restart if 3 restarts within 5 cycles then timeout group server # 可選,依賴於nginx depends on nginx
監控spawn-fcgi程序
check process spawn-fcgi with pidfile /var/run/spawn-fcgi.pid # spawn-fcgi一定要帶-P參數纔會生成pid文件,默認是沒有的 start program = "/usr/bin/spawn-fcgi -a 127.0.0.1 -p 8081 -C 10 -u userxxx -g groupxxx -P /var/run/spawn-fcgi.pid -f /usr/bin/php-cgi" stop program = "/usr/bin/killall /usr/bin/php-cgi" # fast-cgi走的不是http協議,monit的protocol參數也沒有cgi對應的設置,這裏去掉protocol http即可。 if failed host 127.0.0.1 port 8081 then restart if 3 restarts within 5 cycles then timeout group server depends on nginx
監控ssh
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
監控MySQL
mysql_monit.conf
check process mysql with pidfile /var/run/mysqld/mysqld.pid 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
設置開啓啓動
echo '/usr/local/monit/bin/monit -c /etc/monitrc' >> /etc/rc.d/rc.local
monit 命令行操作
monit start nginx 啓動進程
monit stop nginx 關閉進程
monit -h 查看幫助