设置“monit”来监控服务,但无法加载

设置“monit”来监控服务,但无法加载

我正在尝试在我的新服务器上运行此操作:

https://mmonit.com/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)

以下是我得到的结果监控日志

[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

然后当做一个时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

答案1

问题在于缺少allowuse address指令/etc/monit/monitrc。配置后,@AndrewNewby 可以连接到他的 monit-httpd。

答案2

为了使monit status或等命令monit restart service正常工作,必须启用 Monit 嵌入式 HTTP 服务器。这是因为 Monit 客户端使用 HTTP 接口将这些命令发送到 Monit 守护程序。

set httpd port 2812 and您可以通过取消注释 中的、use address localhostallow 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

相关内容