設置“monit”來監控服務,但無法載入
我正在嘗試在我的新伺服器上進行此操作:
我已經安裝了它,但是當我嘗試執行任何命令時,它會超時:
root@mail:~# monit status /etc/monit/monitrc:298: Include failed -- Success '/etc/monit/conf.d/*' /etc/monit/monitrc:299: Include failed -- Success '/etc/monit/conf-enabled/*' Cannot create socket to [192.168.1.34]:2812 -- Connection timed out
我在**/etc/monit/monitrc**的配置有:
set httpd port 2812 and use address 192.168.1.34 # only accept connection from localhost # allow localhost # allow localhost to connect to the server and # allow admin:monit # require user 'admin' with password 'monit'
…當我重新載入時,它看起來很好:
root@mail:~# monit reload /etc/monit/monitrc:298: Include failed -- Success '/etc/monit/conf.d/*' /etc/monit/monitrc:299: Include failed -- Success '/etc/monit/conf-enabled/*' Reinitializing monit daemon
然而,當我查看狀態時,我得到了連接錯誤。我也試過用 127.0.0.1 來做,因為這是我
ping localhost
從 SSH做的我正在使用 Ubuntu 16 順便說一句。我使用以下方法安裝 Monit:
sudo apt-get install monit
關於我可以檢查什麼的任何建議?我在畫一個空白。
根據要求,這是來自的輸出
netstat -tulpen
:root@mail:~# netstat -tulpen Active Internet connections (only servers) Proto Recv-Q Send-Q Local Address Foreign Address State User Inode PID/Program name tcp 0 0 127.0.0.1:10025 0.0.0.0:* LISTEN 5001 16892 3763/python tcp 0 0 127.0.0.1:3306 0.0.0.0:* LISTEN 109 178201 20577/mysqld tcp 0 0 127.0.0.1:11211 0.0.0.0:* LISTEN 118 617295 24128/memcached tcp 0 0 0.0.0.0:143 0.0.0.0:* LISTEN 0 623080 26101/dovecot tcp 0 0 0.0.0.0:80 0.0.0.0:* LISTEN 0 625168 26188/nginx -g daem tcp 0 0 0.0.0.0:22 0.0.0.0:* LISTEN 0 15430 3624/sshd tcp 0 0 127.0.0.1:5432 0.0.0.0:* LISTEN 115 16232 3696/postgres tcp 0 0 0.0.0.0:443 0.0.0.0:* LISTEN 0 625170 26188/nginx -g daem tcp 0 0 0.0.0.0:4190 0.0.0.0:* LISTEN 0 623016 26101/dovecot tcp 0 0 0.0.0.0:993 0.0.0.0:* LISTEN 0 623082 26101/dovecot tcp 0 0 0.0.0.0:389 0.0.0.0:* LISTEN 0 16201 3739/slapd tcp6 0 0 :::143 :::* LISTEN 0 623081 26101/dovecot tcp6 0 0 :::80 :::* LISTEN 0 625169 26188/nginx -g daem tcp6 0 0 :::8181 :::* LISTEN 0 16585 4284/apache2 tcp6 0 0 :::22 :::* LISTEN 0 15439 3624/sshd tcp6 0 0 ::1:5432 :::* LISTEN 115 16233 3696/postgres tcp6 0 0 :::443 :::* LISTEN 0 625171 26188/nginx -g daem tcp6 0 0 :::4190 :::* LISTEN 0 623017 26101/dovecot tcp6 0 0 :::993 :::* LISTEN 0 623083 26101/dovecot tcp6 0 0 :::389 :::* LISTEN 0 16202 3739/slapd udp 0 0 127.0.0.1:11211 0.0.0.0:* 118 617296 24128/memcached udp 0 0 0.0.0.0:45852 0.0.0.0:* 5002 627092 25708/uwsgi
我也剛剛嘗試完全重啟伺服器,看看是否有幫助,但沒有區別。如果我嘗試再次啟動監控,我會得到:
root@mail:~# monit Monit daemon with PID 3609 awakened
這是來自的輸出
ufw status
:root@mail:~# ufw status Status: active To Action From -- ------ ---- Nginx Full ALLOW Anywhere Nginx HTTP ALLOW Anywhere 115/tcp ALLOW Anywhere 22 ALLOW Anywhere 8181 ALLOW Anywhere 2812 ALLOW Anywhere Nginx Full (v6) ALLOW Anywhere (v6) Nginx HTTP (v6) ALLOW Anywhere (v6) 115/tcp (v6) ALLOW Anywhere (v6) 22 (v6) ALLOW Anywhere (v6) 8181 (v6) ALLOW Anywhere (v6) 2812 (v6) ALLOW Anywhere (v6)
以下是我在monit.log中得到的內容:
[BST Mar 31 09:33:22] info : Reinitializing monit daemon [BST Mar 31 09:33:22] info : Awakened by the SIGHUP signal Reinitializing Monit - Control file '/etc/monit/monitrc' [BST Mar 31 09:33:22] info : Shutting down Monit HTTP server [BST Mar 31 09:33:22] info : Monit HTTP server stopped [BST Mar 31 09:33:23] info : Starting Monit HTTP server at [localhost]:2812 [BST Mar 31 09:33:23] info : Monit HTTP server started [BST Mar 31 09:33:23] info : 'mail.etrust.pro' Monit reloaded
然後在做 a 時
monit status
,我得到:[BST Mar 31 09:34:09] error : Denied connection from non-authorized client [127.0.0.1] [BST Mar 31 09:34:09] error : Error receiving data -- Connection reset by peer
問題是.
allow
_ 配置後@AndrewNewby 可以連接到他的monit-httpd。use address``/etc/monit/monitrc
為了使諸如
monit status
或之類的命令monit restart service
起作用,必須啟用 Monit 嵌入式 HTTP 伺服器。這是因為 Monit 客戶端使用 HTTP 介面將這些命令發送到 Monit 守護程序。
set httpd port 2812 and
您可以通過取消註釋、use address localhost
和中的allow localhost
行來啟用 HTTP 伺服器/etc/monit/monitrc
。您可能需要重新啟動 Monit (service monit restart
) 才能使這些更改生效。Ubuntu 16.04 上的
Include failed -- Success
消息是由https://bitbucket.org/tildeslash/monit/issues/438/include-optional-empty-directory-will引起的