Uploaded image for project: 'ZABBIX FEATURE REQUESTS'
  1. ZABBIX FEATURE REQUESTS
  2. ZBXNEXT-5835

Preprocessing rule: Numeric hash

XMLWordPrintable

    • Icon: New Feature Request New Feature Request
    • Resolution: Duplicate
    • Icon: Trivial Trivial
    • 5.0 (plan)
    • 4.4.6
    • Templates (T)
    • None

      Hi,

      I had to configure a new template in order to monitor some http redirections, they should change every 24h or an alarm has to raise.

      I did not find how do do this trough the web gui, I could't create a trigger to comparte the actual item text value to the one 24h ago (didn't find an easy way to compare strings),  but was able to do it via UserParameters:

      UserParameter=curl.get.redirecturl.hash[*],perl -le 'print shift()/1e27' $(printf "%f\n" 0x$(curl -m 5 -sI $1 | sed -n '/^Location:/ s/^Location:\s//p' | md5sum | cut -d ' ' -f1)) 

      So basically I get the URL of the redirection with curl, hash it with md5, that gives a hex number, which  is converted to decimal.

      That number is too big to be stored on a item as a float, so it is divided by 1e27.

      I thought that a preprocessing option to convert any text to a numeric hash value (probably using a more suitable hash function) can come very handy, as a easy way to compare strings in order to create triggers.

      Thank you.

       

            Unassigned Unassigned
            Héctor Héctor Sánchez
            Votes:
            0 Vote for this issue
            Watchers:
            4 Start watching this issue

              Created:
              Updated:
              Resolved: