【问题标题】:monit: monitoring certificatesmonit:监控证书
【发布时间】:2019-05-02 02:48:59
【问题描述】:

我目前正试图密切关注我的系统证书,以确保在到期前 30 天收到警报。作为一个例子,我拿了 google.com 并监控它的证书。查看monitrc文件我添加了这个:

check host google.com with address google.com
            if failed
                    port 443
                    protocol https
                    with ssl options {verify: enable}
                    certificate valid > 1095 days
            then alert

当我重新启动 monit 时出现错误,没有名为 google.com 的服务

【问题讨论】:

    标签: ssl certificate monit


    【解决方案1】:

    设置新的monit配置或更改/编辑当前配置时,应先重新加载以确保monit重新初始化守护进程

    重现问题

    # Edit monit config
    root@home:~# vim /etc/monit/conf-enabled/test
    
    # Restart right way will fail
    root@home:~# monit restart all
    There is no service named "google.com"
    
    # Logs
    [CEST Sep 12 19:16:29] info     : 'home' trying to restart
    [CEST Sep 12 19:16:29] info     : 'home' restart action done
    [CEST Sep 12 19:17:09] info     : 'home' restart on user request
    [CEST Sep 12 19:17:09] error    : HttpRequest: error -- client [::1]: HTTP/1.0 400 There is no service named "google.com"
    [CEST Sep 12 19:17:09] error    : There is no service named "google.com"
    

    解决方案

    # Edit monit config
    root@home:~# vim /etc/monit/conf-enabled/test
    
    # Reload to reinitialize monit
    root@home:~# monit reload
    Reinitializing monit daemon
    
    root@home:~# monit status
    Monit 5.25.2 uptime: 24m
    
    Remote Host 'google.com'
      status                       OK
      monitoring status            Monitored
      monitoring mode              active
      on reboot                    start
      port response time           878.069 ms to google.com:443 type TCP/IP using TLS (certificate valid for 69 days) protocol HTTP
      data collected               Thu, 12 Sep 2019 19:24:06
    

    【讨论】:

      【解决方案2】:

      您还可以使用Overseer 等软件运行定期测试,并使用Notify17 通知模板接收通知(参见示例recipe)。

      您可以使用如下测试规则:

      https://myurl.com/path must run https
      

      或者

      https://myurl.com/path must run ssl
      

      这些规则评估网站是否可通过 SSL 访问以及证书是否即将过期(您可以在 source code 中查看更多选项)。

      附:要轻松开始使用 Oververse,您可以查看Kubernetes deployment example

      【讨论】:

      • 与问题无关,可能是垃圾回答
      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2010-11-16
      • 2017-02-19
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多