Ad Widget

Collapse

Get triggered values from database

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • JCS81
    Junior Member
    • Sep 2010
    • 5

    #1

    Get triggered values from database

    Hi all,

    I'm currently working on migrating from Nagios to Zabbix. On Nagios I've created a custom webpage showing the values of only the current triggered items, so only the problems on the network will be shown in detail. Like this:

    [hostname] [date/time] [issue description]
    SERVER1 09-09 12:13 The alerter service has been stopped
    SERVER3 14-09 09:09 Free space on D: is running low (0.8GB)

    I'm trying to recreate this for Zabbix (also with mysql) but i am unable to find the way of obaining if an item has been triggered. Does anyone know if this is a single value in the database and which one it is, or another way to find triggered items using mysql.

    Thanx!
  • richlv
    Senior Member
    Zabbix Certified Trainer
    Zabbix Certified SpecialistZabbix Certified Professional
    • Oct 2005
    • 3112

    #2
    you might want to look into the api - would be better than hooking into the db directly

    http://www.zabbix.com/documentation/1.8/api/trigger/get
    Zabbix 3.0 Network Monitoring book

    Comment

    • JCS81
      Junior Member
      • Sep 2010
      • 5

      #3
      Thanx for your reply. I've looked at the API for this but I'm a system engineer not a programmer, I know how to handle php/mysql quite well but working api's is all greek to me. I'll give it a try though, but my first attempt with farley's php class failed... If anyone has any suggestions

      Comment

      • richlv
        Senior Member
        Zabbix Certified Trainer
        Zabbix Certified SpecialistZabbix Certified Professional
        • Oct 2005
        • 3112

        #4
        zabcon just got raw api support - you might want to play around with it, as it allows to access api without coding
        Zabbix 3.0 Network Monitoring book

        Comment

        • JCS81
          Junior Member
          • Sep 2010
          • 5

          #5
          Hadn't heared about it yet, looks very nice indeed . I'm going to give it a try, thanx!

          Comment

          • JCS81
            Junior Member
            • Sep 2010
            • 5

            #6
            I've looked into Zabcon and it's a great tool indeed, but unfortunately also in Zabcon I cannot find the query to show only the currently triggered items / current errors.

            Comment

            • richlv
              Senior Member
              Zabbix Certified Trainer
              Zabbix Certified SpecialistZabbix Certified Professional
              • Oct 2005
              • 3112

              #7
              try something like :
              Code:
               +> raw json {"jsonrpc":"2.0","method":"trigger.get","params":{"only_true":true,"monitored":true,"filter":{"value":1}},"auth":"$auth","id":100}
              Zabbix 3.0 Network Monitoring book

              Comment

              • nelsonab
                Senior Member
                Zabbix Certified SpecialistZabbix Certified Professional
                • Sep 2006
                • 1233

                #8
                Or you could use the shorter method:

                Code:
                +> raw api trigger.get only_true=true, monitored=true, filter={value=1}
                The latest svn was updated to support item={item1=val} correctly.
                RHCE, author of zbxapi
                Ansible, the missing piece (Zabconf 2017): https://www.youtube.com/watch?v=R5T9NidjjDE
                Zabbix and SNMP on Linux (Zabconf 2015): https://www.youtube.com/watch?v=98PEHpLFVHM

                Comment

                • jameno123
                  Junior Member
                  • Sep 2006
                  • 7

                  #9
                  Get triggered values from database

                  Even though messing with the database is absolutely a last resort... I am as well stuck with having to deal with it for integration with an application im working on... Below is what i have found:

                  The zabbix database is a bit of a cluster {....} essentially join triggers against functions and functions against items and items against hosts... to find the hostname like:

                  Code:
                  select DISTINCT t.triggerid,i.itemid,h.host,t.description,t.lastchange from triggers t,functions f,items i,hosts h where t.triggerid = f.triggerid and f.itemid = i.itemid and i.hostid = h.hostid and t.value = 1 and h.status = 0
                  if you just want a list of active triggers with no hostnames:
                  something like:
                  Code:
                  select * from triggers where t.value = 1

                  It would seem that a simple "hostid" field in the triggers database, would be too much to ask for.
                  Last edited by jameno123; 12-05-2011, 05:31.

                  Comment

                  Working...