Ad Widget

Collapse

Certificate Monitoring zabbix Agent 2

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • z0x10
    Junior Member
    • Jul 2024
    • 6

    #1

    Certificate Monitoring zabbix Agent 2

    Dear all

    Got a question about customizing the cert monitoring on zabbix.
    It works very well with the default template.

    But is there a way to change the expiration date to expiration days until the certificate expires?
    That would be cool addition

    Thanks in advance...
    z0x10


  • kyus
    Senior Member
    • Feb 2024
    • 171

    #2
    Hey! I think that certificates don't display this information, but Zabbix collects the "Not Before" and "Not After" fields of the certificate.

    That said, you can create a calculated item inside your template that will calculate how many days are left before the certificate expires (that's essentialy what the trigger for this template already do).

    Your formula for a calculated item will probably look like this:
    (last(//cert.not_after)-now())/86400

    Comment

    • z0x10
      Junior Member
      • Jul 2024
      • 6

      #3
      Ola, thanks for the hint

      The thing is, I do not know how to add the formula to the template
      My goal is to have a dashboard item that shows the remaining days till the cert expires.

      Comment

      • markfree
        Senior Member
        • Apr 2019
        • 868

        #4
        Originally posted by z0x10
        Ola, thanks for the hint
        The thing is, I do not know how to add the formula to the template
        My goal is to have a dashboard item that shows the remaining days till the cert expires.
        Check out how to create a calculated item here. You can simply add an item to the template.
        Last edited by markfree; 22-10-2024, 04:28.

        Comment

        • z0x10
          Junior Member
          • Jul 2024
          • 6

          #5
          I got it know. I made a copy of the existing expiration item. And add then the mentioned formula to it.
          And it shows now the correct numbers of days. Seems that it took a while until it showed the correct value.

          Thanks for all the hints.

          Comment

          • mattyj2001
            Junior Member
            • Dec 2025
            • 2

            #6
            Is there a way to put this type of item in a template? I seem to be running into a problem with user macros in this context.

            If I use the above formula in the calculated item within a template, it says it can't find the key. Which I think is understandable because it doesn't reference a host.

            If I put the literal text from the existing 'not_after' item in there, it works (URL's changed to protect the innocent):

            HTML Code:
            (last(/example-host.com/cert.not_after["example.com, {HOST.IP}"]) - now()) / 86400
            But since we're templating, we may want to use macros:

            HTML Code:
            (last(/{HOST.HOST}/cert.not_after["{$WEBSITE.DOMAIN}, {HOST.IP}"]) - now()) / 86400
            However, this last one does not work. It seem to not be able to find "{$WEBSITE.DOMAIN}", which is a user macro on the host.

            Is this expected, and can anyone think of a clever way to make this work within a template? Is there some syntactical magic available to make it recognize a user macro from a templated calculated key?

            Thanks!

            Comment

            • cyber
              Senior Member
              Zabbix Certified SpecialistZabbix Certified Professional
              • Dec 2006
              • 4806

              #7
              What does nto work? where? Whatever you just showed here, I was able to put into template (item with key "cert.not_after["{$WEBSITE.DOMAIN}, {HOST.IP}"]" and calcualted item "(last(/{HOST.HOST}/cert.not_after["{$WEBSITE.DOMAIN}, {HOST.IP}"]) - now()) / 86400" ....
              Or I just do not get exactly the point... which is nothing unusual ..

              Comment

              Working...