{"id":98,"date":"2016-01-12T20:51:26","date_gmt":"2016-01-12T12:51:26","guid":{"rendered":"https:\/\/blog.espnlol.com\/?p=98"},"modified":"2016-01-12T22:12:27","modified_gmt":"2016-01-12T14:12:27","slug":"%e8%bf%9b%e7%a8%8b%e7%9b%91%e6%8e%a7%e7%a5%9e%e5%99%a8mmonitmonit","status":"publish","type":"post","link":"https:\/\/blog.espnlol.com\/?p=98","title":{"rendered":"\u8fdb\u7a0b\u76d1\u63a7\u795e\u5668M\/Monit+Monit"},"content":{"rendered":"<h2><strong>\u76ee\u7684<\/strong><\/h2>\n<h5>\u9700\u8981\u5b9e\u65f6\u76d1\u63a7\u8fdb\u7a0b\u7684\u72b6\u6001\uff0c\u53ef\u4ee5\u4ece\u9875\u9762\u91cd\u542f\u8fdb\u7a0b\uff0c\u96c6\u4e2d\u76d1\u63a7\u6240\u6709\u4e3b\u673a\u7684\u8fdb\u7a0b<\/h5>\n<h2><strong>\u5b89\u88c5<\/strong><\/h2>\n<h3>1\uff0c\u5b89\u88c5\u5305\u4e0b\u8f7d<\/h3>\n<p>Mmonit \u00a0 \u00a0\u00a0https:\/\/mmonit.com\/dist\/mmonit-3.5.1-linux-x64.tar.gz<\/p>\n<p>Monit \u00a0 \u00a0 \u00a0 \u00a0\u00a0https:\/\/mmonit.com\/monit\/dist\/monit-5.3.1.tar.gz<\/p>\n<h3>2\uff0c\u90e8\u7f72Mmonit<\/h3>\n<h4>1&gt; \u5b89\u88c5mysql<\/h4>\n<h4>\u4f20\u9001\u95e8\u00a0https:\/\/blog.espnlol.com\/?p=82<\/h4>\n<h4>2&gt;\u5b89\u88c5mmonit<\/h4>\n<pre class=\"lang:vim decode:true\">tar xvzf mmonit-3.5.1-linux-x64.tar.gz\r\nmv mmonit-3.5.1 \/usr\/local\r\nln -s \/usr\/local\/mmonit-3.5.1\/ \/usr\/local\/mmonit\r\nmysql \u2013u root \u2013p\r\npassword:******\r\nmysql&gt;create database mmonit;\r\nmysql&gt; GRANT ALL ON mmonit.* to mmonit@localhost identified by 'mmonit';\r\nmysql&gt;quit\r\ncd \/usr\/local\/mmonit\/db\r\nmysql -u mmonit mmonit -p &lt; mmonit-schema.mysql\r\n\r\n<\/pre>\n<h4>3&gt;\u914d\u7f6emmonit<\/h4>\n<pre class=\"lang:vim decode:true \">vi \/usr\/local\/mmonit\/conf\/server.xml\r\n\r\n&lt;Connector address=\"*\" port=\"8099\" processors=\"5\" \/&gt;  \u66f4\u6539web\u7aef\u53e3\r\n\u4f7f\u7528mysql\u6570\u636e\u5e93\uff0c\u5176\u4ed6\u6ce8\u91ca\u6389\r\n&lt;Realm url=\"mysql:\/\/mmonit:mmonit@127.0.0.1:3306\/mmonit\" \r\n                  minConnections=\"1\"\r\n                  maxConnections=\"100\"\r\n                  reapConnections=\"1000\" \/&gt;\r\n<\/pre>\n<h4>4&gt;\u542f\u52a8\u670d\u52a1<\/h4>\n<h4>\u5148\u5c06\u7cfb\u7edf\u65e5\u671f\u53d8\u66f4\u4e3a2011\u5e746\u67086\u65e5<\/h4>\n<h4>date 060610002011<\/h4>\n<h4>\u7136\u540e\u542f\u52a8\u670d\u52a1<\/h4>\n<h4>\/usr\/local\/mmonit\/bin\/mmonit start<\/h4>\n<h4>\u7136\u540e\u5c06\u7cfb\u7edf\u65f6\u95f4\u8fd8\u539f\u5373\u53ef<\/h4>\n<h4>ntpdate \u00a03.centos.pool.ntp.org<\/h4>\n<h4>\u5199\u5165\u542f\u52a8\u9879<\/h4>\n<h4>echo \u201c\/usr\/local\/mmonit\/bin\/mmonit start\u201d&gt;&gt;\/etc\/rc.d\/rc.local<\/h4>\n<h3>3,\u90e8\u7f72monit<\/h3>\n<h4>1&gt;\u5b89\u88c5monit<\/h4>\n<pre class=\"lang:vim decode:true\">tar xf monit-5.3.1.tar.gz \r\ncd monit-5.3.1\r\n.\/configure --prefix=\/usr\/local\/monit --with-openssl=\/usr\/local\/ssl --enable-threads\r\nmake\r\nmake install\r\ncd \/usr\/local\/monit\r\nmkdir etc\r\ncd etc\r\nmkdir monit.d\r\nvi monitrc\r\nset daemon  60              # check services at 1-minute intervals\r\nset logfile syslog facility log_daemon\r\nset idfile \/var\/.monit.id\r\nset statefile \/var\/.monit.state\r\n set eventqueue\r\n     basedir \/var\/monit  # set the base directory where events will be stored\r\n     slots 100           # optionally limit the queue size\r\n set mmonit http:\/\/monit:monit@127.0.0.1:8099\/collector\r\nset httpd port 2812 and\r\n    use address 0.0.0.0  # only accept connection from localhost\r\n    allow 127.0.0.1       # allow localhost to connect to the server and\r\n    allow admin:monit      # require user 'admin' with password 'monit'\r\n  check system sysload\r\n    if loadavg (1min) &gt; 20 then alert\r\n    if loadavg (5min) &gt; 30 then alert\r\n    if memory usage &gt; 75% then alert\r\n    if swap usage &gt; 25% then alert\r\n    if memory usage &gt; 75% then alert\r\n    if swap usage &gt; 25% then alert\r\n    if cpu usage (user) &gt; 70% then alert\r\n    if cpu usage (system) &gt; 30% then alert\r\n    if cpu usage (wait) &gt; 20% then alert\r\n    group server\r\ncheck filesystem root_space with path \/dev\/vda1\r\n    if space usage &gt; 80% for 5 times within 15 cycles then alert\r\ncheck filesystem data_space with path \/dev\/vdb\r\n    if space usage &gt; 80% for 5 times within 15 cycles then alert\r\ngroup server\r\n  include \/usr\/local\/monit\/etc\/monit.d\/*\r\n<\/pre>\n<h4>2&gt;\u914d\u7f6e<\/h4>\n<h4>\u66f4\u6539monitrc\u6743\u9650\u4e3a600<\/h4>\n<pre class=\"lang:vim decode:true\">chmod 600 \/usr\/local\/monit\/etc\/monitrc<\/pre>\n<h4>\u5728\/usr\/local\/monit\/etc\/monit.d\u4e0b\u521b\u5efa\u76f8\u5e94\u670d\u52a1\u76d1\u63a7\u914d\u7f6e\u6587\u4ef6<\/h4>\n<h4>\u4f8b\uff1anginx\u76d1\u63a7\u6587\u4ef6\u4e3anginx<\/h4>\n<h4><\/h4>\n<pre class=\"lang:vim decode:true \">echo \"\/usr\/local\/monit\/bin\/monit -c \/usr\/local\/monit\/etc\/monitrc\" &gt;&gt;\/etc\/rc.d\/rc.local\r\n\r\n\/usr\/local\/monit\/bin\/monit -c \/usr\/local\/monit\/etc\/monitrc<\/pre>\n<h3>4,\u9a8c\u8bc1\u4e0e\u76d1\u63a7<\/h3>\n<h4>1\uff09\u67e5\u770bmmonit web\u9875\u9762<\/h4>\n<h4>http:\/\/ip\uff1a8099<\/h4>\n<h4>\u9ed8\u8ba4\u7528\u6237admin \u9ed8\u8ba4\u5bc6\u7801swordfish\uff08\u81ea\u884c\u66f4\u6539\uff09<\/h4>\n<h4>\u67e5\u770b\u5404monit\u76d1\u63a7\u4e3b\u673a\u72b6\u6001\u6b63\u5e38<\/h4>\n<p><a href=\"https:\/\/blog.espnlol.com\/wp-content\/uploads\/2016\/01\/monit1.png\"><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-full wp-image-99\" src=\"https:\/\/blog.espnlol.com\/wp-content\/uploads\/2016\/01\/monit1.png\" alt=\"monit1\" width=\"1047\" height=\"671\" srcset=\"https:\/\/blog.espnlol.com\/wp-content\/uploads\/2016\/01\/monit1.png 1047w, https:\/\/blog.espnlol.com\/wp-content\/uploads\/2016\/01\/monit1-300x192.png 300w, https:\/\/blog.espnlol.com\/wp-content\/uploads\/2016\/01\/monit1-1024x656.png 1024w\" sizes=\"auto, (max-width: 1047px) 100vw, 1047px\" \/><\/a> <a href=\"https:\/\/blog.espnlol.com\/wp-content\/uploads\/2016\/01\/monit2.png\"><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-full wp-image-100\" src=\"https:\/\/blog.espnlol.com\/wp-content\/uploads\/2016\/01\/monit2.png\" alt=\"monit2\" width=\"1030\" height=\"323\" srcset=\"https:\/\/blog.espnlol.com\/wp-content\/uploads\/2016\/01\/monit2.png 1030w, https:\/\/blog.espnlol.com\/wp-content\/uploads\/2016\/01\/monit2-300x94.png 300w, https:\/\/blog.espnlol.com\/wp-content\/uploads\/2016\/01\/monit2-1024x321.png 1024w\" sizes=\"auto, (max-width: 1030px) 100vw, 1030px\" \/><\/a> <a href=\"https:\/\/blog.espnlol.com\/wp-content\/uploads\/2016\/01\/monit3.png\"><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-full wp-image-101\" src=\"https:\/\/blog.espnlol.com\/wp-content\/uploads\/2016\/01\/monit3.png\" alt=\"monit3\" width=\"1046\" height=\"736\" srcset=\"https:\/\/blog.espnlol.com\/wp-content\/uploads\/2016\/01\/monit3.png 1046w, https:\/\/blog.espnlol.com\/wp-content\/uploads\/2016\/01\/monit3-300x211.png 300w, https:\/\/blog.espnlol.com\/wp-content\/uploads\/2016\/01\/monit3-1024x721.png 1024w\" sizes=\"auto, (max-width: 1046px) 100vw, 1046px\" \/><\/a><\/p>\n<h3>5,\u8fc7\u671f\u91cd\u542f<\/h3>\n<h4>\u767b\u9646\u5230M\/Monit &#8211; Admin-General<\/h4>\n<p><a href=\"https:\/\/blog.espnlol.com\/wp-content\/uploads\/2016\/01\/monit4.png\"><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-full wp-image-102\" src=\"https:\/\/blog.espnlol.com\/wp-content\/uploads\/2016\/01\/monit4.png\" alt=\"monit4\" width=\"737\" height=\"518\" srcset=\"https:\/\/blog.espnlol.com\/wp-content\/uploads\/2016\/01\/monit4.png 737w, https:\/\/blog.espnlol.com\/wp-content\/uploads\/2016\/01\/monit4-300x211.png 300w\" sizes=\"auto, (max-width: 737px) 100vw, 737px\" \/><\/a><\/p>\n<p>\u5c06\u65f6\u95f4\u4fee\u6539\u5230\u8fc7\u671f\u524d\uff0c\u91cd\u542f\u4e4b\u540e\uff0c\u5728\u6062\u590d\u65f6\u95f4\u5373\u53ef<\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u76ee\u7684 \u9700\u8981\u5b9e\u65f6\u76d1\u63a7\u8fdb\u7a0b\u7684\u72b6\u6001\uff0c\u53ef\u4ee5\u4ece\u9875\u9762\u91cd\u542f\u8fdb\u7a0b\uff0c\u96c6\u4e2d\u76d1\u63a7\u6240\u6709\u4e3b\u673a\u7684\u8fdb\u7a0b \u5b89\u88c5  &hellip; <a href=\"https:\/\/blog.espnlol.com\/?p=98\">\u7ee7\u7eed\u9605\u8bfb <span class=\"meta-nav\">&rarr;<\/span><\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[21],"tags":[],"class_list":["post-98","post","type-post","status-publish","format-standard","hentry","category-linux"],"_links":{"self":[{"href":"https:\/\/blog.espnlol.com\/index.php?rest_route=\/wp\/v2\/posts\/98","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/blog.espnlol.com\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/blog.espnlol.com\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/blog.espnlol.com\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/blog.espnlol.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=98"}],"version-history":[{"count":3,"href":"https:\/\/blog.espnlol.com\/index.php?rest_route=\/wp\/v2\/posts\/98\/revisions"}],"predecessor-version":[{"id":104,"href":"https:\/\/blog.espnlol.com\/index.php?rest_route=\/wp\/v2\/posts\/98\/revisions\/104"}],"wp:attachment":[{"href":"https:\/\/blog.espnlol.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=98"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/blog.espnlol.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=98"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/blog.espnlol.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=98"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}