Ad Widget

Collapse

Item history

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • VadimIV
    Junior Member
    • Feb 2019
    • 3

    #1

    Item history

    good day masters. How can i reseive history of items. What tables is contained this data?
  • LenR
    Senior Member
    • Sep 2009
    • 1005

    #2
    It's easier to use the api instead of accessing the tables directly, see https://www.zabbix.com/documentation...erence/history

    If you want to use direct sql, something like phpmyadmin is great for learning the schema. It's been awhile, but there are different history tables for the item type, history for float, history_uint for integers etc. That table has an itemid, time and value. There is an items table that has the itemid info and hostid,

    This is some api code I found that is passed a group name and gets history. It's python using pyzabbix https://github.com/lukecyca/pyzabbix


    grp = str(sys.argv[1])
    group = zapi.hostgroup.get(filter={"name": grp}, output=["groupid"])
    #print json.dumps(group, indent=4, sort_keys=True)
    if len(group) > 0:
    groupValue = group[0]['groupid']

    items = zapi.item.get(search={"name": "icmp ping"}, groupids=groupValue, output=["itemid"])

    for item in items:

    hist = zapi.history.get(history=3,
    itemids=item['itemid'],sortfield='clock',sortorder='DESC',
    time_from=st,time_till=now,
    output='extend')

    if len(hist) > 0:
    if hist[0]['value'] <> '1':
    host = zapi.host.get(itemids=item['itemid'], output="extend")

    print host[0]['name']

    Comment


    • LenR
      LenR commented
      Editing a comment
      Pasting lost indents...
Working...