how can i get last 20 issues like dashboard with zabbix api?
Ad Widget
Collapse
how to get last 20 issues with zabbix API?
Collapse
X
-
Looking at the source (2.0.7): frontends/php/dashboard.php#L51-L110 configure `make_latest_issues` in frontends/php/include/blocks.inc.php#L774-L986 .
Depending on your settings it looks like trigger.get gives you most of what you need:
(Snippet from above mentioned source..)
PHP Code://...
// get triggers
$options = array(
'groupids' => $filter['groupids'],
'hostids' => isset($filter['hostids']) ? $filter['hostids'] : null,
'monitored' => true,
'maintenance' => $filter['maintenance'],
'withLastEventUnacknowledged' => (!empty($filter['extAck']) && $filter['extAck'] == EXTACK_OPTION_UNACK) ? true : null,
'skipDependent' => true,
'filter' => array(
'priority' => $filter['severity'],
'value' => TRIGGER_VALUE_TRUE
),
'selectHosts' => array('hostid', 'name'),
'output' => array('triggerid', 'value_flags', 'error', 'url', 'expression', 'description', 'priority', 'type'),
'sortfield' => $filter['sortfield'],
'sortorder' => $filter['sortorder'],
'limit' => isset($filter['limit']) ? $filter['limit'] : DEFAULT_LATEST_ISSUES_CNT
);
$triggers = API::Trigger()->get($options);
//...
-
Thanks for the reply chrischris, But what parameter should I use to get host name, issue and age like dashboard?Looking at the source (2.0.7): frontends/php/dashboard.php#L51-L110 configure `make_latest_issues` in frontends/php/include/blocks.inc.php#L774-L986 .
Depending on your settings it looks like trigger.get gives you most of what you need:
(Snippet from above mentioned source..)
PHP Code://...
// get triggers
$options = array(
'groupids' => $filter['groupids'],
'hostids' => isset($filter['hostids']) ? $filter['hostids'] : null,
'monitored' => true,
'maintenance' => $filter['maintenance'],
'withLastEventUnacknowledged' => (!empty($filter['extAck']) && $filter['extAck'] == EXTACK_OPTION_UNACK) ? true : null,
'skipDependent' => true,
'filter' => array(
'priority' => $filter['severity'],
'value' => TRIGGER_VALUE_TRUE
),
'selectHosts' => array('hostid', 'name'),
'output' => array('triggerid', 'value_flags', 'error', 'url', 'expression', 'description', 'priority', 'type'),
'sortfield' => $filter['sortfield'],
'sortorder' => $filter['sortorder'],
'limit' => isset($filter['limit']) ? $filter['limit'] : DEFAULT_LATEST_ISSUES_CNT
);
$triggers = API::Trigger()->get($options);
//...
Comment
Comment