Ad Widget

Collapse

Getting current issues using API

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • Leviter
    Junior Member
    • May 2017
    • 5

    #1

    Getting current issues using API

    Hi,

    I am fairly new in using the API of Zabbix (using version 3.0.5). What I wanted to do, was create a simple (standalone) dashboard with the current issues. A bit like is being displayed on the standard Zabbix dashboard, but without a limit, different color coding etc etc.

    What I do not seem to figure out, is how everything is linked together or even better... how to get that data in one call.

    I never seem to get what I want. :-(

    The language I am using is Perl BTW.

    Is there someone who can give me a push in the right direction, or even some code samples?

    Cheers,
    -- Marcel
  • Leviter
    Junior Member
    • May 2017
    • 5

    #2
    ... a bit further

    I made some progress!

    Currently I can get some of the triggers, but somehow I do not get the same as on the Zabbix dashboard. I have no idea why. :-(

    Here is some of the code I have:

    Code:
    my $triggerparams =
      {
                    'output' => [
                            'triggerid', 'expression', 'description', 'url', 'priority', 'lastchange', 'comments', 'error', 'state', 'status', 'value'
                    ],
                    'selectHosts' => ['hostid', 'name', 'maintenance_status'],
                    'selectLastEvent' => ['eventid', 'acknowledged', 'objectid', 'clock', 'ns', 'value'],
                    'selectItems' => ['name'],
                    'skipDependent' => 1,
                    'sortfield' => ['lastchange'],
                    'sortorder' => ['DESC'],
                    'filter' => {'value' => 1},
                    'expandComment' => 1,
                    'expandExpression' => 1,
                    'monitored' => 1
      };
    
    my $triggers = $zabbix->do(
            'trigger.get',
            $triggerparams
    );
    
    for my $event (@$triggers) {
            for my $host ( @{ $event->{hosts} }) {
                    print "$host->{name} / $event->{description} / $event->{priority}<br/>";
            }
    }
    So small steps, but not all issues are returned. Can someone shed some light on this or tell me what I am doing wrong?

    Cheers,
    -- Marcel

    Comment

    • Leviter
      Junior Member
      • May 2017
      • 5

      #3
      Could it be that....

      Could it be that some triggers will not show up because of the "value=1" filter? What if a trigger has had several events of which some of them already ended... will these be filtered out?

      Is there a way to filter only triggers that have a lastEvent with a value of 1?

      Cheers,
      -- Marcel

      Comment

      • Leviter
        Junior Member
        • May 2017
        • 5

        #4
        Figured it out

        ... finally found out what was the problem. The user that was used to log into the API did not have permissions to read all triggers.

        Comment

        Working...