Merge branch 'develop' into panel-triggers

Conflicts:
	plugins/datasource-zabbix/datasource.js
This commit is contained in:
Alexander Zobnin
2016-01-09 21:42:31 +03:00
3 changed files with 48 additions and 11 deletions

View File

@@ -4,6 +4,8 @@
[![Gitter](https://badges.gitter.im/Join%20Chat.svg)](https://gitter.im/alexanderzobnin/grafana-zabbix?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge) [![Gitter](https://badges.gitter.im/Join%20Chat.svg)](https://gitter.im/alexanderzobnin/grafana-zabbix?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge)
##### [Donate](https://www.paypal.me/alexanderzobnin)
##### See features overview and dashboards examples at Grafana-Zabbix [Live demo](http://play.grafana-zabbix.org) site. ##### See features overview and dashboards examples at Grafana-Zabbix [Live demo](http://play.grafana-zabbix.org) site.
##### Download [latest release](https://github.com/alexanderzobnin/grafana-zabbix/releases/latest) ##### Download [latest release](https://github.com/alexanderzobnin/grafana-zabbix/releases/latest)

View File

@@ -342,47 +342,65 @@ function (angular, _, dateMath) {
var annotation = options.annotation; var annotation = options.annotation;
var self = this; var self = this;
// Remove events below the chose severity
var severities = [];
for (var i = 5; i >= options.annotation.minseverity; i--) {
severities.push(i);
}
var params = { var params = {
output: ['triggerid', 'description'], output: ['triggerid', 'description', 'priority'],
preservekeys: 1,
filter: { 'priority': severities },
search: { search: {
'description': annotation.trigger 'description': options.annotation.trigger
}, },
searchWildcardsEnabled: true, searchWildcardsEnabled: true,
expandDescription: true expandDescription: true
}; };
if (annotation.host) { if (options.annotation.host) {
params.host = templateSrv.replace(annotation.host); params.host = templateSrv.replace(options.annotation.host);
} }
else if (annotation.group) { else if (options.annotation.group) {
params.group = templateSrv.replace(annotation.group); params.group = templateSrv.replace(options.annotation.group);
} }
return this.zabbixAPI.performZabbixAPIRequest('trigger.get', params) return this.zabbixAPI.performZabbixAPIRequest('trigger.get', params)
.then(function (result) { .then(function (result) {
if(result) { if(result) {
var objects = _.indexBy(result, 'triggerid'); var objects = result;
var params = { var params = {
output: 'extend', output: 'extend',
time_from: from, time_from: from,
time_till: to, time_till: to,
objectids: _.keys(objects), objectids: _.keys(objects),
select_acknowledges: 'extend' select_acknowledges: 'extend',
selectHosts: 'extend'
}; };
// Show problem events only // Show problem events only
if (!annotation.showOkEvents) { if (!options.annotation.showOkEvents) {
params.value = 1; params.value = 1;
} }
return self.zabbixAPI.performZabbixAPIRequest('event.get', params) return self.zabbixAPI.performZabbixAPIRequest('event.get', params)
.then(function (result) { .then(function (result) {
var events = []; var events = [];
_.each(result, function(e) { _.each(result, function(e) {
var title ='';
if (options.annotation.showHostname) {
title += e.hosts[0]['name'] + ': ';
}
title += Number(e.value) ? 'Problem' : 'OK';
// Hide acknowledged events
if (e.acknowledges.length > 0 && options.annotation.showAcknowledged) { return; }
var formatted_acknowledges = zabbixHelperSrv.formatAcknowledges(e.acknowledges); var formatted_acknowledges = zabbixHelperSrv.formatAcknowledges(e.acknowledges);
events.push({ events.push({
annotation: annotation, annotation: options.annotation,
time: e.clock * 1000, time: e.clock * 1000,
title: Number(e.value) ? 'Problem' : 'OK', title: title,
text: objects[e.objectid].description + formatted_acknowledges text: objects[e.objectid].description + formatted_acknowledges
}); });
}); });

View File

@@ -21,6 +21,11 @@
</label> </label>
<input type="text" style="width: 25em" ng-model='currentAnnotation.trigger' placeholder="Trigger name"></input> <input type="text" style="width: 25em" ng-model='currentAnnotation.trigger' placeholder="Trigger name"></input>
</div> </div>
<div class="editor-option">
<label class="small">Minimum severity
</label>
<select class="small" style="width: 113px" ng-init='currentAnnotation.minseverity = currentAnnotation.minseverity || 0' ng-model='currentAnnotation.minseverity' ng-options="v as k for (k, v) in {'Not classified': 0, 'Information': 1, 'Warning': 2, 'Average': 3, 'High': 4, 'Disaster': 5}" ng-change="render()"></select>
</div>
</div> </div>
<div class="editor-row"> <div class="editor-row">
@@ -32,5 +37,17 @@
<label for="currentAnnotation.showOkEvents" class="cr1">Show OK events <label for="currentAnnotation.showOkEvents" class="cr1">Show OK events
<tip>Show events, generated when trigger release to OK state</tip> <tip>Show events, generated when trigger release to OK state</tip>
</label> </label>
<input type="checkbox" class="cr1" id="currentAnnotation.showHostname"
ng-model="currentAnnotation.showHostname"
ng-checked="currentAnnotation.showHostname">
<label for="currentAnnotation.showHostname" class="cr1">Show hostname
<tip>Show the hostname the event belongs to</tip>
</label>
<input type="checkbox" class="cr1" id="currentAnnotation.showAcknowledged"
ng-model="currentAnnotation.showAcknowledged"
ng-checked="currentAnnotation.showAcknowledged">
<label for="currentAnnotation.showAcknowledged" class="cr1">Hide acknowledged events
<tip>Hide events, that have been acknowledged</tip>
</label>
</div> </div>
</div> </div>