Ad Widget

Collapse

Curl+SNMP, Compare and Trigger

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • harvey
    Junior Member
    • Sep 2011
    • 13

    #1

    Curl+SNMP, Compare and Trigger

    Hi All,

    I'm using SNMP to monitor some routers. One of the metrics is the the firmware of the router. The router manufacturer offers a URL that can be curl'd with to show the latest firmware.

    What I would like to do it to be able to run a script locally on the Zabbix server that looks up the latest version and then some way compare the output of the snmp and curl value and if they are different trigger an alert.

    Is this possible, if so how??

    Many thanks.
    Last edited by harvey; 13-02-2019, 16:57.
  • kloczek
    Senior Member
    • Jun 2006
    • 1771

    #2
    I'm 100% sure that the same information about firmware version already served in OIDs tree
    KISS principle ..
    http://uk.linkedin.com/pub/tomasz-k%...zko/6/940/430/
    https://kloczek.wordpress.com/
    zapish - Zabbix API SHell binding https://github.com/kloczek/zapish
    My zabbix templates https://github.com/kloczek/zabbix-templates

    Comment

    • harvey
      Junior Member
      • Sep 2011
      • 13

      #3
      Originally posted by harvey
      Hi All,

      I'm using SNMP to monitor some routers. One of the metrics is the the firmware of the router. The router manufacturer offers a URL that can be curl'd with to show the latest firmware.

      What I would like to do it to be able to run a script locally on the Zabbix server that looks up the latest version and then some way compare the output of the snmp and curl value and if they are different trigger an alert.

      Is this possible, if so how??

      Many thanks.
      To clarify:-

      "What I would like to do it to be able to run a script locally on the Zabbix server to get the latest version and then compare the output to the snmp value and if they are different trigger an alert."

      Comment

      • harvey
        Junior Member
        • Sep 2011
        • 13

        #4
        Originally posted by kloczek
        I'm 100% sure that the same information about firmware version already served in OIDs tree
        KISS principle ..
        The actual installed router firmware version is accessible via SNMP but newer (not installed versions) are not accessible via SNMP. I want to trigger an alert when the routers firmware is out of date.

        Comment

        • harvey
          Junior Member
          • Sep 2011
          • 13

          #5
          I've made some progress, I created a script in '/usr/lib/zabbix/externalscripts' and created an item using the 'External Check' type. I now have two items, one pulling the installed firmware via SNMP and the latest version via CURL. Both item types are set as text and can see the values.

          I have now created a trigger with the following expression:-

          {MikrotikSNMPv3AES-SHA:1.3.6.1.4.1.14988.1.1.4.4.0.last()} <> {MikrotikSNMPv3AES-SHA:mikrotik_latest.sh.last()}

          However, I am getting the following error:-

          Cannot evaluate expression: expected numeric token at "6.43.11) <> (6.43.12)".

          I suspect <> is trying to compare numerical values, is there anyway to compare two strings together?

          Comment

          • harvey
            Junior Member
            • Sep 2011
            • 13

            #6
            Originally posted by harvey
            I've made some progress, I created a script in '/usr/lib/zabbix/externalscripts' and created an item using the 'External Check' type. I now have two items, one pulling the installed firmware via SNMP and the latest version via CURL. Both item types are set as text and can see the values.

            I have now created a trigger with the following expression:-

            {MikrotikSNMPv3AES-SHA:1.3.6.1.4.1.14988.1.1.4.4.0.last()} <> {MikrotikSNMPv3AES-SHA:mikrotik_latest.sh.last()}

            However, I am getting the following error:-

            Cannot evaluate expression: expected numeric token at "6.43.11) <> (6.43.12)".

            I suspect <> is trying to compare numerical values, is there anyway to compare two strings together?
            Or somehow create a numerical representation of the two strings and compare those? Or md5 hash the strings and compare?

            Comment

            • Evgeniy
              Senior Member
              • May 2012
              • 157

              #7
              One solution is to delete "." and compare numeric values.

              Comment

              • harvey
                Junior Member
                • Sep 2011
                • 13

                #8
                Originally posted by Evgeniy
                One solution is to delete "." and compare numeric values.
                Thanks, actually thats what I have been working on using preprocessing regex but I'm not very good with regex. if you have any idea what to put in for pattern and output that would be appreciated.

                Comment


                • Evgeniy
                  Evgeniy commented
                  Editing a comment
                  Not sure what will work, try, e.g. (\d*)\.(\d*)\.(\d*) -------------- \1\2\3
              • harvey
                Junior Member
                • Sep 2011
                • 13

                #9
                Thanks! That worked. I still want the pretty version available for viewing so I duplicated the items and applied the regex in pre processing on the duplicates. I was then able to create the trigger against the duplicated items.

                Is there any way to apply the regex within the trigger expression so I don't need the duplicate items?

                Hope that makes sense!

                Comment

                Working...