Merge branch 'feature-annotations' into develop
This commit is contained in:
@@ -617,31 +617,37 @@ function (angular, _, kbn) {
|
|||||||
search: {
|
search: {
|
||||||
'description': annotation.query
|
'description': annotation.query
|
||||||
},
|
},
|
||||||
|
searchWildcardsEnabled: true,
|
||||||
|
expandDescription: true
|
||||||
};
|
};
|
||||||
|
|
||||||
return this.performZabbixAPIRequest('trigger.get', params)
|
return this.performZabbixAPIRequest('trigger.get', params)
|
||||||
.then(function (result) {
|
.then(function (result) {
|
||||||
if(result) {
|
if(result) {
|
||||||
var obs = {};
|
var objects = _.indexBy(result, 'triggerid');
|
||||||
obs = _.indexBy(result, 'triggerid');
|
|
||||||
|
|
||||||
var params = {
|
var params = {
|
||||||
output: 'extend',
|
output: 'extend',
|
||||||
sortorder: 'DESC',
|
|
||||||
time_from: from,
|
time_from: from,
|
||||||
time_till: to,
|
time_till: to,
|
||||||
objectids: _.keys(obs)
|
objectids: _.keys(objects),
|
||||||
|
select_acknowledges: 'extend'
|
||||||
};
|
};
|
||||||
|
|
||||||
|
// Show problem events only
|
||||||
|
if (!annotation.showOkEvents) {
|
||||||
|
params.value = 1;
|
||||||
|
}
|
||||||
|
|
||||||
return self.performZabbixAPIRequest('event.get', params)
|
return self.performZabbixAPIRequest('event.get', params)
|
||||||
.then(function (result) {
|
.then(function (result) {
|
||||||
var events = [];
|
var events = [];
|
||||||
_.each(result, function(e) {
|
_.each(result, function(e) {
|
||||||
|
var formatted_acknowledges = formatAcknowledges(e.acknowledges);;
|
||||||
events.push({
|
events.push({
|
||||||
annotation: annotation,
|
annotation: annotation,
|
||||||
time: e.clock * 1000,
|
time: e.clock * 1000,
|
||||||
title: obs[e.objectid].description,
|
title: Number(e.value) ? 'Problem' : 'OK',
|
||||||
text: e.eventid,
|
text: objects[e.objectid].description + formatted_acknowledges,
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
return events;
|
return events;
|
||||||
@@ -691,4 +697,44 @@ function expandItemName(item) {
|
|||||||
name = name.replace('$' + i, key_params[i - 1]);
|
name = name.replace('$' + i, key_params[i - 1]);
|
||||||
};
|
};
|
||||||
return name;
|
return name;
|
||||||
};
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Convert Date object to local time in format
|
||||||
|
* YYYY-MM-DD HH:mm:ss
|
||||||
|
*
|
||||||
|
* @param {Date} date Date object
|
||||||
|
* @return {string} formatted local time YYYY-MM-DD HH:mm:ss
|
||||||
|
*/
|
||||||
|
function getShortTime(date) {
|
||||||
|
var MM = date.getMonth() < 10 ? '0' + date.getMonth() : date.getMonth();
|
||||||
|
var DD = date.getDate() < 10 ? '0' + date.getDate() : date.getDate();
|
||||||
|
var HH = date.getHours() < 10 ? '0' + date.getHours() : date.getHours();
|
||||||
|
var mm = date.getMinutes() < 10 ? '0' + date.getMinutes() : date.getMinutes();
|
||||||
|
var ss = date.getSeconds() < 10 ? '0' + date.getSeconds() : date.getSeconds();
|
||||||
|
return date.getFullYear() + '-' + MM + '-' + DD + ' ' + HH + ':' + mm + ':' + ss;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Format acknowledges.
|
||||||
|
*
|
||||||
|
* @param {array} acknowledges array of Zabbix acknowledge objects
|
||||||
|
* @return {string} HTML-formatted table
|
||||||
|
*/
|
||||||
|
function formatAcknowledges(acknowledges) {
|
||||||
|
if (acknowledges.length) {
|
||||||
|
var formatted_acknowledges = '<br><br>Acknowledges:<br><table><tr><td><b>Time</b></td><td><b>User</b></td><td><b>Comments</b></td></tr>';
|
||||||
|
_.each(_.map(acknowledges, function (ack) {
|
||||||
|
var time = new Date(ack.clock * 1000);
|
||||||
|
return '<tr><td><i>' + getShortTime(time) + '</i></td><td>' + ack.alias + ' (' + ack.name+ ' ' + ack.surname + ')' + '</td><td>' + ack.message + '</td></tr>';
|
||||||
|
}), function (ack) {
|
||||||
|
formatted_acknowledges = formatted_acknowledges.concat(ack)
|
||||||
|
});
|
||||||
|
formatted_acknowledges = formatted_acknowledges.concat('</table>')
|
||||||
|
return formatted_acknowledges;
|
||||||
|
} else {
|
||||||
|
return '';
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -2,7 +2,15 @@
|
|||||||
<div class="section">
|
<div class="section">
|
||||||
<h5>Zabbix trigger <tip>Example: Lack of free swap space</tip></h5>
|
<h5>Zabbix trigger <tip>Example: Lack of free swap space</tip></h5>
|
||||||
<div class="editor-option">
|
<div class="editor-option">
|
||||||
<input type="text" class="span10" ng-model='currentAnnotation.query' placeholder="Lack of free swap space"></input>
|
<input type="text" class="span10" ng-model="currentAnnotation.query" placeholder="Lack of free swap space"></input>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
<div class="editor-row">
|
||||||
|
<div class="section">
|
||||||
|
<h5>Options</h5>
|
||||||
|
<input type="checkbox" class="cr1" id="currentAnnotation.okEvents" ng-model="currentAnnotation.okEvents" ng-checked="currentAnnotation.okEvents">
|
||||||
|
<label for="currentAnnotation.okEvents" class="cr1">Show OK events <tip>Show events, generated when trigger release to OK state</tip></label>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|||||||
Reference in New Issue
Block a user