Ad Widget

Collapse

zabbix api - item lastvalue not in human readable format

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • ileventy
    Junior Member
    • Aug 2019
    • 3

    #1

    zabbix api - item lastvalue not in human readable format

    Hello,
    I'm using zabbix 4.0 jsonrpc api to integrate with my angular based application. In my custom web page, i show last value of the item, getting from item.lastvalue field, but it is not in human readable form, it is raw value. For example i'd like to see host availability as zabbix frontend shows, "unknown (2)", but i see just "2" (i use a value mapping "host availability") . Another example: when i set unit of "free disk space" item as "B", it is shown as "4.99 GB" in zabbix frontend, but "5357203456" in my application, because item.lastvalue is "5357203456". item object seems not having such a field?
  • kloczek
    Senior Member
    • Jun 2006
    • 1771

    #2
    That is the difference between actual value and what appears on presentation layer which is web frontend.
    API returns exact value stored in database.
    If you are writing your own presentation you can show that value as you want.
    Last edited by kloczek; 23-08-2019, 12:14.
    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

    • ileventy
      Junior Member
      • Aug 2019
      • 3

      #3
      wouldn't it be nice if api also provided the "calculated" value, so that every api client should not try to make his own implementation for just showing human readable format?

      Comment

      • ileventy
        Junior Member
        • Aug 2019
        • 3

        #4
        I think this violates the principle of "seperation of concerns". As an api user, i don't think i should make a very zabbix specific calculation on my side. For the cases i mentioned above:
        1. if the item value has a value mapping, find and get the mapped value yourself - with another api call.
        2. if the item's unit is "B", convert the value to "MB" or "GB", whichever you can. Also do this for items having unit Bps, b, bps ..etc.

        This logic should stay on zabbix server-side so that every user of api wouldn't have to implement the same thing for many times, maybe some with mistakes. The implementation exist on zabbix frontend. In my opinion, this can be moved to server side, and become a part of api, because this info is very useful.

        Comment

        Working...