Ad Widget

Collapse

Update host tag on item value change

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • rbenea
    Member
    • Apr 2008
    • 35

    #1

    Update host tag on item value change

    Hi,

    I want to update a host tag value based on an item value. I am setting up the tag on host discovery with the correct value. Also I can have a trigger on item value change. What do I have to write in the trigger/action to issue a tag value update?

    Thank you,
    Rares
  • rbenea
    Member
    • Apr 2008
    • 35

    #2
    Yes, I confirm, I can set the tag at trigger level but not at host level. Also the help page says that {ITEM.VALUE} is not available at host level: https://www.zabbix.com/documentation...r/event_tags?s[]=tag#macro_support

    If my host is called "testhost" and has the unsigned item "testitem" that has a working trigger with the formula "{testhost:testitem.last()}>100", what would you write in the host "TestTag" value field so that TestTag will follow the testitem.VALUE?

    The idea is that I want to group the hosts based on the tag. Or even better, can I move a host from one group to another based on an item value?

    Thank you,
    Rares
    Last edited by rbenea; 19-02-2021, 12:00.

    Comment

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

      #3
      If you already set it to hardcoded value, you can not change it. If you use macro like {ITEM.VALUE} as tag value, then your item value is populated to tag value.
      Last edited by cyber; 01-04-2021, 18:02.

      Comment

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

        #4
        Host groups are not dynamic, not formed based on tags... So if you want them based on tags, you need to script it and move your hosts around over API.

        Comment


        • epizarro
          epizarro commented
          Editing a comment
          the way is with script or preproc the value though zabbix api, you must use your api as text (non secret). This is an example using script item type to get the lastvalue from another host, but you can modify the ZAPIJSON var to your tag and return the value with a dependant item., params: itemid (get the itemid from browser url)

          obj = JSON.parse(value);
          itemid = obj.itemid;

          var ZAPIJSON = '{"jsonrpc":"2.0","method":"item.get","params":{"o utput":["lastvalue"],"itemids":' + itemid + '},"auth":"' + '{$ZABBIX_API_KEY}' + '","id":1}';
          var req = new HttpRequest();
          req.addHeader('Content-Type: application/json');
          var resp = req.post('http://127.0.0.1/api_jsonrpc.php', ZAPIJSON);

          if (req.getStatus() == 200) {
          return JSON.parse(resp).result[0].lastvalue;
          }
      Working...