table mode with triggers stats, #141
This commit is contained in:
72
dist/datasource-zabbix/constants.js
vendored
72
dist/datasource-zabbix/constants.js
vendored
@@ -1,75 +1,79 @@
|
||||
"use strict";
|
||||
'use strict';
|
||||
|
||||
System.register([], function (_export, _context) {
|
||||
"use strict";
|
||||
|
||||
var MODE_METRICS, MODE_ITSERVICE, MODE_TEXT, MODE_ITEMID, MODE_TRIGGERS, SEV_NOT_CLASSIFIED, SEV_INFORMATION, SEV_WARNING, SEV_AVERAGE, SEV_HIGH, SEV_DISASTER, SHOW_ALL_TRIGGERS, SHOW_ALL_EVENTS, SHOW_OK_EVENTS, DATAPOINT_VALUE, DATAPOINT_TS;
|
||||
var MODE_METRICS, MODE_ITSERVICE, MODE_TEXT, MODE_ITEMID, MODE_TRIGGERS, SEV_NOT_CLASSIFIED, SEV_INFORMATION, SEV_WARNING, SEV_AVERAGE, SEV_HIGH, SEV_DISASTER, SHOW_ALL_TRIGGERS, SHOW_ALL_EVENTS, SHOW_OK_EVENTS, DATAPOINT_VALUE, DATAPOINT_TS, TRIGGER_SEVERITY;
|
||||
return {
|
||||
setters: [],
|
||||
execute: function () {
|
||||
_export("MODE_METRICS", MODE_METRICS = 0);
|
||||
_export('MODE_METRICS', MODE_METRICS = 0);
|
||||
|
||||
_export("MODE_METRICS", MODE_METRICS);
|
||||
_export('MODE_METRICS', MODE_METRICS);
|
||||
|
||||
_export("MODE_ITSERVICE", MODE_ITSERVICE = 1);
|
||||
_export('MODE_ITSERVICE', MODE_ITSERVICE = 1);
|
||||
|
||||
_export("MODE_ITSERVICE", MODE_ITSERVICE);
|
||||
_export('MODE_ITSERVICE', MODE_ITSERVICE);
|
||||
|
||||
_export("MODE_TEXT", MODE_TEXT = 2);
|
||||
_export('MODE_TEXT', MODE_TEXT = 2);
|
||||
|
||||
_export("MODE_TEXT", MODE_TEXT);
|
||||
_export('MODE_TEXT', MODE_TEXT);
|
||||
|
||||
_export("MODE_ITEMID", MODE_ITEMID = 3);
|
||||
_export('MODE_ITEMID', MODE_ITEMID = 3);
|
||||
|
||||
_export("MODE_ITEMID", MODE_ITEMID);
|
||||
_export('MODE_ITEMID', MODE_ITEMID);
|
||||
|
||||
_export("MODE_TRIGGERS", MODE_TRIGGERS = 4);
|
||||
_export('MODE_TRIGGERS', MODE_TRIGGERS = 4);
|
||||
|
||||
_export("MODE_TRIGGERS", MODE_TRIGGERS);
|
||||
_export('MODE_TRIGGERS', MODE_TRIGGERS);
|
||||
|
||||
_export("SEV_NOT_CLASSIFIED", SEV_NOT_CLASSIFIED = 0);
|
||||
_export('SEV_NOT_CLASSIFIED', SEV_NOT_CLASSIFIED = 0);
|
||||
|
||||
_export("SEV_NOT_CLASSIFIED", SEV_NOT_CLASSIFIED);
|
||||
_export('SEV_NOT_CLASSIFIED', SEV_NOT_CLASSIFIED);
|
||||
|
||||
_export("SEV_INFORMATION", SEV_INFORMATION = 1);
|
||||
_export('SEV_INFORMATION', SEV_INFORMATION = 1);
|
||||
|
||||
_export("SEV_INFORMATION", SEV_INFORMATION);
|
||||
_export('SEV_INFORMATION', SEV_INFORMATION);
|
||||
|
||||
_export("SEV_WARNING", SEV_WARNING = 2);
|
||||
_export('SEV_WARNING', SEV_WARNING = 2);
|
||||
|
||||
_export("SEV_WARNING", SEV_WARNING);
|
||||
_export('SEV_WARNING', SEV_WARNING);
|
||||
|
||||
_export("SEV_AVERAGE", SEV_AVERAGE = 3);
|
||||
_export('SEV_AVERAGE', SEV_AVERAGE = 3);
|
||||
|
||||
_export("SEV_AVERAGE", SEV_AVERAGE);
|
||||
_export('SEV_AVERAGE', SEV_AVERAGE);
|
||||
|
||||
_export("SEV_HIGH", SEV_HIGH = 4);
|
||||
_export('SEV_HIGH', SEV_HIGH = 4);
|
||||
|
||||
_export("SEV_HIGH", SEV_HIGH);
|
||||
_export('SEV_HIGH', SEV_HIGH);
|
||||
|
||||
_export("SEV_DISASTER", SEV_DISASTER = 5);
|
||||
_export('SEV_DISASTER', SEV_DISASTER = 5);
|
||||
|
||||
_export("SEV_DISASTER", SEV_DISASTER);
|
||||
_export('SEV_DISASTER', SEV_DISASTER);
|
||||
|
||||
_export("SHOW_ALL_TRIGGERS", SHOW_ALL_TRIGGERS = [0, 1]);
|
||||
_export('SHOW_ALL_TRIGGERS', SHOW_ALL_TRIGGERS = [0, 1]);
|
||||
|
||||
_export("SHOW_ALL_TRIGGERS", SHOW_ALL_TRIGGERS);
|
||||
_export('SHOW_ALL_TRIGGERS', SHOW_ALL_TRIGGERS);
|
||||
|
||||
_export("SHOW_ALL_EVENTS", SHOW_ALL_EVENTS = [0, 1]);
|
||||
_export('SHOW_ALL_EVENTS', SHOW_ALL_EVENTS = [0, 1]);
|
||||
|
||||
_export("SHOW_ALL_EVENTS", SHOW_ALL_EVENTS);
|
||||
_export('SHOW_ALL_EVENTS', SHOW_ALL_EVENTS);
|
||||
|
||||
_export("SHOW_OK_EVENTS", SHOW_OK_EVENTS = 1);
|
||||
_export('SHOW_OK_EVENTS', SHOW_OK_EVENTS = 1);
|
||||
|
||||
_export("SHOW_OK_EVENTS", SHOW_OK_EVENTS);
|
||||
_export('SHOW_OK_EVENTS', SHOW_OK_EVENTS);
|
||||
|
||||
_export("DATAPOINT_VALUE", DATAPOINT_VALUE = 0);
|
||||
_export('DATAPOINT_VALUE', DATAPOINT_VALUE = 0);
|
||||
|
||||
_export("DATAPOINT_VALUE", DATAPOINT_VALUE);
|
||||
_export('DATAPOINT_VALUE', DATAPOINT_VALUE);
|
||||
|
||||
_export("DATAPOINT_TS", DATAPOINT_TS = 1);
|
||||
_export('DATAPOINT_TS', DATAPOINT_TS = 1);
|
||||
|
||||
_export("DATAPOINT_TS", DATAPOINT_TS);
|
||||
_export('DATAPOINT_TS', DATAPOINT_TS);
|
||||
|
||||
_export('TRIGGER_SEVERITY', TRIGGER_SEVERITY = [{ val: 0, text: 'Not classified' }, { val: 1, text: 'Information' }, { val: 2, text: 'Warning' }, { val: 3, text: 'Average' }, { val: 4, text: 'High' }, { val: 5, text: 'Disaster' }]);
|
||||
|
||||
_export('TRIGGER_SEVERITY', TRIGGER_SEVERITY);
|
||||
}
|
||||
};
|
||||
});
|
||||
|
||||
2
dist/datasource-zabbix/constants.js.map
vendored
2
dist/datasource-zabbix/constants.js.map
vendored
@@ -1 +1 @@
|
||||
{"version":3,"sources":["../../src/datasource-zabbix/constants.js"],"names":["MODE_METRICS","MODE_ITSERVICE","MODE_TEXT","MODE_ITEMID","MODE_TRIGGERS","SEV_NOT_CLASSIFIED","SEV_INFORMATION","SEV_WARNING","SEV_AVERAGE","SEV_HIGH","SEV_DISASTER","SHOW_ALL_TRIGGERS","SHOW_ALL_EVENTS","SHOW_OK_EVENTS","DATAPOINT_VALUE","DATAPOINT_TS"],"mappings":";;;;;;;;;8BACaA,Y,GAAe,C;;;;gCACfC,c,GAAiB,C;;;;2BACjBC,S,GAAY,C;;;;6BACZC,W,GAAc,C;;;;+BACdC,a,GAAgB,C;;;;oCAGhBC,kB,GAAqB,C;;;;iCACrBC,e,GAAkB,C;;;;6BAClBC,W,GAAc,C;;;;6BACdC,W,GAAc,C;;;;0BACdC,Q,GAAW,C;;;;8BACXC,Y,GAAe,C;;;;mCAEfC,iB,GAAoB,CAAC,CAAD,EAAI,CAAJ,C;;;;iCACpBC,e,GAAkB,CAAC,CAAD,EAAI,CAAJ,C;;;;gCAClBC,c,GAAiB,C;;;;iCAGjBC,e,GAAkB,C;;;;8BAClBC,Y,GAAe,C","file":"constants.js","sourcesContent":["// Editor modes\nexport const MODE_METRICS = 0;\nexport const MODE_ITSERVICE = 1;\nexport const MODE_TEXT = 2;\nexport const MODE_ITEMID = 3;\nexport const MODE_TRIGGERS = 4;\n\n// Triggers severity\nexport const SEV_NOT_CLASSIFIED = 0;\nexport const SEV_INFORMATION = 1;\nexport const SEV_WARNING = 2;\nexport const SEV_AVERAGE = 3;\nexport const SEV_HIGH = 4;\nexport const SEV_DISASTER = 5;\n\nexport const SHOW_ALL_TRIGGERS = [0, 1];\nexport const SHOW_ALL_EVENTS = [0, 1];\nexport const SHOW_OK_EVENTS = 1;\n\n// Data point\nexport const DATAPOINT_VALUE = 0;\nexport const DATAPOINT_TS = 1;\n"]}
|
||||
{"version":3,"sources":["../../src/datasource-zabbix/constants.js"],"names":["MODE_METRICS","MODE_ITSERVICE","MODE_TEXT","MODE_ITEMID","MODE_TRIGGERS","SEV_NOT_CLASSIFIED","SEV_INFORMATION","SEV_WARNING","SEV_AVERAGE","SEV_HIGH","SEV_DISASTER","SHOW_ALL_TRIGGERS","SHOW_ALL_EVENTS","SHOW_OK_EVENTS","DATAPOINT_VALUE","DATAPOINT_TS","TRIGGER_SEVERITY","val","text"],"mappings":";;;;;;;;;8BACaA,Y,GAAe,C;;;;gCACfC,c,GAAiB,C;;;;2BACjBC,S,GAAY,C;;;;6BACZC,W,GAAc,C;;;;+BACdC,a,GAAgB,C;;;;oCAGhBC,kB,GAAqB,C;;;;iCACrBC,e,GAAkB,C;;;;6BAClBC,W,GAAc,C;;;;6BACdC,W,GAAc,C;;;;0BACdC,Q,GAAW,C;;;;8BACXC,Y,GAAe,C;;;;mCAEfC,iB,GAAoB,CAAC,CAAD,EAAI,CAAJ,C;;;;iCACpBC,e,GAAkB,CAAC,CAAD,EAAI,CAAJ,C;;;;gCAClBC,c,GAAiB,C;;;;iCAGjBC,e,GAAkB,C;;;;8BAClBC,Y,GAAe,C;;;;kCAEfC,gB,GAAmB,CAC9B,EAACC,KAAK,CAAN,EAASC,MAAM,gBAAf,EAD8B,EAE9B,EAACD,KAAK,CAAN,EAASC,MAAM,aAAf,EAF8B,EAG9B,EAACD,KAAK,CAAN,EAASC,MAAM,SAAf,EAH8B,EAI9B,EAACD,KAAK,CAAN,EAASC,MAAM,SAAf,EAJ8B,EAK9B,EAACD,KAAK,CAAN,EAASC,MAAM,MAAf,EAL8B,EAM9B,EAACD,KAAK,CAAN,EAASC,MAAM,UAAf,EAN8B,C","file":"constants.js","sourcesContent":["// Editor modes\nexport const MODE_METRICS = 0;\nexport const MODE_ITSERVICE = 1;\nexport const MODE_TEXT = 2;\nexport const MODE_ITEMID = 3;\nexport const MODE_TRIGGERS = 4;\n\n// Triggers severity\nexport const SEV_NOT_CLASSIFIED = 0;\nexport const SEV_INFORMATION = 1;\nexport const SEV_WARNING = 2;\nexport const SEV_AVERAGE = 3;\nexport const SEV_HIGH = 4;\nexport const SEV_DISASTER = 5;\n\nexport const SHOW_ALL_TRIGGERS = [0, 1];\nexport const SHOW_ALL_EVENTS = [0, 1];\nexport const SHOW_OK_EVENTS = 1;\n\n// Data point\nexport const DATAPOINT_VALUE = 0;\nexport const DATAPOINT_TS = 1;\n\nexport const TRIGGER_SEVERITY = [\n {val: 0, text: 'Not classified'},\n {val: 1, text: 'Information'},\n {val: 2, text: 'Warning'},\n {val: 3, text: 'Average'},\n {val: 4, text: 'High'},\n {val: 5, text: 'Disaster'}\n];\n"]}
|
||||
2
dist/datasource-zabbix/datasource.js
vendored
2
dist/datasource-zabbix/datasource.js
vendored
@@ -579,7 +579,7 @@ System.register(['lodash', 'app/core/utils/datemath', './utils', './migrations',
|
||||
if (hosts.length) {
|
||||
var hostids = _.map(hosts, 'hostid');
|
||||
var appids = _.map(apps, 'applicationid');
|
||||
return _this7.zabbix.getHostAlerts(hostids, appids, target.minSeverity, target.options.countTriggers, timeFrom, timeTo).then(function (triggers) {
|
||||
return _this7.zabbix.getHostAlerts(hostids, appids, target.minSeverity, target.countTriggers, timeFrom, timeTo).then(function (triggers) {
|
||||
return responseHandler.handleTriggersResponse(triggers, timeRange);
|
||||
});
|
||||
} else {
|
||||
|
||||
2
dist/datasource-zabbix/datasource.js.map
vendored
2
dist/datasource-zabbix/datasource.js.map
vendored
File diff suppressed because one or more lines are too long
@@ -118,9 +118,9 @@
|
||||
}">
|
||||
</div>
|
||||
|
||||
<div class="gf-form max-width-20" ng-show="ctrl.target.mode == editorMode.TRIGGERS">
|
||||
<div class="gf-form max-width-23" ng-show="ctrl.target.mode == editorMode.TRIGGERS">
|
||||
<label class="gf-form-label query-keyword width-8">Min Severity</label>
|
||||
<div class="gf-form-select-wrapper width-20">
|
||||
<div class="gf-form-select-wrapper width-16">
|
||||
<select class="gf-form-input"
|
||||
ng-change="ctrl.onTargetBlur()"
|
||||
ng-model="ctrl.target.minSeverity"
|
||||
@@ -129,9 +129,12 @@
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<gf-form-switch class="gf-form" label="Count" checked="ctrl.target.countTriggers" on-change="ctrl.onTargetBlur()">
|
||||
</gf-form-switch>
|
||||
|
||||
<div class="gf-form gf-form--grow">
|
||||
<label class="gf-form-label gf-form-label--grow">
|
||||
<a ng-click="ctrl.toggleQueryOptions()">
|
||||
<a ng-click="ctrl.toggleQueryOptions()" ng-hide="ctrl.target.mode == editorMode.TRIGGERS">
|
||||
<i class="fa fa-caret-down" ng-show="ctrl.showQueryOptions"></i>
|
||||
<i class="fa fa-caret-right" ng-hide="ctrl.showQueryOptions"></i>
|
||||
{{ctrl.queryOptionsText}}
|
||||
@@ -149,13 +152,6 @@
|
||||
on-change="ctrl.onQueryOptionChange()">
|
||||
</gf-form-switch>
|
||||
</div>
|
||||
<div class="gf-form offset-width-7" ng-show="ctrl.target.mode == editorMode.TRIGGERS">
|
||||
<gf-form-switch class="gf-form"
|
||||
label="Count triggers"
|
||||
checked="ctrl.target.options.countTriggers"
|
||||
on-change="ctrl.onQueryOptionChange()">
|
||||
</gf-form-switch>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- Item IDs editor mode -->
|
||||
|
||||
9
dist/datasource-zabbix/query.controller.js
vendored
9
dist/datasource-zabbix/query.controller.js
vendored
@@ -95,7 +95,7 @@ System.register(['app/plugins/sdk', 'lodash', './constants', './utils', './metri
|
||||
|
||||
_this.slaPropertyList = [{ name: "Status", property: "status" }, { name: "SLA", property: "sla" }, { name: "OK time", property: "okTime" }, { name: "Problem time", property: "problemTime" }, { name: "Down time", property: "downtimeTime" }];
|
||||
|
||||
_this.triggerSeverity = [{ val: 0, text: 'Not classified' }, { val: 1, text: 'Information' }, { val: 2, text: 'Warning' }, { val: 3, text: 'Average' }, { val: 4, text: 'High' }, { val: 5, text: 'Disaster' }];
|
||||
_this.triggerSeverity = c.TRIGGER_SEVERITY;
|
||||
|
||||
// Map functions for bs-typeahead
|
||||
_this.getGroupNames = _.bind(_this.getMetricNames, _this, 'groupList');
|
||||
@@ -137,9 +137,9 @@ System.register(['app/plugins/sdk', 'lodash', './constants', './utils', './metri
|
||||
'item': { 'filter': "" },
|
||||
'functions': [],
|
||||
'minSeverity': 3,
|
||||
'countTriggers': true,
|
||||
'options': {
|
||||
'showDisabledItems': false,
|
||||
'countTriggers': true
|
||||
'showDisabledItems': false
|
||||
}
|
||||
};
|
||||
_.defaults(target, targetDefaults);
|
||||
@@ -360,8 +360,7 @@ System.register(['app/plugins/sdk', 'lodash', './constants', './utils', './metri
|
||||
key: 'renderQueryOptionsText',
|
||||
value: function renderQueryOptionsText() {
|
||||
var optionsMap = {
|
||||
showDisabledItems: "Show disabled items",
|
||||
countTriggers: "Count Triggers"
|
||||
showDisabledItems: "Show disabled items"
|
||||
};
|
||||
var options = [];
|
||||
_.forOwn(this.target.options, function (value, key) {
|
||||
|
||||
File diff suppressed because one or more lines are too long
66
dist/datasource-zabbix/responseHandler.js
vendored
66
dist/datasource-zabbix/responseHandler.js
vendored
@@ -1,9 +1,21 @@
|
||||
'use strict';
|
||||
|
||||
System.register(['lodash'], function (_export, _context) {
|
||||
System.register(['lodash', 'app/core/table_model', './constants'], function (_export, _context) {
|
||||
"use strict";
|
||||
|
||||
var _;
|
||||
var _, TableModel, c;
|
||||
|
||||
function _toConsumableArray(arr) {
|
||||
if (Array.isArray(arr)) {
|
||||
for (var i = 0, arr2 = Array(arr.length); i < arr.length; i++) {
|
||||
arr2[i] = arr[i];
|
||||
}
|
||||
|
||||
return arr2;
|
||||
} else {
|
||||
return Array.from(arr);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Convert Zabbix API history.get response to Grafana format
|
||||
@@ -102,17 +114,47 @@ System.register(['lodash'], function (_export, _context) {
|
||||
if (_.isNumber(triggers)) {
|
||||
return {
|
||||
target: "triggers count",
|
||||
datapoints: [[triggers, timeRange[1]]]
|
||||
datapoints: [[triggers, timeRange[1] * 1000]]
|
||||
};
|
||||
} else {
|
||||
return triggers;
|
||||
var stats = getTriggerStats(triggers);
|
||||
var table = new TableModel();
|
||||
table.addColumn({ text: 'Host group' });
|
||||
_.each(_.orderBy(c.TRIGGER_SEVERITY, ['val'], ['desc']), function (severity) {
|
||||
table.addColumn({ text: severity.text });
|
||||
});
|
||||
_.each(stats, function (severity_stats, group) {
|
||||
var row = _.map(_.orderBy(_.toPairs(severity_stats), function (s) {
|
||||
return s[0];
|
||||
}, ['desc']), function (s) {
|
||||
return s[1];
|
||||
});
|
||||
row = _.concat.apply(_, [[group]].concat(_toConsumableArray(row)));
|
||||
table.rows.push(row);
|
||||
});
|
||||
return table;
|
||||
}
|
||||
}function convertHistoryPoint(point) {
|
||||
// Value must be a number for properly work
|
||||
return [Number(point.value), point.clock * 1000 + Math.round(point.ns / 1000000)];
|
||||
}function getTriggerStats(triggers) {
|
||||
var groups = _.uniq(_.flattenDeep(_.map(triggers, function (trigger) {
|
||||
return _.map(trigger.groups, 'name');
|
||||
})));
|
||||
// let severity = _.map(c.TRIGGER_SEVERITY, 'text');
|
||||
var stats = {};
|
||||
_.each(groups, function (group) {
|
||||
stats[group] = { 0: 0, 1: 0, 2: 0, 3: 0, 4: 0, 5: 0 }; // severity:count
|
||||
});
|
||||
_.each(triggers, function (trigger) {
|
||||
_.each(trigger.groups, function (group) {
|
||||
stats[group.name][trigger.priority]++;
|
||||
});
|
||||
});
|
||||
return stats;
|
||||
}
|
||||
|
||||
function convertTrendPoint(valueType, point) {
|
||||
function convertHistoryPoint(point) {
|
||||
// Value must be a number for properly work
|
||||
return [Number(point.value), point.clock * 1000 + Math.round(point.ns / 1000000)];
|
||||
}function convertTrendPoint(valueType, point) {
|
||||
var value;
|
||||
switch (valueType) {
|
||||
case "min":
|
||||
@@ -135,9 +177,15 @@ System.register(['lodash'], function (_export, _context) {
|
||||
}
|
||||
|
||||
return [Number(value), point.clock * 1000];
|
||||
}return {
|
||||
}
|
||||
|
||||
return {
|
||||
setters: [function (_lodash) {
|
||||
_ = _lodash.default;
|
||||
}, function (_appCoreTable_model) {
|
||||
TableModel = _appCoreTable_model.default;
|
||||
}, function (_constants) {
|
||||
c = _constants;
|
||||
}],
|
||||
execute: function () {
|
||||
_export('default', {
|
||||
|
||||
File diff suppressed because one or more lines are too long
4
dist/datasource-zabbix/zabbixAPI.service.js
vendored
4
dist/datasource-zabbix/zabbixAPI.service.js
vendored
@@ -426,7 +426,9 @@ System.register(['angular', 'lodash', './utils', './zabbixAPICore.service'], fun
|
||||
expandComment: true,
|
||||
monitored: true,
|
||||
skipDependent: true,
|
||||
selectLastEvent: 'extend'
|
||||
selectLastEvent: 'extend',
|
||||
selectGroups: 'extend',
|
||||
selectHosts: ['host', 'name']
|
||||
};
|
||||
|
||||
if (count) {
|
||||
|
||||
File diff suppressed because one or more lines are too long
4
dist/test/datasource-zabbix/constants.js
vendored
4
dist/test/datasource-zabbix/constants.js
vendored
@@ -1,4 +1,4 @@
|
||||
"use strict";
|
||||
'use strict';
|
||||
|
||||
Object.defineProperty(exports, "__esModule", {
|
||||
value: true
|
||||
@@ -25,3 +25,5 @@ var SHOW_OK_EVENTS = exports.SHOW_OK_EVENTS = 1;
|
||||
// Data point
|
||||
var DATAPOINT_VALUE = exports.DATAPOINT_VALUE = 0;
|
||||
var DATAPOINT_TS = exports.DATAPOINT_TS = 1;
|
||||
|
||||
var TRIGGER_SEVERITY = exports.TRIGGER_SEVERITY = [{ val: 0, text: 'Not classified' }, { val: 1, text: 'Information' }, { val: 2, text: 'Warning' }, { val: 3, text: 'Average' }, { val: 4, text: 'High' }, { val: 5, text: 'Disaster' }];
|
||||
|
||||
2
dist/test/datasource-zabbix/datasource.js
vendored
2
dist/test/datasource-zabbix/datasource.js
vendored
@@ -457,7 +457,7 @@ var ZabbixAPIDatasource = function () {
|
||||
if (hosts.length) {
|
||||
var hostids = _lodash2.default.map(hosts, 'hostid');
|
||||
var appids = _lodash2.default.map(apps, 'applicationid');
|
||||
return _this7.zabbix.getHostAlerts(hostids, appids, target.minSeverity, target.options.countTriggers, timeFrom, timeTo).then(function (triggers) {
|
||||
return _this7.zabbix.getHostAlerts(hostids, appids, target.minSeverity, target.countTriggers, timeFrom, timeTo).then(function (triggers) {
|
||||
return _responseHandler2.default.handleTriggersResponse(triggers, timeRange);
|
||||
});
|
||||
} else {
|
||||
|
||||
@@ -72,7 +72,7 @@ var ZabbixQueryController = exports.ZabbixQueryController = function (_QueryCtrl
|
||||
|
||||
_this.slaPropertyList = [{ name: "Status", property: "status" }, { name: "SLA", property: "sla" }, { name: "OK time", property: "okTime" }, { name: "Problem time", property: "problemTime" }, { name: "Down time", property: "downtimeTime" }];
|
||||
|
||||
_this.triggerSeverity = [{ val: 0, text: 'Not classified' }, { val: 1, text: 'Information' }, { val: 2, text: 'Warning' }, { val: 3, text: 'Average' }, { val: 4, text: 'High' }, { val: 5, text: 'Disaster' }];
|
||||
_this.triggerSeverity = c.TRIGGER_SEVERITY;
|
||||
|
||||
// Map functions for bs-typeahead
|
||||
_this.getGroupNames = _lodash2.default.bind(_this.getMetricNames, _this, 'groupList');
|
||||
@@ -114,9 +114,9 @@ var ZabbixQueryController = exports.ZabbixQueryController = function (_QueryCtrl
|
||||
'item': { 'filter': "" },
|
||||
'functions': [],
|
||||
'minSeverity': 3,
|
||||
'countTriggers': true,
|
||||
'options': {
|
||||
'showDisabledItems': false,
|
||||
'countTriggers': true
|
||||
'showDisabledItems': false
|
||||
}
|
||||
};
|
||||
_lodash2.default.defaults(target, targetDefaults);
|
||||
@@ -345,8 +345,7 @@ var ZabbixQueryController = exports.ZabbixQueryController = function (_QueryCtrl
|
||||
key: 'renderQueryOptionsText',
|
||||
value: function renderQueryOptionsText() {
|
||||
var optionsMap = {
|
||||
showDisabledItems: "Show disabled items",
|
||||
countTriggers: "Count Triggers"
|
||||
showDisabledItems: "Show disabled items"
|
||||
};
|
||||
var options = [];
|
||||
_lodash2.default.forOwn(this.target.options, function (value, key) {
|
||||
|
||||
48
dist/test/datasource-zabbix/responseHandler.js
vendored
48
dist/test/datasource-zabbix/responseHandler.js
vendored
@@ -8,8 +8,20 @@ var _lodash = require('lodash');
|
||||
|
||||
var _lodash2 = _interopRequireDefault(_lodash);
|
||||
|
||||
var _table_model = require('app/core/table_model');
|
||||
|
||||
var _table_model2 = _interopRequireDefault(_table_model);
|
||||
|
||||
var _constants = require('./constants');
|
||||
|
||||
var c = _interopRequireWildcard(_constants);
|
||||
|
||||
function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } else { var newObj = {}; if (obj != null) { for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) newObj[key] = obj[key]; } } newObj.default = obj; return newObj; } }
|
||||
|
||||
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
||||
|
||||
function _toConsumableArray(arr) { if (Array.isArray(arr)) { for (var i = 0, arr2 = Array(arr.length); i < arr.length; i++) { arr2[i] = arr[i]; } return arr2; } else { return Array.from(arr); } }
|
||||
|
||||
/**
|
||||
* Convert Zabbix API history.get response to Grafana format
|
||||
*
|
||||
@@ -113,13 +125,45 @@ function handleTriggersResponse(triggers, timeRange) {
|
||||
if (_lodash2.default.isNumber(triggers)) {
|
||||
return {
|
||||
target: "triggers count",
|
||||
datapoints: [[triggers, timeRange[1]]]
|
||||
datapoints: [[triggers, timeRange[1] * 1000]]
|
||||
};
|
||||
} else {
|
||||
return triggers;
|
||||
var stats = getTriggerStats(triggers);
|
||||
var table = new _table_model2.default();
|
||||
table.addColumn({ text: 'Host group' });
|
||||
_lodash2.default.each(_lodash2.default.orderBy(c.TRIGGER_SEVERITY, ['val'], ['desc']), function (severity) {
|
||||
table.addColumn({ text: severity.text });
|
||||
});
|
||||
_lodash2.default.each(stats, function (severity_stats, group) {
|
||||
var row = _lodash2.default.map(_lodash2.default.orderBy(_lodash2.default.toPairs(severity_stats), function (s) {
|
||||
return s[0];
|
||||
}, ['desc']), function (s) {
|
||||
return s[1];
|
||||
});
|
||||
row = _lodash2.default.concat.apply(_lodash2.default, [[group]].concat(_toConsumableArray(row)));
|
||||
table.rows.push(row);
|
||||
});
|
||||
return table;
|
||||
}
|
||||
}
|
||||
|
||||
function getTriggerStats(triggers) {
|
||||
var groups = _lodash2.default.uniq(_lodash2.default.flattenDeep(_lodash2.default.map(triggers, function (trigger) {
|
||||
return _lodash2.default.map(trigger.groups, 'name');
|
||||
})));
|
||||
// let severity = _.map(c.TRIGGER_SEVERITY, 'text');
|
||||
var stats = {};
|
||||
_lodash2.default.each(groups, function (group) {
|
||||
stats[group] = { 0: 0, 1: 0, 2: 0, 3: 0, 4: 0, 5: 0 }; // severity:count
|
||||
});
|
||||
_lodash2.default.each(triggers, function (trigger) {
|
||||
_lodash2.default.each(trigger.groups, function (group) {
|
||||
stats[group.name][trigger.priority]++;
|
||||
});
|
||||
});
|
||||
return stats;
|
||||
}
|
||||
|
||||
function convertHistoryPoint(point) {
|
||||
// Value must be a number for properly work
|
||||
return [Number(point.value), point.clock * 1000 + Math.round(point.ns / 1000000)];
|
||||
|
||||
@@ -498,7 +498,9 @@ function ZabbixAPIServiceFactory(alertSrv, zabbixAPICoreService) {
|
||||
expandComment: true,
|
||||
monitored: true,
|
||||
skipDependent: true,
|
||||
selectLastEvent: 'extend'
|
||||
selectLastEvent: 'extend',
|
||||
selectGroups: 'extend',
|
||||
selectHosts: ['host', 'name']
|
||||
};
|
||||
|
||||
if (count) {
|
||||
|
||||
@@ -20,3 +20,12 @@ export const SHOW_OK_EVENTS = 1;
|
||||
// Data point
|
||||
export const DATAPOINT_VALUE = 0;
|
||||
export const DATAPOINT_TS = 1;
|
||||
|
||||
export const TRIGGER_SEVERITY = [
|
||||
{val: 0, text: 'Not classified'},
|
||||
{val: 1, text: 'Information'},
|
||||
{val: 2, text: 'Warning'},
|
||||
{val: 3, text: 'Average'},
|
||||
{val: 4, text: 'High'},
|
||||
{val: 5, text: 'Disaster'}
|
||||
];
|
||||
|
||||
@@ -362,7 +362,7 @@ class ZabbixAPIDatasource {
|
||||
if (hosts.length) {
|
||||
let hostids = _.map(hosts, 'hostid');
|
||||
let appids = _.map(apps, 'applicationid');
|
||||
return this.zabbix.getHostAlerts(hostids, appids, target.minSeverity, target.options.countTriggers, timeFrom, timeTo)
|
||||
return this.zabbix.getHostAlerts(hostids, appids, target.minSeverity, target.countTriggers, timeFrom, timeTo)
|
||||
.then((triggers) => {
|
||||
return responseHandler.handleTriggersResponse(triggers, timeRange);
|
||||
});
|
||||
|
||||
@@ -118,9 +118,9 @@
|
||||
}">
|
||||
</div>
|
||||
|
||||
<div class="gf-form max-width-20" ng-show="ctrl.target.mode == editorMode.TRIGGERS">
|
||||
<div class="gf-form max-width-23" ng-show="ctrl.target.mode == editorMode.TRIGGERS">
|
||||
<label class="gf-form-label query-keyword width-8">Min Severity</label>
|
||||
<div class="gf-form-select-wrapper width-20">
|
||||
<div class="gf-form-select-wrapper width-16">
|
||||
<select class="gf-form-input"
|
||||
ng-change="ctrl.onTargetBlur()"
|
||||
ng-model="ctrl.target.minSeverity"
|
||||
@@ -129,9 +129,12 @@
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<gf-form-switch class="gf-form" label="Count" checked="ctrl.target.countTriggers" on-change="ctrl.onTargetBlur()">
|
||||
</gf-form-switch>
|
||||
|
||||
<div class="gf-form gf-form--grow">
|
||||
<label class="gf-form-label gf-form-label--grow">
|
||||
<a ng-click="ctrl.toggleQueryOptions()">
|
||||
<a ng-click="ctrl.toggleQueryOptions()" ng-hide="ctrl.target.mode == editorMode.TRIGGERS">
|
||||
<i class="fa fa-caret-down" ng-show="ctrl.showQueryOptions"></i>
|
||||
<i class="fa fa-caret-right" ng-hide="ctrl.showQueryOptions"></i>
|
||||
{{ctrl.queryOptionsText}}
|
||||
@@ -149,13 +152,6 @@
|
||||
on-change="ctrl.onQueryOptionChange()">
|
||||
</gf-form-switch>
|
||||
</div>
|
||||
<div class="gf-form offset-width-7" ng-show="ctrl.target.mode == editorMode.TRIGGERS">
|
||||
<gf-form-switch class="gf-form"
|
||||
label="Count triggers"
|
||||
checked="ctrl.target.options.countTriggers"
|
||||
on-change="ctrl.onQueryOptionChange()">
|
||||
</gf-form-switch>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- Item IDs editor mode -->
|
||||
|
||||
@@ -45,11 +45,7 @@ export class ZabbixQueryController extends QueryCtrl {
|
||||
{name: "Down time", property: "downtimeTime"}
|
||||
];
|
||||
|
||||
this.triggerSeverity = [
|
||||
{val: 0, text: 'Not classified'}, {val: 1, text:'Information'},
|
||||
{val: 2, text: 'Warning'}, {val: 3, text: 'Average'},
|
||||
{val: 4, text: 'High'}, {val: 5, text: 'Disaster'}
|
||||
];
|
||||
this.triggerSeverity = c.TRIGGER_SEVERITY;
|
||||
|
||||
// Map functions for bs-typeahead
|
||||
this.getGroupNames = _.bind(this.getMetricNames, this, 'groupList');
|
||||
@@ -89,9 +85,9 @@ export class ZabbixQueryController extends QueryCtrl {
|
||||
'item': { 'filter': "" },
|
||||
'functions': [],
|
||||
'minSeverity': 3,
|
||||
'countTriggers': true,
|
||||
'options': {
|
||||
'showDisabledItems': false,
|
||||
'countTriggers': true
|
||||
'showDisabledItems': false
|
||||
}
|
||||
};
|
||||
_.defaults(target, targetDefaults);
|
||||
@@ -293,8 +289,7 @@ export class ZabbixQueryController extends QueryCtrl {
|
||||
|
||||
renderQueryOptionsText() {
|
||||
var optionsMap = {
|
||||
showDisabledItems: "Show disabled items",
|
||||
countTriggers: "Count Triggers"
|
||||
showDisabledItems: "Show disabled items"
|
||||
};
|
||||
var options = [];
|
||||
_.forOwn(this.target.options, (value, key) => {
|
||||
|
||||
@@ -1,4 +1,6 @@
|
||||
import _ from 'lodash';
|
||||
import TableModel from 'app/core/table_model';
|
||||
import * as c from './constants';
|
||||
|
||||
/**
|
||||
* Convert Zabbix API history.get response to Grafana format
|
||||
@@ -105,14 +107,40 @@ function handleTriggersResponse(triggers, timeRange) {
|
||||
return {
|
||||
target: "triggers count",
|
||||
datapoints: [
|
||||
[triggers, timeRange[1]]
|
||||
[triggers, timeRange[1] * 1000]
|
||||
]
|
||||
};
|
||||
} else {
|
||||
return triggers;
|
||||
let stats = getTriggerStats(triggers);
|
||||
let table = new TableModel();
|
||||
table.addColumn({text: 'Host group'});
|
||||
_.each(_.orderBy(c.TRIGGER_SEVERITY, ['val'], ['desc']), (severity) => {
|
||||
table.addColumn({text: severity.text});
|
||||
});
|
||||
_.each(stats, (severity_stats, group) => {
|
||||
let row = _.map(_.orderBy(_.toPairs(severity_stats), (s) => s[0], ['desc']), (s) => s[1]);
|
||||
row = _.concat([group], ...row);
|
||||
table.rows.push(row);
|
||||
});
|
||||
return table;
|
||||
}
|
||||
}
|
||||
|
||||
function getTriggerStats(triggers) {
|
||||
let groups = _.uniq(_.flattenDeep(_.map(triggers, (trigger) => _.map(trigger.groups, 'name'))));
|
||||
// let severity = _.map(c.TRIGGER_SEVERITY, 'text');
|
||||
let stats = {};
|
||||
_.each(groups, (group) => {
|
||||
stats[group] = {0:0, 1:0, 2:0, 3:0, 4:0, 5:0}; // severity:count
|
||||
});
|
||||
_.each(triggers, (trigger) => {
|
||||
_.each(trigger.groups, (group) => {
|
||||
stats[group.name][trigger.priority]++;
|
||||
});
|
||||
});
|
||||
return stats;
|
||||
}
|
||||
|
||||
function convertHistoryPoint(point) {
|
||||
// Value must be a number for properly work
|
||||
return [
|
||||
|
||||
@@ -445,7 +445,9 @@ function ZabbixAPIServiceFactory(alertSrv, zabbixAPICoreService) {
|
||||
expandComment: true,
|
||||
monitored: true,
|
||||
skipDependent: true,
|
||||
selectLastEvent: 'extend'
|
||||
selectLastEvent: 'extend',
|
||||
selectGroups: 'extend',
|
||||
selectHosts: ['host', 'name']
|
||||
};
|
||||
|
||||
if (count) {
|
||||
|
||||
Reference in New Issue
Block a user