Squid 监控

Squid 监控

我正在尝试使用 monit 来监控我的 squid 服务器。我使用 apt-get 在 raspbian stretch 上安装了 squid 服务器。squid 服务安装在 /etc/init.d/squid 下,我检查了 /var/run/squid.pid 下的 PID 文件是否存在。

当我运行 sudo monit start 时仍然得到:

There is no service named "squid"

我以 root 身份编译 monit 并将其添加到 systemd 中,如下所示: https://mmonit.com/wiki/Monit/Systemd

这是我在 /etc/monitrc 中创建的 monit 文件

set daemon 60
set logfile syslog facility log_daemon
set idfile /tmp/monit.id
set statefile /tmp/monit.state
set mailserver localhost
set alert [email protected]
set httpd port 2812 and
     #use address localhost  # only accept connection from localhost
      allow localhost        # allow localhost to connect to the server and
      allow admin:monit      # require user 'admin' with password 'monit'

 check process squid with pidfile /var/run/squid.pid
   group proxy
   start program = "/etc/init.d/squid start"
   stop  program = "/etc/init.d/squid stop"
   if failed host localhost port 3128
     send "GET /monit-check HTTP/1.0\r\n\r\n"
     expect "HTTP/[0-9\.]{3} 400 .*\r\n"
     for 5 cycles then restart

输出自service squid status

● squid.service - LSB: Squid HTTP Proxy version 3.x
   Loaded: loaded (/etc/init.d/squid; generated; vendor preset: enabled)
   Active: active (running) since Tue 2018-01-16 12:23:25 UTC; 2h 1min ago
     Docs: man:systemd-sysv-generator(8)
  Process: 24781 ExecStop=/etc/init.d/squid stop (code=exited, status=0/SUCCESS)
  Process: 24928 ExecStart=/etc/init.d/squid start (code=exited, status=0/SUCCESS)
 Main PID: 24970 (squid)
      CPU: 3.718s
   CGroup: /system.slice/squid.service
           ├─24968 /usr/sbin/squid -YC -f /etc/squid/squid.conf
           ├─24970 (squid-1) -YC -f /etc/squid/squid.conf
           ├─24971 (logfile-daemon) /var/log/squid/access.log
           ├─24984 (pinger)
           └─25378 (basic_ncsa_auth) /etc/squid/squid_passwd

Jan 16 12:23:24 raspberrypi systemd[1]: Starting LSB: Squid HTTP Proxy version 3.x...
Jan 16 12:23:25 raspberrypi squid[24968]: Squid Parent: will start 1 kids
Jan 16 12:23:25 raspberrypi squid[24968]: Squid Parent: (squid-1) process 24970 started
Jan 16 12:23:25 raspberrypi squid[24928]: Starting Squid HTTP Proxy: squid.
Jan 16 12:23:25 raspberrypi systemd[1]: squid.service: PID file /var/run/squid.pid not readable (yet?) after start: No sJan 16 12:23:25 raspberrypi systemd[1]: squid.service: Supervising process 24970 which is not our child. We'll most likeJan 16 12:23:25 raspberrypi systemd[1]: Started LSB: Squid HTTP Proxy version 3.x.

相关内容