PR for request #562
https://github.com/alexanderzobnin/grafana-zabbix/issues/562
This commit is contained in:
File diff suppressed because one or more lines are too long
@@ -1,70 +1,70 @@
|
||||
import _ from 'lodash';
|
||||
import ts from '../timeseries';
|
||||
|
||||
let datapoints = [[10.7104, 1498409636085], [10.578, 1498409651011], [10.5985, 1498409666628], [10.6877, 1498409681525], [10.5495, 1498409696586], [10.5981, 1498409711009], [10.5076, 1498409726949], [11.4807, 1498409741853], [11.6165, 1498409756165], [11.8575, 1498409771018], [11.9936, 1498409786056], [10.7566, 1498409801942], [10.7484, 1498409816010], [10.6038, 1498409831018], [10.2932, 1498409846010], [10.4912, 1498409861946], [10.4151, 1498409876871], [10.2401, 1498409891710], [10.4921, 1498409906143], [10.4413, 1498409921477], [10.6318, 1498409936147], [10.5277, 1498409951915], [10.6333, 1498409966052], [10.6417, 1498409981944], [10.4505, 1498409996867], [10.5812, 1498410011770], [10.4934, 1498410026573], [10.5731, 1498410041317], [10.5, 1498410056213], [10.6505, 1498410071013], [9.4035, 1498410086387]];
|
||||
|
||||
let series_set = [
|
||||
[[1.0247, 1498409631773], [0.9988, 1498409646697], [0.9817, 1498409661239], [0.9569, 1498409676045], [1.0331, 1498409691922], [1.0755, 1498409706546], [1.1862, 1498409721525], [1.2984, 1498409736175], [1.2389, 1498409751817], [1.1452, 1498409766783], [1.102, 1498409781699], [0.9647, 1498409796664], [1.0063, 1498409811627], [1.0318, 1498409826887], [1.065, 1498409841645], [1.0907, 1498409856647], [1.0229, 1498409871521], [1.0654, 1498409886031], [1.0568, 1498409901544], [1.0818, 1498409916194], [1.1335, 1498409931672], [1.057, 1498409946673], [1.0243, 1498409961669], [1.0329, 1498409976637], [1.1428, 1498409991563], [1.2198, 1498410006441], [1.2192, 1498410021230], [1.2615, 1498410036027], [1.1765, 1498410051907], [1.2352, 1498410066109], [1.0557, 1498410081043]],
|
||||
[[10.7104, 1498409636085], [10.578, 1498409651011], [10.5985, 1498409666628], [10.6877, 1498409681525], [10.5495, 1498409696586], [10.5981, 1498409711009], [10.5076, 1498409726949], [11.4807, 1498409741853], [11.6165, 1498409756165], [11.8575, 1498409771018], [11.9936, 1498409786056], [10.7566, 1498409801942], [10.7484, 1498409816010], [10.6038, 1498409831018], [10.2932, 1498409846010], [10.4912, 1498409861946], [10.4151, 1498409876871], [10.2401, 1498409891710], [10.4921, 1498409906143], [10.4413, 1498409921477], [10.6318, 1498409936147], [10.5277, 1498409951915], [10.6333, 1498409966052], [10.6417, 1498409981944], [10.4505, 1498409996867], [10.5812, 1498410011770], [10.4934, 1498410026573], [10.5731, 1498410041317], [10.5, 1498410056213], [10.6505, 1498410071013], [9.4035, 1498410086387]]
|
||||
];
|
||||
|
||||
let growing_series = [[10755200, 1498332216642], [10761200, 1498332276802], [10767200, 1498332336367], [10773200, 1498332396584], [10779200, 1498332456880], [10785200, 1498332516479], [10791200, 1498332576610], [10797200, 1498332636353], [10803200, 1498332696513], [10809200, 1498332756884], [10815200, 1498332816890], [10821200, 1498332876305], [10827200, 1498332936384], [10833200, 1498332996659], [10839200, 1498333056965], [10845200, 1498333116748], [10851200, 1498333176687], [10857200, 1498333236646], [10863200, 1498333297034], [10869200, 1498333356358], [10875200, 1498333416445], [4800, 1498333536686], [17900, 1498333667962], [24000, 1498333729157], [29500, 1498333783662], [34800, 1498333836813], [40700, 1498333896403], [46800, 1498333956953], [52800, 1498334016976], [6000, 1498334136593], [12000, 1498334196567]];
|
||||
|
||||
module.exports = [
|
||||
{
|
||||
name: 'groupBy',
|
||||
tests: {
|
||||
'groupBy(AVERAGE)': () => {
|
||||
ts.groupBy(datapoints, '5m', ts.AVERAGE);
|
||||
},
|
||||
'groupBy(MAX)': () => {
|
||||
ts.groupBy(datapoints, '5m', ts.COUNT);
|
||||
}
|
||||
}
|
||||
},
|
||||
{
|
||||
name: 'sumSeries',
|
||||
tests: {
|
||||
'sumSeries()': () => {
|
||||
ts.sumSeries(series_set);
|
||||
},
|
||||
'groupBy(MAX)->sumSeries()': () => {
|
||||
let prepeared_series = _.map(series_set, datapoints => ts.groupBy(datapoints, '5m', ts.MAX));
|
||||
ts.sumSeries(prepeared_series);
|
||||
}
|
||||
}
|
||||
},
|
||||
{
|
||||
name: 'delta vs rate',
|
||||
tests: {
|
||||
'delta()': () => {
|
||||
ts.delta(growing_series);
|
||||
},
|
||||
'rate()': () => {
|
||||
ts.rate(growing_series);
|
||||
}
|
||||
}
|
||||
},
|
||||
{
|
||||
name: 'scale',
|
||||
tests: {
|
||||
'scale()': () => {
|
||||
ts.scale(datapoints, 42);
|
||||
},
|
||||
'scale_perf()': () => {
|
||||
ts.scale_perf(datapoints, 42);
|
||||
}
|
||||
}
|
||||
},
|
||||
{
|
||||
name: 'groupBy vs groupBy_perf',
|
||||
tests: {
|
||||
'groupBy()': () => {
|
||||
ts.groupBy(datapoints, '5m', ts.AVERAGE);
|
||||
},
|
||||
'groupBy_perf()': () => {
|
||||
ts.groupBy_perf(datapoints, '5m', ts.AVERAGE);
|
||||
}
|
||||
}
|
||||
}
|
||||
];
|
||||
import _ from 'lodash';
|
||||
import ts from '../timeseries';
|
||||
|
||||
let datapoints = [[10.7104, 1498409636085], [10.578, 1498409651011], [10.5985, 1498409666628], [10.6877, 1498409681525], [10.5495, 1498409696586], [10.5981, 1498409711009], [10.5076, 1498409726949], [11.4807, 1498409741853], [11.6165, 1498409756165], [11.8575, 1498409771018], [11.9936, 1498409786056], [10.7566, 1498409801942], [10.7484, 1498409816010], [10.6038, 1498409831018], [10.2932, 1498409846010], [10.4912, 1498409861946], [10.4151, 1498409876871], [10.2401, 1498409891710], [10.4921, 1498409906143], [10.4413, 1498409921477], [10.6318, 1498409936147], [10.5277, 1498409951915], [10.6333, 1498409966052], [10.6417, 1498409981944], [10.4505, 1498409996867], [10.5812, 1498410011770], [10.4934, 1498410026573], [10.5731, 1498410041317], [10.5, 1498410056213], [10.6505, 1498410071013], [9.4035, 1498410086387]];
|
||||
|
||||
let series_set = [
|
||||
[[1.0247, 1498409631773], [0.9988, 1498409646697], [0.9817, 1498409661239], [0.9569, 1498409676045], [1.0331, 1498409691922], [1.0755, 1498409706546], [1.1862, 1498409721525], [1.2984, 1498409736175], [1.2389, 1498409751817], [1.1452, 1498409766783], [1.102, 1498409781699], [0.9647, 1498409796664], [1.0063, 1498409811627], [1.0318, 1498409826887], [1.065, 1498409841645], [1.0907, 1498409856647], [1.0229, 1498409871521], [1.0654, 1498409886031], [1.0568, 1498409901544], [1.0818, 1498409916194], [1.1335, 1498409931672], [1.057, 1498409946673], [1.0243, 1498409961669], [1.0329, 1498409976637], [1.1428, 1498409991563], [1.2198, 1498410006441], [1.2192, 1498410021230], [1.2615, 1498410036027], [1.1765, 1498410051907], [1.2352, 1498410066109], [1.0557, 1498410081043]],
|
||||
[[10.7104, 1498409636085], [10.578, 1498409651011], [10.5985, 1498409666628], [10.6877, 1498409681525], [10.5495, 1498409696586], [10.5981, 1498409711009], [10.5076, 1498409726949], [11.4807, 1498409741853], [11.6165, 1498409756165], [11.8575, 1498409771018], [11.9936, 1498409786056], [10.7566, 1498409801942], [10.7484, 1498409816010], [10.6038, 1498409831018], [10.2932, 1498409846010], [10.4912, 1498409861946], [10.4151, 1498409876871], [10.2401, 1498409891710], [10.4921, 1498409906143], [10.4413, 1498409921477], [10.6318, 1498409936147], [10.5277, 1498409951915], [10.6333, 1498409966052], [10.6417, 1498409981944], [10.4505, 1498409996867], [10.5812, 1498410011770], [10.4934, 1498410026573], [10.5731, 1498410041317], [10.5, 1498410056213], [10.6505, 1498410071013], [9.4035, 1498410086387]]
|
||||
];
|
||||
|
||||
let growing_series = [[10755200, 1498332216642], [10761200, 1498332276802], [10767200, 1498332336367], [10773200, 1498332396584], [10779200, 1498332456880], [10785200, 1498332516479], [10791200, 1498332576610], [10797200, 1498332636353], [10803200, 1498332696513], [10809200, 1498332756884], [10815200, 1498332816890], [10821200, 1498332876305], [10827200, 1498332936384], [10833200, 1498332996659], [10839200, 1498333056965], [10845200, 1498333116748], [10851200, 1498333176687], [10857200, 1498333236646], [10863200, 1498333297034], [10869200, 1498333356358], [10875200, 1498333416445], [4800, 1498333536686], [17900, 1498333667962], [24000, 1498333729157], [29500, 1498333783662], [34800, 1498333836813], [40700, 1498333896403], [46800, 1498333956953], [52800, 1498334016976], [6000, 1498334136593], [12000, 1498334196567]];
|
||||
|
||||
module.exports = [
|
||||
{
|
||||
name: 'groupBy',
|
||||
tests: {
|
||||
'groupBy(AVERAGE)': () => {
|
||||
ts.groupBy(datapoints, '5m', ts.AVERAGE);
|
||||
},
|
||||
'groupBy(MAX)': () => {
|
||||
ts.groupBy(datapoints, '5m', ts.COUNT);
|
||||
}
|
||||
}
|
||||
},
|
||||
{
|
||||
name: 'sumSeries',
|
||||
tests: {
|
||||
'sumSeries()': () => {
|
||||
ts.sumSeries(series_set);
|
||||
},
|
||||
'groupBy(MAX)->sumSeries()': () => {
|
||||
let prepeared_series = _.map(series_set, datapoints => ts.groupBy(datapoints, '5m', ts.MAX));
|
||||
ts.sumSeries(prepeared_series);
|
||||
}
|
||||
}
|
||||
},
|
||||
{
|
||||
name: 'delta vs rate',
|
||||
tests: {
|
||||
'delta()': () => {
|
||||
ts.delta(growing_series);
|
||||
},
|
||||
'rate()': () => {
|
||||
ts.rate(growing_series);
|
||||
}
|
||||
}
|
||||
},
|
||||
{
|
||||
name: 'scale',
|
||||
tests: {
|
||||
'scale()': () => {
|
||||
ts.scale(datapoints, 42);
|
||||
},
|
||||
'scale_perf()': () => {
|
||||
ts.scale_perf(datapoints, 42);
|
||||
}
|
||||
}
|
||||
},
|
||||
{
|
||||
name: 'groupBy vs groupBy_perf',
|
||||
tests: {
|
||||
'groupBy()': () => {
|
||||
ts.groupBy(datapoints, '5m', ts.AVERAGE);
|
||||
},
|
||||
'groupBy_perf()': () => {
|
||||
ts.groupBy_perf(datapoints, '5m', ts.AVERAGE);
|
||||
}
|
||||
}
|
||||
}
|
||||
];
|
||||
|
||||
@@ -1 +1 @@
|
||||
{"version":3,"sources":["../../src/datasource-zabbix/config.controller.js"],"names":["_","SUPPORTED_SQL_DS","defaultConfig","dbConnection","enable","ZabbixDSConfigController","$scope","$injector","datasourceSrv","defaults","current","jsonData","sqlDataSources","getSupportedSQLDataSources","datasources","getAll","filter","includes","ds","type","templateUrl"],"mappings":";;;;;;;;;;;;;;;AAAOA,O;;;;;;;;;;;;;;;;;;;;;AAEDC,sB,GAAmB,CAAC,OAAD,EAAU,UAAV,C;AAEnBC,mB,GAAgB;AACpBC,sBAAc;AACZC,kBAAQ;AADI;AADM,O;;0CAMTC,wB;AACX;AACA,0CAAYC,MAAZ,EAAoBC,SAApB,EAA+BC,aAA/B,EAA8C;AAAA;;AAC5C,eAAKA,aAAL,GAAqBA,aAArB;;AAEAR,YAAES,QAAF,CAAW,KAAKC,OAAL,CAAaC,QAAxB,EAAkCT,aAAlC;AACA,eAAKU,cAAL,GAAsB,KAAKC,0BAAL,EAAtB;AACD;;;;uDAE4B;AAC3B,gBAAIC,cAAc,KAAKN,aAAL,CAAmBO,MAAnB,EAAlB;AACA,mBAAOf,EAAEgB,MAAF,CAASF,WAAT,EAAsB,cAAM;AACjC,qBAAOd,EAAEiB,QAAF,CAAWhB,gBAAX,EAA6BiB,GAAGC,IAAhC,CAAP;AACD,aAFM,CAAP;AAGD;;;;;;;;AAGHd,+BAAyBe,WAAzB,GAAuC,wCAAvC","file":"config.controller.js","sourcesContent":["import _ from 'lodash';\n\nconst SUPPORTED_SQL_DS = ['mysql', 'postgres'];\n\nconst defaultConfig = {\n dbConnection: {\n enable: false,\n }\n};\n\nexport class ZabbixDSConfigController {\n /** @ngInject */\n constructor($scope, $injector, datasourceSrv) {\n this.datasourceSrv = datasourceSrv;\n\n _.defaults(this.current.jsonData, defaultConfig);\n this.sqlDataSources = this.getSupportedSQLDataSources();\n }\n\n getSupportedSQLDataSources() {\n let datasources = this.datasourceSrv.getAll();\n return _.filter(datasources, ds => {\n return _.includes(SUPPORTED_SQL_DS, ds.type);\n });\n }\n}\n\nZabbixDSConfigController.templateUrl = 'datasource-zabbix/partials/config.html';\n"]}
|
||||
{"version":3,"sources":["../../src/datasource-zabbix/config.controller.js"],"names":["_","SUPPORTED_SQL_DS","defaultConfig","dbConnection","enable","ZabbixDSConfigController","$scope","$injector","datasourceSrv","defaults","current","jsonData","sqlDataSources","getSupportedSQLDataSources","datasources","getAll","filter","includes","ds","type","templateUrl"],"mappings":";;;;;;;;;;;;;;;AAAOA,O;;;;;;;;;;;;;;;;;;;;;AAEDC,sB,GAAmB,CAAC,OAAD,EAAU,UAAV,C;AAEnBC,mB,GAAgB;AACpBC,sBAAc;AACZC,kBAAQ;AADI;AADM,O;;0CAMTC,wB;AACX;AACA,0CAAYC,MAAZ,EAAoBC,SAApB,EAA+BC,aAA/B,EAA8C;AAAA;;AAC5C,eAAKA,aAAL,GAAqBA,aAArB;;AAEAR,YAAES,QAAF,CAAW,KAAKC,OAAL,CAAaC,QAAxB,EAAkCT,aAAlC;AACA,eAAKU,cAAL,GAAsB,KAAKC,0BAAL,EAAtB;AACD;;;;uDAE4B;AAC3B,gBAAIC,cAAc,KAAKN,aAAL,CAAmBO,MAAnB,EAAlB;AACA,mBAAOf,EAAEgB,MAAF,CAASF,WAAT,EAAsB,cAAM;AACjC,qBAAOd,EAAEiB,QAAF,CAAWhB,gBAAX,EAA6BiB,GAAGC,IAAhC,CAAP;AACD,aAFM,CAAP;AAGD;;;;;;;;AAGHd,+BAAyBe,WAAzB,GAAuC,wCAAvC","file":"config.controller.js","sourcesContent":["import _ from 'lodash';\r\n\r\nconst SUPPORTED_SQL_DS = ['mysql', 'postgres'];\r\n\r\nconst defaultConfig = {\r\n dbConnection: {\r\n enable: false,\r\n }\r\n};\r\n\r\nexport class ZabbixDSConfigController {\r\n /** @ngInject */\r\n constructor($scope, $injector, datasourceSrv) {\r\n this.datasourceSrv = datasourceSrv;\r\n\r\n _.defaults(this.current.jsonData, defaultConfig);\r\n this.sqlDataSources = this.getSupportedSQLDataSources();\r\n }\r\n\r\n getSupportedSQLDataSources() {\r\n let datasources = this.datasourceSrv.getAll();\r\n return _.filter(datasources, ds => {\r\n return _.includes(SUPPORTED_SQL_DS, ds.type);\r\n });\r\n }\r\n}\r\n\r\nZabbixDSConfigController.templateUrl = 'datasource-zabbix/partials/config.html';\r\n"]}
|
||||
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","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"]}
|
||||
{"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\r\nexport const MODE_METRICS = 0;\r\nexport const MODE_ITSERVICE = 1;\r\nexport const MODE_TEXT = 2;\r\nexport const MODE_ITEMID = 3;\r\nexport const MODE_TRIGGERS = 4;\r\n\r\n// Triggers severity\r\nexport const SEV_NOT_CLASSIFIED = 0;\r\nexport const SEV_INFORMATION = 1;\r\nexport const SEV_WARNING = 2;\r\nexport const SEV_AVERAGE = 3;\r\nexport const SEV_HIGH = 4;\r\nexport const SEV_DISASTER = 5;\r\n\r\nexport const SHOW_ALL_TRIGGERS = [0, 1];\r\nexport const SHOW_ALL_EVENTS = [0, 1];\r\nexport const SHOW_OK_EVENTS = 1;\r\n\r\n// Data point\r\nexport const DATAPOINT_VALUE = 0;\r\nexport const DATAPOINT_TS = 1;\r\n\r\nexport const TRIGGER_SEVERITY = [\r\n {val: 0, text: 'Not classified'},\r\n {val: 1, text: 'Information'},\r\n {val: 2, text: 'Warning'},\r\n {val: 3, text: 'Average'},\r\n {val: 4, text: 'High'},\r\n {val: 5, text: 'Disaster'}\r\n];\r\n"]}
|
||||
21
dist/datasource-zabbix/dataProcessor.js
vendored
21
dist/datasource-zabbix/dataProcessor.js
vendored
@@ -21,6 +21,24 @@ System.register(['lodash', './utils', './timeseries'], function (_export, _conte
|
||||
}
|
||||
}
|
||||
|
||||
function removeAboveValue(n, datapoints) {
|
||||
return _.map(datapoints, function (point) {
|
||||
return [point[0] > n ? null : point[0], point[1]];
|
||||
});
|
||||
}
|
||||
|
||||
function removeBelowValue(n, datapoints) {
|
||||
return _.map(datapoints, function (point) {
|
||||
return [point[0] < n ? null : point[0], point[1]];
|
||||
});
|
||||
}
|
||||
|
||||
function transformNull(n, datapoints) {
|
||||
return _.map(datapoints, function (point) {
|
||||
return [point[0] !== null ? point[0] : n, point[1]];
|
||||
});
|
||||
}
|
||||
|
||||
function sortSeries(direction, timeseries) {
|
||||
return _.orderBy(timeseries, [function (ts) {
|
||||
return ts.target.toLowerCase();
|
||||
@@ -142,6 +160,7 @@ System.register(['lodash', './utils', './timeseries'], function (_export, _conte
|
||||
rate: rate,
|
||||
movingAverage: simpleMovingAverage,
|
||||
exponentialMovingAverage: expMovingAverage,
|
||||
transformNull: transformNull,
|
||||
aggregateBy: aggregateByWrapper,
|
||||
// Predefined aggs
|
||||
percentil: percentil,
|
||||
@@ -152,6 +171,8 @@ System.register(['lodash', './utils', './timeseries'], function (_export, _conte
|
||||
sum: _.partial(aggregateWrapper, SUM),
|
||||
count: _.partial(aggregateWrapper, COUNT),
|
||||
sumSeries: sumSeries,
|
||||
removeAboveValue: removeAboveValue,
|
||||
removeBelowValue: removeBelowValue,
|
||||
top: _.partial(limit, 'top'),
|
||||
bottom: _.partial(limit, 'bottom'),
|
||||
sortSeries: sortSeries,
|
||||
|
||||
2
dist/datasource-zabbix/dataProcessor.js.map
vendored
2
dist/datasource-zabbix/dataProcessor.js.map
vendored
File diff suppressed because one or more lines are too long
40
dist/datasource-zabbix/datasource.js
vendored
40
dist/datasource-zabbix/datasource.js
vendored
@@ -52,15 +52,15 @@ System.register(['lodash', 'app/core/utils/datemath', './utils', './migrations',
|
||||
};
|
||||
}
|
||||
|
||||
/**
|
||||
* Custom formatter for template variables.
|
||||
* Default Grafana "regex" formatter returns
|
||||
* value1|value2
|
||||
* This formatter returns
|
||||
* (value1|value2)
|
||||
* This format needed for using in complex regex with
|
||||
* template variables, for example
|
||||
* /CPU $cpu_item.*time/ where $cpu_item is system,user,iowait
|
||||
/**
|
||||
* Custom formatter for template variables.
|
||||
* Default Grafana "regex" formatter returns
|
||||
* value1|value2
|
||||
* This formatter returns
|
||||
* (value1|value2)
|
||||
* This format needed for using in complex regex with
|
||||
* template variables, for example
|
||||
* /CPU $cpu_item.*time/ where $cpu_item is system,user,iowait
|
||||
*/
|
||||
function zabbixTemplateFormat(value) {
|
||||
if (typeof value === 'string') {
|
||||
@@ -78,13 +78,13 @@ System.register(['lodash', 'app/core/utils/datemath', './utils', './migrations',
|
||||
return value.join(',');
|
||||
}
|
||||
|
||||
/**
|
||||
* If template variables are used in request, replace it using regex format
|
||||
* and wrap with '/' for proper multi-value work. Example:
|
||||
* $variable selected as a, b, c
|
||||
* We use filter $variable
|
||||
* $variable -> a|b|c -> /a|b|c/
|
||||
* /$variable/ -> /a|b|c/ -> /a|b|c/
|
||||
/**
|
||||
* If template variables are used in request, replace it using regex format
|
||||
* and wrap with '/' for proper multi-value work. Example:
|
||||
* $variable selected as a, b, c
|
||||
* We use filter $variable
|
||||
* $variable -> a|b|c -> /a|b|c/
|
||||
* /$variable/ -> /a|b|c/ -> /a|b|c/
|
||||
*/
|
||||
function replaceTemplateVars(templateSrv, target, scopedVars) {
|
||||
var replacedTarget = templateSrv.replace(target, scopedVars, zabbixTemplateFormat);
|
||||
@@ -265,10 +265,10 @@ System.register(['lodash', 'app/core/utils/datemath', './utils', './migrations',
|
||||
// Datasource methods //
|
||||
////////////////////////
|
||||
|
||||
/**
|
||||
* Query panel data. Calls for each panel in dashboard.
|
||||
* @param {Object} options Contains time range, targets and other info.
|
||||
* @return {Object} Grafana metrics object with timeseries data for each target.
|
||||
/**
|
||||
* Query panel data. Calls for each panel in dashboard.
|
||||
* @param {Object} options Contains time range, targets and other info.
|
||||
* @return {Object} Grafana metrics object with timeseries data for each target.
|
||||
*/
|
||||
|
||||
|
||||
|
||||
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
212
dist/datasource-zabbix/img/zabbix_app_logo.svg
vendored
212
dist/datasource-zabbix/img/zabbix_app_logo.svg
vendored
@@ -1,107 +1,107 @@
|
||||
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
|
||||
<!-- Generator: Adobe Illustrator 19.1.0, SVG Export Plug-In . SVG Version: 6.00 Build 0) -->
|
||||
|
||||
<svg
|
||||
xmlns:dc="http://purl.org/dc/elements/1.1/"
|
||||
xmlns:cc="http://creativecommons.org/ns#"
|
||||
xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
|
||||
xmlns:svg="http://www.w3.org/2000/svg"
|
||||
xmlns="http://www.w3.org/2000/svg"
|
||||
xmlns:sodipodi="http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd"
|
||||
xmlns:inkscape="http://www.inkscape.org/namespaces/inkscape"
|
||||
version="1.0"
|
||||
id="Layer_1"
|
||||
x="0px"
|
||||
y="0px"
|
||||
width="100px"
|
||||
height="100px"
|
||||
viewBox="692 0 100 100"
|
||||
style="enable-background:new 692 0 100 100;"
|
||||
xml:space="preserve"
|
||||
inkscape:version="0.91 r"
|
||||
sodipodi:docname="zabbix_app_logo.svg"
|
||||
enable-background="new"><metadata
|
||||
id="metadata13"><rdf:RDF><cc:Work
|
||||
rdf:about=""><dc:format>image/svg+xml</dc:format><dc:type
|
||||
rdf:resource="http://purl.org/dc/dcmitype/StillImage" /><dc:title></dc:title></cc:Work></rdf:RDF></metadata><defs
|
||||
id="defs11"><linearGradient
|
||||
id="SVGID_1_"
|
||||
gradientUnits="userSpaceOnUse"
|
||||
x1="2.6005001"
|
||||
y1="65.475197"
|
||||
x2="94.377701"
|
||||
y2="30.245199"><stop
|
||||
id="stop34"
|
||||
style="stop-color:#58595B"
|
||||
offset="0.2583" /><stop
|
||||
id="stop32"
|
||||
style="stop-color:#646C70"
|
||||
offset="0.2917" /><stop
|
||||
id="stop30"
|
||||
style="stop-color:#6C8087"
|
||||
offset="0.3398" /><stop
|
||||
id="stop28"
|
||||
style="stop-color:#6D8F9B"
|
||||
offset="0.3927" /><stop
|
||||
id="stop26"
|
||||
style="stop-color:#689BAA"
|
||||
offset="0.4499" /><stop
|
||||
id="stop24"
|
||||
style="stop-color:#5FA3B5"
|
||||
offset="0.5128" /><stop
|
||||
id="stop22"
|
||||
style="stop-color:#53A8BD"
|
||||
offset="0.5837" /><stop
|
||||
id="stop20"
|
||||
style="stop-color:#47ABC2"
|
||||
offset="0.6674" /><stop
|
||||
id="stop18"
|
||||
style="stop-color:#3FAEC5"
|
||||
offset="0.7759" /><stop
|
||||
id="stop16"
|
||||
style="stop-color:#3CAFC7"
|
||||
offset="1" /><stop
|
||||
id="stop14"
|
||||
style="stop-color:#3BB0C9"
|
||||
offset="1" /></linearGradient></defs><sodipodi:namedview
|
||||
pagecolor="#ffffff"
|
||||
bordercolor="#666666"
|
||||
borderopacity="1"
|
||||
objecttolerance="10"
|
||||
gridtolerance="10"
|
||||
guidetolerance="10"
|
||||
inkscape:pageopacity="0"
|
||||
inkscape:pageshadow="2"
|
||||
inkscape:window-width="1615"
|
||||
inkscape:window-height="1026"
|
||||
id="namedview9"
|
||||
showgrid="false"
|
||||
inkscape:zoom="4.285"
|
||||
inkscape:cx="50.424685"
|
||||
inkscape:cy="23.581186"
|
||||
inkscape:window-x="65"
|
||||
inkscape:window-y="24"
|
||||
inkscape:window-maximized="1"
|
||||
inkscape:current-layer="g5194" /><style
|
||||
type="text/css"
|
||||
id="style3">
|
||||
.st0{fill:#787878;}
|
||||
</style><g
|
||||
inkscape:groupmode="layer"
|
||||
id="g5194"
|
||||
inkscape:label="Zabbix BG Original"
|
||||
style="display:inline"><rect
|
||||
style="fill:#d40000;fill-opacity:1"
|
||||
id="rect5196"
|
||||
width="100"
|
||||
height="100"
|
||||
x="692"
|
||||
y="0" /></g><g
|
||||
inkscape:groupmode="layer"
|
||||
id="layer6"
|
||||
inkscape:label="Zabbix Original Z"
|
||||
style="display:inline"><path
|
||||
d="m 715.54426,16.689227 52.91147,0 0,6.87033 -42.58255,52.167008 43.62047,0 0,7.584207 -54.9873,0 0,-6.871516 42.58255,-52.166552 -41.54464,0 0,-7.583477 z"
|
||||
style="display:inline;fill:#ffffff;fill-opacity:1;fill-rule:nonzero;stroke:none"
|
||||
id="path4169-6"
|
||||
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
|
||||
<!-- Generator: Adobe Illustrator 19.1.0, SVG Export Plug-In . SVG Version: 6.00 Build 0) -->
|
||||
|
||||
<svg
|
||||
xmlns:dc="http://purl.org/dc/elements/1.1/"
|
||||
xmlns:cc="http://creativecommons.org/ns#"
|
||||
xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
|
||||
xmlns:svg="http://www.w3.org/2000/svg"
|
||||
xmlns="http://www.w3.org/2000/svg"
|
||||
xmlns:sodipodi="http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd"
|
||||
xmlns:inkscape="http://www.inkscape.org/namespaces/inkscape"
|
||||
version="1.0"
|
||||
id="Layer_1"
|
||||
x="0px"
|
||||
y="0px"
|
||||
width="100px"
|
||||
height="100px"
|
||||
viewBox="692 0 100 100"
|
||||
style="enable-background:new 692 0 100 100;"
|
||||
xml:space="preserve"
|
||||
inkscape:version="0.91 r"
|
||||
sodipodi:docname="zabbix_app_logo.svg"
|
||||
enable-background="new"><metadata
|
||||
id="metadata13"><rdf:RDF><cc:Work
|
||||
rdf:about=""><dc:format>image/svg+xml</dc:format><dc:type
|
||||
rdf:resource="http://purl.org/dc/dcmitype/StillImage" /><dc:title></dc:title></cc:Work></rdf:RDF></metadata><defs
|
||||
id="defs11"><linearGradient
|
||||
id="SVGID_1_"
|
||||
gradientUnits="userSpaceOnUse"
|
||||
x1="2.6005001"
|
||||
y1="65.475197"
|
||||
x2="94.377701"
|
||||
y2="30.245199"><stop
|
||||
id="stop34"
|
||||
style="stop-color:#58595B"
|
||||
offset="0.2583" /><stop
|
||||
id="stop32"
|
||||
style="stop-color:#646C70"
|
||||
offset="0.2917" /><stop
|
||||
id="stop30"
|
||||
style="stop-color:#6C8087"
|
||||
offset="0.3398" /><stop
|
||||
id="stop28"
|
||||
style="stop-color:#6D8F9B"
|
||||
offset="0.3927" /><stop
|
||||
id="stop26"
|
||||
style="stop-color:#689BAA"
|
||||
offset="0.4499" /><stop
|
||||
id="stop24"
|
||||
style="stop-color:#5FA3B5"
|
||||
offset="0.5128" /><stop
|
||||
id="stop22"
|
||||
style="stop-color:#53A8BD"
|
||||
offset="0.5837" /><stop
|
||||
id="stop20"
|
||||
style="stop-color:#47ABC2"
|
||||
offset="0.6674" /><stop
|
||||
id="stop18"
|
||||
style="stop-color:#3FAEC5"
|
||||
offset="0.7759" /><stop
|
||||
id="stop16"
|
||||
style="stop-color:#3CAFC7"
|
||||
offset="1" /><stop
|
||||
id="stop14"
|
||||
style="stop-color:#3BB0C9"
|
||||
offset="1" /></linearGradient></defs><sodipodi:namedview
|
||||
pagecolor="#ffffff"
|
||||
bordercolor="#666666"
|
||||
borderopacity="1"
|
||||
objecttolerance="10"
|
||||
gridtolerance="10"
|
||||
guidetolerance="10"
|
||||
inkscape:pageopacity="0"
|
||||
inkscape:pageshadow="2"
|
||||
inkscape:window-width="1615"
|
||||
inkscape:window-height="1026"
|
||||
id="namedview9"
|
||||
showgrid="false"
|
||||
inkscape:zoom="4.285"
|
||||
inkscape:cx="50.424685"
|
||||
inkscape:cy="23.581186"
|
||||
inkscape:window-x="65"
|
||||
inkscape:window-y="24"
|
||||
inkscape:window-maximized="1"
|
||||
inkscape:current-layer="g5194" /><style
|
||||
type="text/css"
|
||||
id="style3">
|
||||
.st0{fill:#787878;}
|
||||
</style><g
|
||||
inkscape:groupmode="layer"
|
||||
id="g5194"
|
||||
inkscape:label="Zabbix BG Original"
|
||||
style="display:inline"><rect
|
||||
style="fill:#d40000;fill-opacity:1"
|
||||
id="rect5196"
|
||||
width="100"
|
||||
height="100"
|
||||
x="692"
|
||||
y="0" /></g><g
|
||||
inkscape:groupmode="layer"
|
||||
id="layer6"
|
||||
inkscape:label="Zabbix Original Z"
|
||||
style="display:inline"><path
|
||||
d="m 715.54426,16.689227 52.91147,0 0,6.87033 -42.58255,52.167008 43.62047,0 0,7.584207 -54.9873,0 0,-6.871516 42.58255,-52.166552 -41.54464,0 0,-7.583477 z"
|
||||
style="display:inline;fill:#ffffff;fill-opacity:1;fill-rule:nonzero;stroke:none"
|
||||
id="path4169-6"
|
||||
inkscape:connector-curvature="0" /></g></svg>
|
||||
|
Before Width: | Height: | Size: 3.5 KiB After Width: | Height: | Size: 3.6 KiB |
File diff suppressed because one or more lines are too long
21
dist/datasource-zabbix/metricFunctions.js
vendored
21
dist/datasource-zabbix/metricFunctions.js
vendored
@@ -125,6 +125,13 @@ System.register(['lodash', 'jquery'], function (_export, _context) {
|
||||
defaultParams: [0.2]
|
||||
});
|
||||
|
||||
addFuncDef({
|
||||
name: 'transformNull',
|
||||
category: 'Transform',
|
||||
params: [{ name: 'number', type: 'float' }],
|
||||
defaultParams: [0]
|
||||
});
|
||||
|
||||
// Aggregate
|
||||
|
||||
addFuncDef({
|
||||
@@ -192,6 +199,20 @@ System.register(['lodash', 'jquery'], function (_export, _context) {
|
||||
|
||||
// Filter
|
||||
|
||||
addFuncDef({
|
||||
name: 'removeAboveValue',
|
||||
category: 'Filter',
|
||||
params: [{ name: 'number', type: 'float' }],
|
||||
defaultParams: [0]
|
||||
});
|
||||
|
||||
addFuncDef({
|
||||
name: 'removeBelowValue',
|
||||
category: 'Filter',
|
||||
params: [{ name: 'number', type: 'float' }],
|
||||
defaultParams: [0]
|
||||
});
|
||||
|
||||
addFuncDef({
|
||||
name: 'top',
|
||||
category: 'Filter',
|
||||
|
||||
File diff suppressed because one or more lines are too long
6
dist/datasource-zabbix/migrations.js
vendored
6
dist/datasource-zabbix/migrations.js
vendored
@@ -3,9 +3,9 @@
|
||||
System.register([], function (_export, _context) {
|
||||
"use strict";
|
||||
|
||||
/**
|
||||
* Query format migration.
|
||||
* This module can detect query format version and make migration.
|
||||
/**
|
||||
* Query format migration.
|
||||
* This module can detect query format version and make migration.
|
||||
*/
|
||||
|
||||
function isGrafana2target(target) {
|
||||
|
||||
2
dist/datasource-zabbix/migrations.js.map
vendored
2
dist/datasource-zabbix/migrations.js.map
vendored
@@ -1 +1 @@
|
||||
{"version":3,"sources":["../../src/datasource-zabbix/migrations.js"],"names":["isGrafana2target","target","mode","hostFilter","itemFilter","downsampleFunction","host","item","filter","undefined","migrateFrom2To3version","group","name","convertToRegex","application","migrate","resultFormat","str"],"mappings":";;;;;AAAA;;;;;AAKO,WAASA,gBAAT,CAA0BC,MAA1B,EAAkC;AACvC,QAAI,CAACA,OAAOC,IAAR,IAAgBD,OAAOC,IAAP,KAAgB,CAAhC,IAAqCD,OAAOC,IAAP,KAAgB,CAAzD,EAA4D;AAC1D,UAAI,CAACD,OAAOE,UAAP,IAAqBF,OAAOG,UAA5B,IAA0CH,OAAOI,kBAAjD,IACAJ,OAAOK,IAAP,IAAeL,OAAOK,IAAP,CAAYA,IAD5B,KAECL,OAAOM,IAAP,CAAYC,MAAZ,KAAuBC,SAAvB,IAAoCR,OAAOK,IAAP,CAAYE,MAAZ,KAAuBC,SAFhE,EAE4E;AAC1E,eAAO,IAAP;AACD,OAJD,MAIO;AACL,eAAO,KAAP;AACD;AACF,KARD,MAQO;AACL,aAAO,KAAP;AACD;AACF;;8BAZeT,gB;;AAcT,WAASU,sBAAT,CAAgCT,MAAhC,EAAwC;AAC7CA,WAAOU,KAAP,CAAaH,MAAb,GAAsBP,OAAOU,KAAP,CAAaC,IAAb,KAAsB,GAAtB,GAA4B,MAA5B,GAAqCX,OAAOU,KAAP,CAAaC,IAAxE;AACAX,WAAOK,IAAP,CAAYE,MAAZ,GAAqBP,OAAOK,IAAP,CAAYM,IAAZ,KAAqB,GAArB,GAA2BC,eAAeZ,OAAOE,UAAtB,CAA3B,GAA+DF,OAAOK,IAAP,CAAYM,IAAhG;AACAX,WAAOa,WAAP,CAAmBN,MAAnB,GAA4BP,OAAOa,WAAP,CAAmBF,IAAnB,KAA4B,GAA5B,GAAkC,EAAlC,GAAuCX,OAAOa,WAAP,CAAmBF,IAAtF;AACAX,WAAOM,IAAP,CAAYC,MAAZ,GAAqBP,OAAOM,IAAP,CAAYK,IAAZ,KAAqB,KAArB,GAA6BC,eAAeZ,OAAOG,UAAtB,CAA7B,GAAiEH,OAAOM,IAAP,CAAYK,IAAlG;AACA,WAAOX,MAAP;AACD;oCANeS,sB;;AAQT,WAASK,OAAT,CAAiBd,MAAjB,EAAyB;AAC9BA,WAAOe,YAAP,GAAsBf,OAAOe,YAAP,IAAuB,aAA7C;AACA,QAAIhB,iBAAiBC,MAAjB,CAAJ,EAA8B;AAC5B,aAAOS,uBAAuBT,MAAvB,CAAP;AACD,KAFD,MAEO;AACL,aAAOA,MAAP;AACD;AACF;;qBAPec,O;;AAShB,WAASF,cAAT,CAAwBI,GAAxB,EAA6B;AAC3B,QAAIA,GAAJ,EAAS;AACP,aAAO,MAAMA,GAAN,GAAY,GAAnB;AACD,KAFD,MAEO;AACL,aAAO,MAAP;AACD;AACF,G","file":"migrations.js","sourcesContent":["/**\n * Query format migration.\n * This module can detect query format version and make migration.\n */\n\nexport function isGrafana2target(target) {\n if (!target.mode || target.mode === 0 || target.mode === 2) {\n if ((target.hostFilter || target.itemFilter || target.downsampleFunction ||\n (target.host && target.host.host)) &&\n (target.item.filter === undefined && target.host.filter === undefined)) {\n return true;\n } else {\n return false;\n }\n } else {\n return false;\n }\n}\n\nexport function migrateFrom2To3version(target) {\n target.group.filter = target.group.name === \"*\" ? \"/.*/\" : target.group.name;\n target.host.filter = target.host.name === \"*\" ? convertToRegex(target.hostFilter) : target.host.name;\n target.application.filter = target.application.name === \"*\" ? \"\" : target.application.name;\n target.item.filter = target.item.name === \"All\" ? convertToRegex(target.itemFilter) : target.item.name;\n return target;\n}\n\nexport function migrate(target) {\n target.resultFormat = target.resultFormat || 'time_series';\n if (isGrafana2target(target)) {\n return migrateFrom2To3version(target);\n } else {\n return target;\n }\n}\n\nfunction convertToRegex(str) {\n if (str) {\n return '/' + str + '/';\n } else {\n return '/.*/';\n }\n}\n"]}
|
||||
{"version":3,"sources":["../../src/datasource-zabbix/migrations.js"],"names":["isGrafana2target","target","mode","hostFilter","itemFilter","downsampleFunction","host","item","filter","undefined","migrateFrom2To3version","group","name","convertToRegex","application","migrate","resultFormat","str"],"mappings":";;;;;AAAA;;;;;AAKO,WAASA,gBAAT,CAA0BC,MAA1B,EAAkC;AACvC,QAAI,CAACA,OAAOC,IAAR,IAAgBD,OAAOC,IAAP,KAAgB,CAAhC,IAAqCD,OAAOC,IAAP,KAAgB,CAAzD,EAA4D;AAC1D,UAAI,CAACD,OAAOE,UAAP,IAAqBF,OAAOG,UAA5B,IAA0CH,OAAOI,kBAAjD,IACAJ,OAAOK,IAAP,IAAeL,OAAOK,IAAP,CAAYA,IAD5B,KAECL,OAAOM,IAAP,CAAYC,MAAZ,KAAuBC,SAAvB,IAAoCR,OAAOK,IAAP,CAAYE,MAAZ,KAAuBC,SAFhE,EAE4E;AAC1E,eAAO,IAAP;AACD,OAJD,MAIO;AACL,eAAO,KAAP;AACD;AACF,KARD,MAQO;AACL,aAAO,KAAP;AACD;AACF;;8BAZeT,gB;;AAcT,WAASU,sBAAT,CAAgCT,MAAhC,EAAwC;AAC7CA,WAAOU,KAAP,CAAaH,MAAb,GAAsBP,OAAOU,KAAP,CAAaC,IAAb,KAAsB,GAAtB,GAA4B,MAA5B,GAAqCX,OAAOU,KAAP,CAAaC,IAAxE;AACAX,WAAOK,IAAP,CAAYE,MAAZ,GAAqBP,OAAOK,IAAP,CAAYM,IAAZ,KAAqB,GAArB,GAA2BC,eAAeZ,OAAOE,UAAtB,CAA3B,GAA+DF,OAAOK,IAAP,CAAYM,IAAhG;AACAX,WAAOa,WAAP,CAAmBN,MAAnB,GAA4BP,OAAOa,WAAP,CAAmBF,IAAnB,KAA4B,GAA5B,GAAkC,EAAlC,GAAuCX,OAAOa,WAAP,CAAmBF,IAAtF;AACAX,WAAOM,IAAP,CAAYC,MAAZ,GAAqBP,OAAOM,IAAP,CAAYK,IAAZ,KAAqB,KAArB,GAA6BC,eAAeZ,OAAOG,UAAtB,CAA7B,GAAiEH,OAAOM,IAAP,CAAYK,IAAlG;AACA,WAAOX,MAAP;AACD;oCANeS,sB;;AAQT,WAASK,OAAT,CAAiBd,MAAjB,EAAyB;AAC9BA,WAAOe,YAAP,GAAsBf,OAAOe,YAAP,IAAuB,aAA7C;AACA,QAAIhB,iBAAiBC,MAAjB,CAAJ,EAA8B;AAC5B,aAAOS,uBAAuBT,MAAvB,CAAP;AACD,KAFD,MAEO;AACL,aAAOA,MAAP;AACD;AACF;;qBAPec,O;;AAShB,WAASF,cAAT,CAAwBI,GAAxB,EAA6B;AAC3B,QAAIA,GAAJ,EAAS;AACP,aAAO,MAAMA,GAAN,GAAY,GAAnB;AACD,KAFD,MAEO;AACL,aAAO,MAAP;AACD;AACF,G","file":"migrations.js","sourcesContent":["/**\r\n * Query format migration.\r\n * This module can detect query format version and make migration.\r\n */\r\n\r\nexport function isGrafana2target(target) {\r\n if (!target.mode || target.mode === 0 || target.mode === 2) {\r\n if ((target.hostFilter || target.itemFilter || target.downsampleFunction ||\r\n (target.host && target.host.host)) &&\r\n (target.item.filter === undefined && target.host.filter === undefined)) {\r\n return true;\r\n } else {\r\n return false;\r\n }\r\n } else {\r\n return false;\r\n }\r\n}\r\n\r\nexport function migrateFrom2To3version(target) {\r\n target.group.filter = target.group.name === \"*\" ? \"/.*/\" : target.group.name;\r\n target.host.filter = target.host.name === \"*\" ? convertToRegex(target.hostFilter) : target.host.name;\r\n target.application.filter = target.application.name === \"*\" ? \"\" : target.application.name;\r\n target.item.filter = target.item.name === \"All\" ? convertToRegex(target.itemFilter) : target.item.name;\r\n return target;\r\n}\r\n\r\nexport function migrate(target) {\r\n target.resultFormat = target.resultFormat || 'time_series';\r\n if (isGrafana2target(target)) {\r\n return migrateFrom2To3version(target);\r\n } else {\r\n return target;\r\n }\r\n}\r\n\r\nfunction convertToRegex(str) {\r\n if (str) {\r\n return '/' + str + '/';\r\n } else {\r\n return '/.*/';\r\n }\r\n}\r\n"]}
|
||||
2
dist/datasource-zabbix/module.js.map
vendored
2
dist/datasource-zabbix/module.js.map
vendored
@@ -1 +1 @@
|
||||
{"version":3,"sources":["../../src/datasource-zabbix/module.js"],"names":["loadPluginCss","ZabbixAPIDatasource","ZabbixQueryController","ZabbixDSConfigController","dark","light","ZabbixQueryOptionsController","templateUrl","ZabbixAnnotationsQueryController"],"mappings":";;;;;;;;;;;;;;;AAAQA,mB,kBAAAA,a;;AACAC,yB,eAAAA,mB;;AACAC,2B,oBAAAA,qB;;AACAC,8B,qBAAAA,wB;;;;AAERH,oBAAc;AACZI,cAAM,gEADM;AAEZC,eAAO;AAFK,OAAd;;kCAKMC,4B;;;;AACNA,mCAA6BC,WAA7B,GAA2C,+CAA3C;;sCAEMC,gC;;;;AACNA,uCAAiCD,WAAjC,GAA+C,oDAA/C;;4BAGEN,mB;;4BACAE,wB;;2BACAD,qB;;kCACAI,4B;;sCACAE,gC","file":"module.js","sourcesContent":["import {loadPluginCss} from 'app/plugins/sdk';\nimport {ZabbixAPIDatasource} from './datasource';\nimport {ZabbixQueryController} from './query.controller';\nimport {ZabbixDSConfigController} from './config.controller';\n\nloadPluginCss({\n dark: 'plugins/alexanderzobnin-zabbix-app/css/grafana-zabbix.dark.css',\n light: 'plugins/alexanderzobnin-zabbix-app/css/grafana-zabbix.light.css'\n});\n\nclass ZabbixQueryOptionsController {}\nZabbixQueryOptionsController.templateUrl = 'datasource-zabbix/partials/query.options.html';\n\nclass ZabbixAnnotationsQueryController {}\nZabbixAnnotationsQueryController.templateUrl = 'datasource-zabbix/partials/annotations.editor.html';\n\nexport {\n ZabbixAPIDatasource as Datasource,\n ZabbixDSConfigController as ConfigCtrl,\n ZabbixQueryController as QueryCtrl,\n ZabbixQueryOptionsController as QueryOptionsCtrl,\n ZabbixAnnotationsQueryController as AnnotationsQueryCtrl\n};\n"]}
|
||||
{"version":3,"sources":["../../src/datasource-zabbix/module.js"],"names":["loadPluginCss","ZabbixAPIDatasource","ZabbixQueryController","ZabbixDSConfigController","dark","light","ZabbixQueryOptionsController","templateUrl","ZabbixAnnotationsQueryController"],"mappings":";;;;;;;;;;;;;;;AAAQA,mB,kBAAAA,a;;AACAC,yB,eAAAA,mB;;AACAC,2B,oBAAAA,qB;;AACAC,8B,qBAAAA,wB;;;;AAERH,oBAAc;AACZI,cAAM,gEADM;AAEZC,eAAO;AAFK,OAAd;;kCAKMC,4B;;;;AACNA,mCAA6BC,WAA7B,GAA2C,+CAA3C;;sCAEMC,gC;;;;AACNA,uCAAiCD,WAAjC,GAA+C,oDAA/C;;4BAGEN,mB;;4BACAE,wB;;2BACAD,qB;;kCACAI,4B;;sCACAE,gC","file":"module.js","sourcesContent":["import {loadPluginCss} from 'app/plugins/sdk';\r\nimport {ZabbixAPIDatasource} from './datasource';\r\nimport {ZabbixQueryController} from './query.controller';\r\nimport {ZabbixDSConfigController} from './config.controller';\r\n\r\nloadPluginCss({\r\n dark: 'plugins/alexanderzobnin-zabbix-app/css/grafana-zabbix.dark.css',\r\n light: 'plugins/alexanderzobnin-zabbix-app/css/grafana-zabbix.light.css'\r\n});\r\n\r\nclass ZabbixQueryOptionsController {}\r\nZabbixQueryOptionsController.templateUrl = 'datasource-zabbix/partials/query.options.html';\r\n\r\nclass ZabbixAnnotationsQueryController {}\r\nZabbixAnnotationsQueryController.templateUrl = 'datasource-zabbix/partials/annotations.editor.html';\r\n\r\nexport {\r\n ZabbixAPIDatasource as Datasource,\r\n ZabbixDSConfigController as ConfigCtrl,\r\n ZabbixQueryController as QueryCtrl,\r\n ZabbixQueryOptionsController as QueryOptionsCtrl,\r\n ZabbixAnnotationsQueryController as AnnotationsQueryCtrl\r\n};\r\n"]}
|
||||
@@ -1,65 +1,65 @@
|
||||
<div class="gf-form-group">
|
||||
<h6>Filter Triggers</h6>
|
||||
<div class="gf-form-inline">
|
||||
<div class="gf-form">
|
||||
<span class="gf-form-label width-10">Group</span>
|
||||
<input type="text"
|
||||
class="gf-form-input max-width-16"
|
||||
ng-model="ctrl.annotation.group">
|
||||
</input>
|
||||
</div>
|
||||
|
||||
<div class="gf-form">
|
||||
<span class="gf-form-label width-10">Host</span>
|
||||
<input type="text"
|
||||
class="gf-form-input max-width-16"
|
||||
ng-model="ctrl.annotation.host">
|
||||
</input>
|
||||
</div>
|
||||
</div>
|
||||
<div class="gf-form-inline">
|
||||
<div class="gf-form">
|
||||
<span class="gf-form-label width-10">Application</span>
|
||||
<input type="text"
|
||||
class="gf-form-input max-width-16"
|
||||
ng-model="ctrl.annotation.application">
|
||||
</input>
|
||||
</div>
|
||||
|
||||
<div class="gf-form">
|
||||
<span class="gf-form-label width-10">Trigger</span>
|
||||
<input type="text"
|
||||
class="gf-form-input max-width-16"
|
||||
ng-model="ctrl.annotation.trigger">
|
||||
</input>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="gf-form-group">
|
||||
<div class="gf-form">
|
||||
<span class="gf-form-label width-10">Minimum severity</span>
|
||||
<div class="gf-form-select-wrapper">
|
||||
<select class="gf-form-input gf-size-auto"
|
||||
ng-init='ctrl.annotation.minseverity = ctrl.annotation.minseverity || 0'
|
||||
ng-model='ctrl.annotation.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="gf-form-group">
|
||||
<h6>Options</h6>
|
||||
<div class="gf-form">
|
||||
<editor-checkbox text="Show OK events" model="ctrl.annotation.showOkEvents"></editor-checkbox>
|
||||
<editor-checkbox text="Hide acknowledged events" model="ctrl.annotation.hideAcknowledged"></editor-checkbox>
|
||||
<editor-checkbox text="Show hostname" model="ctrl.annotation.showHostname"></editor-checkbox>
|
||||
</div>
|
||||
</div>
|
||||
<div class="gf-form-group">
|
||||
<h6>Filter Triggers</h6>
|
||||
<div class="gf-form-inline">
|
||||
<div class="gf-form">
|
||||
<span class="gf-form-label width-10">Group</span>
|
||||
<input type="text"
|
||||
class="gf-form-input max-width-16"
|
||||
ng-model="ctrl.annotation.group">
|
||||
</input>
|
||||
</div>
|
||||
|
||||
<div class="gf-form">
|
||||
<span class="gf-form-label width-10">Host</span>
|
||||
<input type="text"
|
||||
class="gf-form-input max-width-16"
|
||||
ng-model="ctrl.annotation.host">
|
||||
</input>
|
||||
</div>
|
||||
</div>
|
||||
<div class="gf-form-inline">
|
||||
<div class="gf-form">
|
||||
<span class="gf-form-label width-10">Application</span>
|
||||
<input type="text"
|
||||
class="gf-form-input max-width-16"
|
||||
ng-model="ctrl.annotation.application">
|
||||
</input>
|
||||
</div>
|
||||
|
||||
<div class="gf-form">
|
||||
<span class="gf-form-label width-10">Trigger</span>
|
||||
<input type="text"
|
||||
class="gf-form-input max-width-16"
|
||||
ng-model="ctrl.annotation.trigger">
|
||||
</input>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="gf-form-group">
|
||||
<div class="gf-form">
|
||||
<span class="gf-form-label width-10">Minimum severity</span>
|
||||
<div class="gf-form-select-wrapper">
|
||||
<select class="gf-form-input gf-size-auto"
|
||||
ng-init='ctrl.annotation.minseverity = ctrl.annotation.minseverity || 0'
|
||||
ng-model='ctrl.annotation.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="gf-form-group">
|
||||
<h6>Options</h6>
|
||||
<div class="gf-form">
|
||||
<editor-checkbox text="Show OK events" model="ctrl.annotation.showOkEvents"></editor-checkbox>
|
||||
<editor-checkbox text="Hide acknowledged events" model="ctrl.annotation.hideAcknowledged"></editor-checkbox>
|
||||
<editor-checkbox text="Show hostname" model="ctrl.annotation.showHostname"></editor-checkbox>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
272
dist/datasource-zabbix/partials/config.html
vendored
272
dist/datasource-zabbix/partials/config.html
vendored
@@ -1,136 +1,136 @@
|
||||
<datasource-http-settings current="ctrl.current">
|
||||
</datasource-http-settings>
|
||||
|
||||
<div class="gf-form-group">
|
||||
<h3 class="page-heading">Zabbix API details</h3>
|
||||
|
||||
<div class="gf-form">
|
||||
<span class="gf-form-label width-7">
|
||||
Username
|
||||
</span>
|
||||
<input class="gf-form-input max-width-21"
|
||||
type="text"
|
||||
ng-model='ctrl.current.jsonData.username'
|
||||
placeholder="user"
|
||||
required>
|
||||
</input>
|
||||
</div>
|
||||
|
||||
<div class="gf-form">
|
||||
<span class="gf-form-label width-7">
|
||||
Password
|
||||
</span>
|
||||
<input class="gf-form-input max-width-21"
|
||||
type="password"
|
||||
ng-model='ctrl.current.jsonData.password'
|
||||
placeholder="password">
|
||||
</input>
|
||||
</div>
|
||||
|
||||
<gf-form-switch class="gf-form" label-class="width-7"
|
||||
label="Trends"
|
||||
checked="ctrl.current.jsonData.trends"
|
||||
switch-class="max-width-5">
|
||||
</gf-form-switch>
|
||||
<div class="gf-form-inline">
|
||||
<div class="gf-form" ng-if="ctrl.current.jsonData.trends">
|
||||
<span class="gf-form-label width-7">
|
||||
After
|
||||
<info-popover mode="right-normal">
|
||||
Time after which trends will be used.
|
||||
Best practice is to set this value to your history storage period (7d, 30d, etc).
|
||||
</info-popover>
|
||||
</span>
|
||||
<input class="gf-form-input max-width-5"
|
||||
type="text"
|
||||
ng-model='ctrl.current.jsonData.trendsFrom'
|
||||
placeholder="7d">
|
||||
</input>
|
||||
</div>
|
||||
<div class="gf-form" ng-if="ctrl.current.jsonData.trends">
|
||||
<span class="gf-form-label width-7">
|
||||
Range
|
||||
<info-popover mode="right-normal">
|
||||
Time range width after which trends will be used instead of history.
|
||||
It's better to set this value in range of 4 to 7 days to prevent loading large amount of history data.
|
||||
</info-popover>
|
||||
</span>
|
||||
<input class="gf-form-input max-width-5" type="text" ng-model='ctrl.current.jsonData.trendsRange' placeholder="4d">
|
||||
</input>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="gf-form">
|
||||
<span class="gf-form-label width-12">
|
||||
Cache TTL
|
||||
<info-popover mode="right-normal">
|
||||
Zabbix data source caches metric names in memory. Specify how often data will be updated.
|
||||
</info-popover>
|
||||
</span>
|
||||
<input class="gf-form-input max-width-5"
|
||||
type="text"
|
||||
ng-model='ctrl.current.jsonData.cacheTTL'
|
||||
placeholder="1h">
|
||||
</input>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="gf-form-group">
|
||||
<h3 class="page-heading">Direct DB Connection</h3>
|
||||
<gf-form-switch class="gf-form" label-class="width-12"
|
||||
label="Enable"
|
||||
checked="ctrl.current.jsonData.dbConnection.enable">
|
||||
</gf-form-switch>
|
||||
<div ng-if="ctrl.current.jsonData.dbConnection.enable">
|
||||
<div class="gf-form max-width-20">
|
||||
<span class="gf-form-label width-12">
|
||||
SQL Data Source
|
||||
<info-popover mode="right-normal">
|
||||
Select SQL Data Source for Zabbix database.
|
||||
In order to use this feature you should <a href="/datasources/new" target="_blank">create</a> and
|
||||
configure it first. Zabbix plugin uses this data source for querying history data directly from database.
|
||||
This way usually faster than pulling data from Zabbix API, especially on the wide time ranges, and reduces
|
||||
amount of data transfered.
|
||||
</info-popover>
|
||||
</span>
|
||||
<div class="gf-form-select-wrapper max-width-16">
|
||||
<select class="gf-form-input" ng-model="ctrl.current.jsonData.dbConnection.datasourceId"
|
||||
ng-options="ds.id as ds.name for ds in ctrl.sqlDataSources">
|
||||
</select>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="gf-form-group">
|
||||
<h3 class="page-heading">Alerting</h3>
|
||||
<gf-form-switch class="gf-form" label-class="width-12"
|
||||
label="Enable alerting"
|
||||
checked="ctrl.current.jsonData.alerting">
|
||||
</gf-form-switch>
|
||||
<div ng-if="ctrl.current.jsonData.alerting">
|
||||
<gf-form-switch class="gf-form" label-class="width-12"
|
||||
label="Add thresholds"
|
||||
checked="ctrl.current.jsonData.addThresholds">
|
||||
</gf-form-switch>
|
||||
<div class="gf-form max-width-20">
|
||||
<span class="gf-form-label width-12">Min severity</span>
|
||||
<div class="gf-form-select-wrapper max-width-16">
|
||||
<select class="gf-form-input" ng-model="ctrl.current.jsonData.alertingMinSeverity"
|
||||
ng-options="s.val as s.text for s in [
|
||||
{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'}]">
|
||||
</select>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="gf-form-group">
|
||||
<h3 class="page-heading">Other</h3>
|
||||
<gf-form-switch class="gf-form" label-class="width-20"
|
||||
label="Disable acknowledges for read-only users"
|
||||
checked="ctrl.current.jsonData.disableReadOnlyUsersAck">
|
||||
</gf-form-switch>
|
||||
</div>
|
||||
<datasource-http-settings current="ctrl.current">
|
||||
</datasource-http-settings>
|
||||
|
||||
<div class="gf-form-group">
|
||||
<h3 class="page-heading">Zabbix API details</h3>
|
||||
|
||||
<div class="gf-form">
|
||||
<span class="gf-form-label width-7">
|
||||
Username
|
||||
</span>
|
||||
<input class="gf-form-input max-width-21"
|
||||
type="text"
|
||||
ng-model='ctrl.current.jsonData.username'
|
||||
placeholder="user"
|
||||
required>
|
||||
</input>
|
||||
</div>
|
||||
|
||||
<div class="gf-form">
|
||||
<span class="gf-form-label width-7">
|
||||
Password
|
||||
</span>
|
||||
<input class="gf-form-input max-width-21"
|
||||
type="password"
|
||||
ng-model='ctrl.current.jsonData.password'
|
||||
placeholder="password">
|
||||
</input>
|
||||
</div>
|
||||
|
||||
<gf-form-switch class="gf-form" label-class="width-7"
|
||||
label="Trends"
|
||||
checked="ctrl.current.jsonData.trends"
|
||||
switch-class="max-width-5">
|
||||
</gf-form-switch>
|
||||
<div class="gf-form-inline">
|
||||
<div class="gf-form" ng-if="ctrl.current.jsonData.trends">
|
||||
<span class="gf-form-label width-7">
|
||||
After
|
||||
<info-popover mode="right-normal">
|
||||
Time after which trends will be used.
|
||||
Best practice is to set this value to your history storage period (7d, 30d, etc).
|
||||
</info-popover>
|
||||
</span>
|
||||
<input class="gf-form-input max-width-5"
|
||||
type="text"
|
||||
ng-model='ctrl.current.jsonData.trendsFrom'
|
||||
placeholder="7d">
|
||||
</input>
|
||||
</div>
|
||||
<div class="gf-form" ng-if="ctrl.current.jsonData.trends">
|
||||
<span class="gf-form-label width-7">
|
||||
Range
|
||||
<info-popover mode="right-normal">
|
||||
Time range width after which trends will be used instead of history.
|
||||
It's better to set this value in range of 4 to 7 days to prevent loading large amount of history data.
|
||||
</info-popover>
|
||||
</span>
|
||||
<input class="gf-form-input max-width-5" type="text" ng-model='ctrl.current.jsonData.trendsRange' placeholder="4d">
|
||||
</input>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="gf-form">
|
||||
<span class="gf-form-label width-12">
|
||||
Cache TTL
|
||||
<info-popover mode="right-normal">
|
||||
Zabbix data source caches metric names in memory. Specify how often data will be updated.
|
||||
</info-popover>
|
||||
</span>
|
||||
<input class="gf-form-input max-width-5"
|
||||
type="text"
|
||||
ng-model='ctrl.current.jsonData.cacheTTL'
|
||||
placeholder="1h">
|
||||
</input>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="gf-form-group">
|
||||
<h3 class="page-heading">Direct DB Connection</h3>
|
||||
<gf-form-switch class="gf-form" label-class="width-12"
|
||||
label="Enable"
|
||||
checked="ctrl.current.jsonData.dbConnection.enable">
|
||||
</gf-form-switch>
|
||||
<div ng-if="ctrl.current.jsonData.dbConnection.enable">
|
||||
<div class="gf-form max-width-20">
|
||||
<span class="gf-form-label width-12">
|
||||
SQL Data Source
|
||||
<info-popover mode="right-normal">
|
||||
Select SQL Data Source for Zabbix database.
|
||||
In order to use this feature you should <a href="/datasources/new" target="_blank">create</a> and
|
||||
configure it first. Zabbix plugin uses this data source for querying history data directly from database.
|
||||
This way usually faster than pulling data from Zabbix API, especially on the wide time ranges, and reduces
|
||||
amount of data transfered.
|
||||
</info-popover>
|
||||
</span>
|
||||
<div class="gf-form-select-wrapper max-width-16">
|
||||
<select class="gf-form-input" ng-model="ctrl.current.jsonData.dbConnection.datasourceId"
|
||||
ng-options="ds.id as ds.name for ds in ctrl.sqlDataSources">
|
||||
</select>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="gf-form-group">
|
||||
<h3 class="page-heading">Alerting</h3>
|
||||
<gf-form-switch class="gf-form" label-class="width-12"
|
||||
label="Enable alerting"
|
||||
checked="ctrl.current.jsonData.alerting">
|
||||
</gf-form-switch>
|
||||
<div ng-if="ctrl.current.jsonData.alerting">
|
||||
<gf-form-switch class="gf-form" label-class="width-12"
|
||||
label="Add thresholds"
|
||||
checked="ctrl.current.jsonData.addThresholds">
|
||||
</gf-form-switch>
|
||||
<div class="gf-form max-width-20">
|
||||
<span class="gf-form-label width-12">Min severity</span>
|
||||
<div class="gf-form-select-wrapper max-width-16">
|
||||
<select class="gf-form-input" ng-model="ctrl.current.jsonData.alertingMinSeverity"
|
||||
ng-options="s.val as s.text for s in [
|
||||
{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'}]">
|
||||
</select>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="gf-form-group">
|
||||
<h3 class="page-heading">Other</h3>
|
||||
<gf-form-switch class="gf-form" label-class="width-20"
|
||||
label="Disable acknowledges for read-only users"
|
||||
checked="ctrl.current.jsonData.disableReadOnlyUsersAck">
|
||||
</gf-form-switch>
|
||||
</div>
|
||||
|
||||
470
dist/datasource-zabbix/partials/query.editor.html
vendored
470
dist/datasource-zabbix/partials/query.editor.html
vendored
@@ -1,235 +1,235 @@
|
||||
<query-editor-row query-ctrl="ctrl" can-collapse="false">
|
||||
|
||||
<div class="gf-form-inline">
|
||||
<div class="gf-form max-width-20">
|
||||
<label class="gf-form-label width-7">Query Mode</label>
|
||||
<div class="gf-form-select-wrapper max-width-20">
|
||||
<select class="gf-form-input"
|
||||
ng-change="ctrl.switchEditorMode(ctrl.target.mode)"
|
||||
ng-model="ctrl.target.mode"
|
||||
ng-options="m.mode as m.text for m in ctrl.editorModes">
|
||||
</select>
|
||||
</div>
|
||||
</div>
|
||||
<div class="gf-form" ng-show="ctrl.target.mode == editorMode.TEXT">
|
||||
<label class="gf-form-label query-keyword width-8">Format As</label>
|
||||
<div class="gf-form-select-wrapper">
|
||||
<select class="gf-form-input gf-size-auto" ng-model="ctrl.target.resultFormat" ng-options="f.value as f.text for f in ctrl.resultFormats" ng-change="ctrl.refresh()"></select>
|
||||
</div>
|
||||
</div>
|
||||
<div class="gf-form gf-form--grow">
|
||||
<div class="gf-form-label gf-form-label--grow"></div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- IT Service editor -->
|
||||
<div class="gf-form-inline" ng-show="ctrl.target.mode == editorMode.ITSERVICE">
|
||||
<div class="gf-form max-width-20">
|
||||
<label class="gf-form-label query-keyword width-7">IT Service</label>
|
||||
<input type="text"
|
||||
ng-model="ctrl.target.itServiceFilter"
|
||||
bs-typeahead="ctrl.getITServices"
|
||||
ng-blur="ctrl.onTargetBlur()"
|
||||
data-min-length=0
|
||||
data-items=100
|
||||
class="gf-form-input"
|
||||
ng-class="{
|
||||
'zbx-variable': ctrl.isVariable(ctrl.target.itServiceFilter),
|
||||
'zbx-regex': ctrl.isRegex(ctrl.target.itServiceFilter)
|
||||
}">
|
||||
</input>
|
||||
</div>
|
||||
<div class="gf-form">
|
||||
<label class="gf-form-label query-keyword">Property</label>
|
||||
<div class="gf-form-select-wrapper">
|
||||
<select class="gf-form-input"
|
||||
ng-change="ctrl.onTargetBlur()"
|
||||
ng-model="ctrl.target.slaProperty"
|
||||
ng-options="slaProperty.name for slaProperty in ctrl.slaPropertyList track by slaProperty.name">
|
||||
</select>
|
||||
</div>
|
||||
</div>
|
||||
<div class="gf-form gf-form--grow">
|
||||
<div class="gf-form-label gf-form-label--grow"></div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="gf-form-inline" ng-show="ctrl.target.mode == editorMode.METRICS || ctrl.target.mode == editorMode.TEXT || ctrl.target.mode == editorMode.TRIGGERS">
|
||||
<!-- Select Group -->
|
||||
<div class="gf-form max-width-20">
|
||||
<label class="gf-form-label query-keyword width-7">Group</label>
|
||||
<input type="text"
|
||||
ng-model="ctrl.target.group.filter"
|
||||
bs-typeahead="ctrl.getGroupNames"
|
||||
ng-blur="ctrl.onTargetBlur()"
|
||||
data-min-length=0
|
||||
data-items=100
|
||||
class="gf-form-input"
|
||||
ng-class="{
|
||||
'zbx-variable': ctrl.isVariable(ctrl.target.group.filter),
|
||||
'zbx-regex': ctrl.isRegex(ctrl.target.group.filter)
|
||||
}"></input>
|
||||
</div>
|
||||
<!-- Select Host -->
|
||||
<div class="gf-form">
|
||||
<label class="gf-form-label query-keyword width-8">Host</label>
|
||||
<input type="text"
|
||||
ng-model="ctrl.target.host.filter"
|
||||
bs-typeahead="ctrl.getHostNames"
|
||||
ng-blur="ctrl.onTargetBlur()"
|
||||
data-min-length=0
|
||||
data-items=100
|
||||
class="gf-form-input"
|
||||
ng-class="{
|
||||
'zbx-variable': ctrl.isVariable(ctrl.target.host.filter),
|
||||
'zbx-regex': ctrl.isRegex(ctrl.target.host.filter)
|
||||
}">
|
||||
</div>
|
||||
|
||||
<div class="gf-form gf-form--grow">
|
||||
<div class="gf-form-label gf-form-label--grow"></div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="gf-form-inline" ng-show="ctrl.target.mode == editorMode.METRICS || ctrl.target.mode == editorMode.TEXT || ctrl.target.mode == editorMode.TRIGGERS">
|
||||
<!-- Select Application -->
|
||||
<div class="gf-form max-width-20">
|
||||
<label class="gf-form-label query-keyword width-7">Application</label>
|
||||
<input type="text"
|
||||
ng-model="ctrl.target.application.filter"
|
||||
bs-typeahead="ctrl.getApplicationNames"
|
||||
ng-blur="ctrl.onTargetBlur()"
|
||||
data-min-length=0
|
||||
data-items=100
|
||||
class="gf-form-input"
|
||||
ng-class="{
|
||||
'zbx-variable': ctrl.isVariable(ctrl.target.application.filter),
|
||||
'zbx-regex': ctrl.isRegex(ctrl.target.application.filter)
|
||||
}">
|
||||
</div>
|
||||
|
||||
<!-- Select Item -->
|
||||
<div class="gf-form" ng-show="ctrl.target.mode == editorMode.METRICS || ctrl.target.mode == editorMode.TEXT">
|
||||
<label class="gf-form-label query-keyword width-8">Item</label>
|
||||
<input type="text"
|
||||
ng-model="ctrl.target.item.filter"
|
||||
bs-typeahead="ctrl.getItemNames"
|
||||
ng-blur="ctrl.onTargetBlur()"
|
||||
data-min-length=0
|
||||
data-items=100
|
||||
class="gf-form-input"
|
||||
ng-class="{
|
||||
'zbx-variable': ctrl.isVariable(ctrl.target.item.filter),
|
||||
'zbx-regex': ctrl.isRegex(ctrl.target.item.filter)
|
||||
}">
|
||||
</div>
|
||||
|
||||
<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-16">
|
||||
<select class="gf-form-input"
|
||||
ng-change="ctrl.onTargetBlur()"
|
||||
ng-model="ctrl.target.triggers.minSeverity"
|
||||
ng-options="s.val as s.text for s in ctrl.triggerSeverity">
|
||||
</select>
|
||||
</div>
|
||||
</div>
|
||||
<div class="gf-form max-width-20" ng-show="ctrl.target.mode == editorMode.TRIGGERS">
|
||||
<label class="gf-form-label query-keyword width-8">Acknowledged</label>
|
||||
<div class="gf-form-select-wrapper width-12">
|
||||
<select class="gf-form-input"
|
||||
ng-change="ctrl.onTargetBlur()"
|
||||
ng-model="ctrl.target.triggers.acknowledged"
|
||||
ng-options="a.value as a.text for a in ctrl.ackFilters">
|
||||
</select>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<gf-form-switch class="gf-form" label="Count" ng-show="ctrl.target.mode == editorMode.TRIGGERS"
|
||||
checked="ctrl.target.triggers.count" 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()" 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}}
|
||||
</a>
|
||||
</label>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- Query options -->
|
||||
<div class="gf-form-group" ng-if="ctrl.showQueryOptions">
|
||||
<div class="gf-form offset-width-7" ng-hide="ctrl.target.mode == editorMode.TRIGGERS">
|
||||
<gf-form-switch class="gf-form" label-class="width-10"
|
||||
label="Show disabled items"
|
||||
checked="ctrl.target.options.showDisabledItems"
|
||||
on-change="ctrl.onQueryOptionChange()">
|
||||
</gf-form-switch>
|
||||
</div>
|
||||
<div class="gf-form offset-width-7" ng-show="ctrl.target.mode === editorMode.TEXT && ctrl.target.resultFormat === 'table'">
|
||||
<gf-form-switch class="gf-form" label-class="width-10"
|
||||
label="Skip empty values"
|
||||
checked="ctrl.target.options.skipEmptyValues"
|
||||
on-change="ctrl.onQueryOptionChange()">
|
||||
</gf-form-switch>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- Item IDs editor mode -->
|
||||
<div class="gf-form-inline" ng-show="ctrl.target.mode == editorMode.ITEMID">
|
||||
<div class="gf-form max-width-20">
|
||||
<label class="gf-form-label query-keyword width-7">Item IDs</label>
|
||||
<input type="text"
|
||||
ng-model="ctrl.target.itemids"
|
||||
bs-typeahead="ctrl.getVariables"
|
||||
ng-blur="ctrl.onTargetBlur()"
|
||||
data-min-length=0
|
||||
data-items=100
|
||||
class="gf-form-input"
|
||||
ng-class="{
|
||||
'zbx-variable': ctrl.isVariable(ctrl.target.itServiceFilter),
|
||||
'zbx-regex': ctrl.isRegex(ctrl.target.itServiceFilter)
|
||||
}">
|
||||
</input>
|
||||
</div>
|
||||
<div class="gf-form gf-form--grow">
|
||||
<div class="gf-form-label gf-form-label--grow"></div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- Metric processing functions -->
|
||||
<div class="gf-form-inline" ng-show="ctrl.target.mode == editorMode.METRICS || ctrl.target.mode == editorMode.ITEMID">
|
||||
<div class="gf-form">
|
||||
<label class="gf-form-label query-keyword width-7">Functions</label>
|
||||
<div ng-repeat="func in ctrl.target.functions" class="gf-form-label query-part" metric-function-editor></div>
|
||||
</div>
|
||||
<div class="gf-form dropdown" add-metric-function>
|
||||
</div>
|
||||
<div class="gf-form gf-form--grow">
|
||||
<div class="gf-form-label gf-form-label--grow"></div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- Text mode options -->
|
||||
<div class="gf-form-inline" ng-show="ctrl.target.mode == editorMode.TEXT">
|
||||
<!-- Text metric regex -->
|
||||
<div class="gf-form max-width-20">
|
||||
<label class="gf-form-label query-keyword width-7">Text filter</label>
|
||||
<input type="text"
|
||||
class="gf-form-input"
|
||||
ng-model="ctrl.target.textFilter"
|
||||
spellcheck='false'
|
||||
placeholder="Text filter (regex)"
|
||||
ng-blur="ctrl.onTargetBlur()">
|
||||
</div>
|
||||
|
||||
<gf-form-switch class="gf-form" label="Use capture groups" checked="ctrl.target.useCaptureGroups" on-change="ctrl.onTargetBlur()">
|
||||
</gf-form-switch>
|
||||
<div class="gf-form gf-form--grow">
|
||||
<div class="gf-form-label gf-form-label--grow"></div>
|
||||
</div>
|
||||
</div>
|
||||
</query-editor-row>
|
||||
<query-editor-row query-ctrl="ctrl" can-collapse="false">
|
||||
|
||||
<div class="gf-form-inline">
|
||||
<div class="gf-form max-width-20">
|
||||
<label class="gf-form-label width-7">Query Mode</label>
|
||||
<div class="gf-form-select-wrapper max-width-20">
|
||||
<select class="gf-form-input"
|
||||
ng-change="ctrl.switchEditorMode(ctrl.target.mode)"
|
||||
ng-model="ctrl.target.mode"
|
||||
ng-options="m.mode as m.text for m in ctrl.editorModes">
|
||||
</select>
|
||||
</div>
|
||||
</div>
|
||||
<div class="gf-form" ng-show="ctrl.target.mode == editorMode.TEXT">
|
||||
<label class="gf-form-label query-keyword width-8">Format As</label>
|
||||
<div class="gf-form-select-wrapper">
|
||||
<select class="gf-form-input gf-size-auto" ng-model="ctrl.target.resultFormat" ng-options="f.value as f.text for f in ctrl.resultFormats" ng-change="ctrl.refresh()"></select>
|
||||
</div>
|
||||
</div>
|
||||
<div class="gf-form gf-form--grow">
|
||||
<div class="gf-form-label gf-form-label--grow"></div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- IT Service editor -->
|
||||
<div class="gf-form-inline" ng-show="ctrl.target.mode == editorMode.ITSERVICE">
|
||||
<div class="gf-form max-width-20">
|
||||
<label class="gf-form-label query-keyword width-7">IT Service</label>
|
||||
<input type="text"
|
||||
ng-model="ctrl.target.itServiceFilter"
|
||||
bs-typeahead="ctrl.getITServices"
|
||||
ng-blur="ctrl.onTargetBlur()"
|
||||
data-min-length=0
|
||||
data-items=100
|
||||
class="gf-form-input"
|
||||
ng-class="{
|
||||
'zbx-variable': ctrl.isVariable(ctrl.target.itServiceFilter),
|
||||
'zbx-regex': ctrl.isRegex(ctrl.target.itServiceFilter)
|
||||
}">
|
||||
</input>
|
||||
</div>
|
||||
<div class="gf-form">
|
||||
<label class="gf-form-label query-keyword">Property</label>
|
||||
<div class="gf-form-select-wrapper">
|
||||
<select class="gf-form-input"
|
||||
ng-change="ctrl.onTargetBlur()"
|
||||
ng-model="ctrl.target.slaProperty"
|
||||
ng-options="slaProperty.name for slaProperty in ctrl.slaPropertyList track by slaProperty.name">
|
||||
</select>
|
||||
</div>
|
||||
</div>
|
||||
<div class="gf-form gf-form--grow">
|
||||
<div class="gf-form-label gf-form-label--grow"></div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="gf-form-inline" ng-show="ctrl.target.mode == editorMode.METRICS || ctrl.target.mode == editorMode.TEXT || ctrl.target.mode == editorMode.TRIGGERS">
|
||||
<!-- Select Group -->
|
||||
<div class="gf-form max-width-20">
|
||||
<label class="gf-form-label query-keyword width-7">Group</label>
|
||||
<input type="text"
|
||||
ng-model="ctrl.target.group.filter"
|
||||
bs-typeahead="ctrl.getGroupNames"
|
||||
ng-blur="ctrl.onTargetBlur()"
|
||||
data-min-length=0
|
||||
data-items=100
|
||||
class="gf-form-input"
|
||||
ng-class="{
|
||||
'zbx-variable': ctrl.isVariable(ctrl.target.group.filter),
|
||||
'zbx-regex': ctrl.isRegex(ctrl.target.group.filter)
|
||||
}"></input>
|
||||
</div>
|
||||
<!-- Select Host -->
|
||||
<div class="gf-form">
|
||||
<label class="gf-form-label query-keyword width-8">Host</label>
|
||||
<input type="text"
|
||||
ng-model="ctrl.target.host.filter"
|
||||
bs-typeahead="ctrl.getHostNames"
|
||||
ng-blur="ctrl.onTargetBlur()"
|
||||
data-min-length=0
|
||||
data-items=100
|
||||
class="gf-form-input"
|
||||
ng-class="{
|
||||
'zbx-variable': ctrl.isVariable(ctrl.target.host.filter),
|
||||
'zbx-regex': ctrl.isRegex(ctrl.target.host.filter)
|
||||
}">
|
||||
</div>
|
||||
|
||||
<div class="gf-form gf-form--grow">
|
||||
<div class="gf-form-label gf-form-label--grow"></div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="gf-form-inline" ng-show="ctrl.target.mode == editorMode.METRICS || ctrl.target.mode == editorMode.TEXT || ctrl.target.mode == editorMode.TRIGGERS">
|
||||
<!-- Select Application -->
|
||||
<div class="gf-form max-width-20">
|
||||
<label class="gf-form-label query-keyword width-7">Application</label>
|
||||
<input type="text"
|
||||
ng-model="ctrl.target.application.filter"
|
||||
bs-typeahead="ctrl.getApplicationNames"
|
||||
ng-blur="ctrl.onTargetBlur()"
|
||||
data-min-length=0
|
||||
data-items=100
|
||||
class="gf-form-input"
|
||||
ng-class="{
|
||||
'zbx-variable': ctrl.isVariable(ctrl.target.application.filter),
|
||||
'zbx-regex': ctrl.isRegex(ctrl.target.application.filter)
|
||||
}">
|
||||
</div>
|
||||
|
||||
<!-- Select Item -->
|
||||
<div class="gf-form" ng-show="ctrl.target.mode == editorMode.METRICS || ctrl.target.mode == editorMode.TEXT">
|
||||
<label class="gf-form-label query-keyword width-8">Item</label>
|
||||
<input type="text"
|
||||
ng-model="ctrl.target.item.filter"
|
||||
bs-typeahead="ctrl.getItemNames"
|
||||
ng-blur="ctrl.onTargetBlur()"
|
||||
data-min-length=0
|
||||
data-items=100
|
||||
class="gf-form-input"
|
||||
ng-class="{
|
||||
'zbx-variable': ctrl.isVariable(ctrl.target.item.filter),
|
||||
'zbx-regex': ctrl.isRegex(ctrl.target.item.filter)
|
||||
}">
|
||||
</div>
|
||||
|
||||
<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-16">
|
||||
<select class="gf-form-input"
|
||||
ng-change="ctrl.onTargetBlur()"
|
||||
ng-model="ctrl.target.triggers.minSeverity"
|
||||
ng-options="s.val as s.text for s in ctrl.triggerSeverity">
|
||||
</select>
|
||||
</div>
|
||||
</div>
|
||||
<div class="gf-form max-width-20" ng-show="ctrl.target.mode == editorMode.TRIGGERS">
|
||||
<label class="gf-form-label query-keyword width-8">Acknowledged</label>
|
||||
<div class="gf-form-select-wrapper width-12">
|
||||
<select class="gf-form-input"
|
||||
ng-change="ctrl.onTargetBlur()"
|
||||
ng-model="ctrl.target.triggers.acknowledged"
|
||||
ng-options="a.value as a.text for a in ctrl.ackFilters">
|
||||
</select>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<gf-form-switch class="gf-form" label="Count" ng-show="ctrl.target.mode == editorMode.TRIGGERS"
|
||||
checked="ctrl.target.triggers.count" 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()" 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}}
|
||||
</a>
|
||||
</label>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- Query options -->
|
||||
<div class="gf-form-group" ng-if="ctrl.showQueryOptions">
|
||||
<div class="gf-form offset-width-7" ng-hide="ctrl.target.mode == editorMode.TRIGGERS">
|
||||
<gf-form-switch class="gf-form" label-class="width-10"
|
||||
label="Show disabled items"
|
||||
checked="ctrl.target.options.showDisabledItems"
|
||||
on-change="ctrl.onQueryOptionChange()">
|
||||
</gf-form-switch>
|
||||
</div>
|
||||
<div class="gf-form offset-width-7" ng-show="ctrl.target.mode === editorMode.TEXT && ctrl.target.resultFormat === 'table'">
|
||||
<gf-form-switch class="gf-form" label-class="width-10"
|
||||
label="Skip empty values"
|
||||
checked="ctrl.target.options.skipEmptyValues"
|
||||
on-change="ctrl.onQueryOptionChange()">
|
||||
</gf-form-switch>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- Item IDs editor mode -->
|
||||
<div class="gf-form-inline" ng-show="ctrl.target.mode == editorMode.ITEMID">
|
||||
<div class="gf-form max-width-20">
|
||||
<label class="gf-form-label query-keyword width-7">Item IDs</label>
|
||||
<input type="text"
|
||||
ng-model="ctrl.target.itemids"
|
||||
bs-typeahead="ctrl.getVariables"
|
||||
ng-blur="ctrl.onTargetBlur()"
|
||||
data-min-length=0
|
||||
data-items=100
|
||||
class="gf-form-input"
|
||||
ng-class="{
|
||||
'zbx-variable': ctrl.isVariable(ctrl.target.itServiceFilter),
|
||||
'zbx-regex': ctrl.isRegex(ctrl.target.itServiceFilter)
|
||||
}">
|
||||
</input>
|
||||
</div>
|
||||
<div class="gf-form gf-form--grow">
|
||||
<div class="gf-form-label gf-form-label--grow"></div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- Metric processing functions -->
|
||||
<div class="gf-form-inline" ng-show="ctrl.target.mode == editorMode.METRICS || ctrl.target.mode == editorMode.ITEMID">
|
||||
<div class="gf-form">
|
||||
<label class="gf-form-label query-keyword width-7">Functions</label>
|
||||
<div ng-repeat="func in ctrl.target.functions" class="gf-form-label query-part" metric-function-editor></div>
|
||||
</div>
|
||||
<div class="gf-form dropdown" add-metric-function>
|
||||
</div>
|
||||
<div class="gf-form gf-form--grow">
|
||||
<div class="gf-form-label gf-form-label--grow"></div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- Text mode options -->
|
||||
<div class="gf-form-inline" ng-show="ctrl.target.mode == editorMode.TEXT">
|
||||
<!-- Text metric regex -->
|
||||
<div class="gf-form max-width-20">
|
||||
<label class="gf-form-label query-keyword width-7">Text filter</label>
|
||||
<input type="text"
|
||||
class="gf-form-input"
|
||||
ng-model="ctrl.target.textFilter"
|
||||
spellcheck='false'
|
||||
placeholder="Text filter (regex)"
|
||||
ng-blur="ctrl.onTargetBlur()">
|
||||
</div>
|
||||
|
||||
<gf-form-switch class="gf-form" label="Use capture groups" checked="ctrl.target.useCaptureGroups" on-change="ctrl.onTargetBlur()">
|
||||
</gf-form-switch>
|
||||
<div class="gf-form gf-form--grow">
|
||||
<div class="gf-form-label gf-form-label--grow"></div>
|
||||
</div>
|
||||
</div>
|
||||
</query-editor-row>
|
||||
|
||||
176
dist/datasource-zabbix/partials/query.options.html
vendored
176
dist/datasource-zabbix/partials/query.options.html
vendored
@@ -1,88 +1,88 @@
|
||||
<section class="grafana-metric-options gf-form-group">
|
||||
<div class="gf-form-inline">
|
||||
<div class="gf-form max-width-15">
|
||||
<span class="gf-form-label">Max data points</span>
|
||||
<input type="text"
|
||||
class="gf-form-input"
|
||||
ng-model="ctrl.panelCtrl.panel.maxDataPoints"
|
||||
bs-tooltip="'Override max data points, automatically set to graph width in pixels.'"
|
||||
data-placement="right"
|
||||
ng-model-onblur ng-change="ctrl.panelCtrl.refresh()"
|
||||
spellcheck='false'
|
||||
placeholder="auto">
|
||||
</input>
|
||||
</div>
|
||||
</div>
|
||||
<div class="gf-form-inline">
|
||||
<div class="gf-form">
|
||||
<span class="gf-form-label width-10">
|
||||
<i class="fa fa-info-circle"></i>
|
||||
<a ng-click="ctrl.panelCtrl.toggleEditorHelp(1);" bs-tooltip="'click to show helpful info'" data-placement="bottom">
|
||||
Max data points
|
||||
</a>
|
||||
</span>
|
||||
<span class="gf-form-label width-10">
|
||||
<i class="fa fa-info-circle"></i>
|
||||
<a ng-click="ctrl.panelCtrl.toggleEditorHelp(2);" bs-tooltip="'click to show helpful info'" data-placement="bottom">
|
||||
IT services
|
||||
</a>
|
||||
</span>
|
||||
<span class="gf-form-label width-12">
|
||||
<i class="fa fa-info-circle"></i>
|
||||
<a ng-click="ctrl.panelCtrl.toggleEditorHelp(3)" bs-tooltip="'click to show helpful info'" data-placement="bottom">
|
||||
IT service property
|
||||
</a>
|
||||
</span>
|
||||
<span class="gf-form-label width-8">
|
||||
<i class="fa fa-info-circle"></i>
|
||||
<a ng-click="ctrl.panelCtrl.toggleEditorHelp(4)" bs-tooltip="'click to show helpful info'" data-placement="bottom">
|
||||
Text filter
|
||||
</a>
|
||||
</span>
|
||||
</div>
|
||||
</div>
|
||||
</section>
|
||||
|
||||
<div class="editor-row">
|
||||
<div class="pull-left">
|
||||
|
||||
<div class="grafana-info-box span8" ng-if="ctrl.panelCtrl.editorHelpIndex === 1">
|
||||
<h5>Max data points</h5>
|
||||
<ul>
|
||||
<li>Grafana-Zabbix plugin uses maxDataPoints parameter to consolidate the real number of values down to this
|
||||
number
|
||||
</li>
|
||||
<li>If there are more real values, then by default they will be consolidated using averages</li>
|
||||
<li>This could hide real peaks and max values in your series</li>
|
||||
<li>Point consolidation will effect series legend values (min,max,total,current)</li>
|
||||
<li>If you override maxDataPoint and set a high value performance can be severely effected</li>
|
||||
</ul>
|
||||
</div>
|
||||
|
||||
<div class="grafana-info-box span8" ng-if="ctrl.panelCtrl.editorHelpIndex === 2">
|
||||
<h5>IT services</h5>
|
||||
<ul>
|
||||
<li>Select "IT services" in targets menu to activate IT services mode.</li>
|
||||
</ul>
|
||||
</div>
|
||||
|
||||
<div class="grafana-info-box span8" ng-if="ctrl.panelCtrl.editorHelpIndex === 3">
|
||||
<h5>IT service property</h5>
|
||||
<ul>
|
||||
<li>Zabbix returns the following availability information about IT service</li>
|
||||
<li>Status - current status of the IT service</li>
|
||||
<li>SLA - SLA for the given time interval</li>
|
||||
<li>OK time - time the service was in OK state, in seconds</li>
|
||||
<li>Problem time - time the service was in problem state, in seconds</li>
|
||||
<li>Down time - time the service was in scheduled downtime, in seconds</li>
|
||||
</ul>
|
||||
</div>
|
||||
|
||||
<div class="grafana-info-box span8" ng-if="ctrl.panelCtrl.editorHelpIndex === 4">
|
||||
<h5>Text filter</h5>
|
||||
<ul>
|
||||
<li>Use regex to extract a part of the returned value.</li>
|
||||
</ul>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<section class="grafana-metric-options gf-form-group">
|
||||
<div class="gf-form-inline">
|
||||
<div class="gf-form max-width-15">
|
||||
<span class="gf-form-label">Max data points</span>
|
||||
<input type="text"
|
||||
class="gf-form-input"
|
||||
ng-model="ctrl.panelCtrl.panel.maxDataPoints"
|
||||
bs-tooltip="'Override max data points, automatically set to graph width in pixels.'"
|
||||
data-placement="right"
|
||||
ng-model-onblur ng-change="ctrl.panelCtrl.refresh()"
|
||||
spellcheck='false'
|
||||
placeholder="auto">
|
||||
</input>
|
||||
</div>
|
||||
</div>
|
||||
<div class="gf-form-inline">
|
||||
<div class="gf-form">
|
||||
<span class="gf-form-label width-10">
|
||||
<i class="fa fa-info-circle"></i>
|
||||
<a ng-click="ctrl.panelCtrl.toggleEditorHelp(1);" bs-tooltip="'click to show helpful info'" data-placement="bottom">
|
||||
Max data points
|
||||
</a>
|
||||
</span>
|
||||
<span class="gf-form-label width-10">
|
||||
<i class="fa fa-info-circle"></i>
|
||||
<a ng-click="ctrl.panelCtrl.toggleEditorHelp(2);" bs-tooltip="'click to show helpful info'" data-placement="bottom">
|
||||
IT services
|
||||
</a>
|
||||
</span>
|
||||
<span class="gf-form-label width-12">
|
||||
<i class="fa fa-info-circle"></i>
|
||||
<a ng-click="ctrl.panelCtrl.toggleEditorHelp(3)" bs-tooltip="'click to show helpful info'" data-placement="bottom">
|
||||
IT service property
|
||||
</a>
|
||||
</span>
|
||||
<span class="gf-form-label width-8">
|
||||
<i class="fa fa-info-circle"></i>
|
||||
<a ng-click="ctrl.panelCtrl.toggleEditorHelp(4)" bs-tooltip="'click to show helpful info'" data-placement="bottom">
|
||||
Text filter
|
||||
</a>
|
||||
</span>
|
||||
</div>
|
||||
</div>
|
||||
</section>
|
||||
|
||||
<div class="editor-row">
|
||||
<div class="pull-left">
|
||||
|
||||
<div class="grafana-info-box span8" ng-if="ctrl.panelCtrl.editorHelpIndex === 1">
|
||||
<h5>Max data points</h5>
|
||||
<ul>
|
||||
<li>Grafana-Zabbix plugin uses maxDataPoints parameter to consolidate the real number of values down to this
|
||||
number
|
||||
</li>
|
||||
<li>If there are more real values, then by default they will be consolidated using averages</li>
|
||||
<li>This could hide real peaks and max values in your series</li>
|
||||
<li>Point consolidation will effect series legend values (min,max,total,current)</li>
|
||||
<li>If you override maxDataPoint and set a high value performance can be severely effected</li>
|
||||
</ul>
|
||||
</div>
|
||||
|
||||
<div class="grafana-info-box span8" ng-if="ctrl.panelCtrl.editorHelpIndex === 2">
|
||||
<h5>IT services</h5>
|
||||
<ul>
|
||||
<li>Select "IT services" in targets menu to activate IT services mode.</li>
|
||||
</ul>
|
||||
</div>
|
||||
|
||||
<div class="grafana-info-box span8" ng-if="ctrl.panelCtrl.editorHelpIndex === 3">
|
||||
<h5>IT service property</h5>
|
||||
<ul>
|
||||
<li>Zabbix returns the following availability information about IT service</li>
|
||||
<li>Status - current status of the IT service</li>
|
||||
<li>SLA - SLA for the given time interval</li>
|
||||
<li>OK time - time the service was in OK state, in seconds</li>
|
||||
<li>Problem time - time the service was in problem state, in seconds</li>
|
||||
<li>Down time - time the service was in scheduled downtime, in seconds</li>
|
||||
</ul>
|
||||
</div>
|
||||
|
||||
<div class="grafana-info-box span8" ng-if="ctrl.panelCtrl.editorHelpIndex === 4">
|
||||
<h5>Text filter</h5>
|
||||
<ul>
|
||||
<li>Use regex to extract a part of the returned value.</li>
|
||||
</ul>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
72
dist/datasource-zabbix/plugin.json
vendored
72
dist/datasource-zabbix/plugin.json
vendored
@@ -1,36 +1,36 @@
|
||||
{
|
||||
"type": "datasource",
|
||||
"name": "Zabbix",
|
||||
"id": "alexanderzobnin-zabbix-datasource",
|
||||
|
||||
"includes": [
|
||||
{
|
||||
"type": "dashboard",
|
||||
"name": "Zabbix System Status",
|
||||
"path": "../dashboards/zabbix_system_status.json"
|
||||
},
|
||||
{
|
||||
"type": "dashboard",
|
||||
"name": "Zabbix Template Linux Server",
|
||||
"path": "../dashboards/template_linux_server.json"
|
||||
}
|
||||
],
|
||||
|
||||
"metrics": true,
|
||||
"annotations": true,
|
||||
|
||||
"queryOptions": {
|
||||
"maxDataPoints": true
|
||||
},
|
||||
|
||||
"info": {
|
||||
"author": {
|
||||
"name": "Alexander Zobnin",
|
||||
"url": "https://github.com/alexanderzobnin/grafana-zabbix"
|
||||
},
|
||||
"logos": {
|
||||
"small": "img/zabbix_app_logo.svg",
|
||||
"large": "img/zabbix_app_logo.svg"
|
||||
}
|
||||
}
|
||||
}
|
||||
{
|
||||
"type": "datasource",
|
||||
"name": "Zabbix",
|
||||
"id": "alexanderzobnin-zabbix-datasource",
|
||||
|
||||
"includes": [
|
||||
{
|
||||
"type": "dashboard",
|
||||
"name": "Zabbix System Status",
|
||||
"path": "../dashboards/zabbix_system_status.json"
|
||||
},
|
||||
{
|
||||
"type": "dashboard",
|
||||
"name": "Zabbix Template Linux Server",
|
||||
"path": "../dashboards/template_linux_server.json"
|
||||
}
|
||||
],
|
||||
|
||||
"metrics": true,
|
||||
"annotations": true,
|
||||
|
||||
"queryOptions": {
|
||||
"maxDataPoints": true
|
||||
},
|
||||
|
||||
"info": {
|
||||
"author": {
|
||||
"name": "Alexander Zobnin",
|
||||
"url": "https://github.com/alexanderzobnin/grafana-zabbix"
|
||||
},
|
||||
"logos": {
|
||||
"small": "img/zabbix_app_logo.svg",
|
||||
"large": "img/zabbix_app_logo.svg"
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
File diff suppressed because one or more lines are too long
62
dist/datasource-zabbix/query_help.md
vendored
62
dist/datasource-zabbix/query_help.md
vendored
@@ -1,31 +1,31 @@
|
||||
#### Max data points
|
||||
Override max data points, automatically set to graph width in pixels. Grafana-Zabbix plugin uses maxDataPoints parameter to consolidate the real number of values down to this number. If there are more real values, then by default they will be consolidated using averages. This could hide real peaks and max values in your series. Point consolidation will affect series legend values (min,max,total,current).
|
||||
|
||||
#### Query Mode
|
||||
##### Merics
|
||||
Data from numeric items.
|
||||
|
||||
##### Text
|
||||
Data from items with `Character`, `Text` or `Log` type.
|
||||
|
||||
##### IT Services
|
||||
Time series representation of IT Services data
|
||||
###### IT service property
|
||||
Zabbix returns the following availability information about IT service:
|
||||
- Status - current status of the IT service
|
||||
- SLA - SLA for the given time interval
|
||||
- OK time - time the service was in OK state, in seconds
|
||||
- Problem time - time the service was in problem state, in seconds
|
||||
- Down time - time the service was in scheduled downtime, in seconds
|
||||
|
||||
##### Item ID
|
||||
Data from items with specified ID's (comma separated).
|
||||
This mode is suitable for rendering charts in grafana by passing itemids as url params.
|
||||
1. Create multivalue template variable with type _Custom_, for example, `itemids`.
|
||||
1. Create graph with desired parameters and use `$itemids` in _Item IDs_ filed.
|
||||
1. Save dashboard.
|
||||
1. Click to graph title and select _Share_ -> _Direct link rendered image_.
|
||||
1. Use this URL for graph png image and set `var-itemids` param to desired IDs. Note, for multiple IDs you should pass multiple params, like `&var-itemids=28276&var-itemids=28277`.
|
||||
|
||||
##### Triggers
|
||||
Active triggers count for selected hosts or table data like Zabbix _System status_ panel on the main dashboard.
|
||||
#### Max data points
|
||||
Override max data points, automatically set to graph width in pixels. Grafana-Zabbix plugin uses maxDataPoints parameter to consolidate the real number of values down to this number. If there are more real values, then by default they will be consolidated using averages. This could hide real peaks and max values in your series. Point consolidation will affect series legend values (min,max,total,current).
|
||||
|
||||
#### Query Mode
|
||||
##### Merics
|
||||
Data from numeric items.
|
||||
|
||||
##### Text
|
||||
Data from items with `Character`, `Text` or `Log` type.
|
||||
|
||||
##### IT Services
|
||||
Time series representation of IT Services data
|
||||
###### IT service property
|
||||
Zabbix returns the following availability information about IT service:
|
||||
- Status - current status of the IT service
|
||||
- SLA - SLA for the given time interval
|
||||
- OK time - time the service was in OK state, in seconds
|
||||
- Problem time - time the service was in problem state, in seconds
|
||||
- Down time - time the service was in scheduled downtime, in seconds
|
||||
|
||||
##### Item ID
|
||||
Data from items with specified ID's (comma separated).
|
||||
This mode is suitable for rendering charts in grafana by passing itemids as url params.
|
||||
1. Create multivalue template variable with type _Custom_, for example, `itemids`.
|
||||
1. Create graph with desired parameters and use `$itemids` in _Item IDs_ filed.
|
||||
1. Save dashboard.
|
||||
1. Click to graph title and select _Share_ -> _Direct link rendered image_.
|
||||
1. Use this URL for graph png image and set `var-itemids` param to desired IDs. Note, for multiple IDs you should pass multiple params, like `&var-itemids=28276&var-itemids=28277`.
|
||||
|
||||
##### Triggers
|
||||
Active triggers count for selected hosts or table data like Zabbix _System status_ panel on the main dashboard.
|
||||
|
||||
32
dist/datasource-zabbix/responseHandler.js
vendored
32
dist/datasource-zabbix/responseHandler.js
vendored
@@ -17,24 +17,24 @@ System.register(['lodash', 'app/core/table_model', './constants'], function (_ex
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Convert Zabbix API history.get response to Grafana format
|
||||
*
|
||||
* @return {Array} Array of timeseries in Grafana format
|
||||
* {
|
||||
* target: "Metric name",
|
||||
* datapoints: [[<value>, <unixtime>], ...]
|
||||
* }
|
||||
/**
|
||||
* Convert Zabbix API history.get response to Grafana format
|
||||
*
|
||||
* @return {Array} Array of timeseries in Grafana format
|
||||
* {
|
||||
* target: "Metric name",
|
||||
* datapoints: [[<value>, <unixtime>], ...]
|
||||
* }
|
||||
*/
|
||||
function convertHistory(history, items, addHostName, convertPointCallback) {
|
||||
/**
|
||||
* Response should be in the format:
|
||||
* data: [
|
||||
* {
|
||||
* target: "Metric name",
|
||||
* datapoints: [[<value>, <unixtime>], ...]
|
||||
* }, ...
|
||||
* ]
|
||||
/**
|
||||
* Response should be in the format:
|
||||
* data: [
|
||||
* {
|
||||
* target: "Metric name",
|
||||
* datapoints: [[<value>, <unixtime>], ...]
|
||||
* }, ...
|
||||
* ]
|
||||
*/
|
||||
|
||||
// Group history by itemid
|
||||
|
||||
File diff suppressed because one or more lines are too long
102
dist/datasource-zabbix/specs/dataProcessor.spec.js
vendored
102
dist/datasource-zabbix/specs/dataProcessor.spec.js
vendored
@@ -1,51 +1,51 @@
|
||||
import _ from 'lodash';
|
||||
import dataProcessor from '../dataProcessor';
|
||||
|
||||
describe('dataProcessor', () => {
|
||||
let ctx = {};
|
||||
|
||||
beforeEach(() => {
|
||||
ctx.datapoints = [
|
||||
[[10, 1500000000000], [2, 1500000001000], [7, 1500000002000], [1, 1500000003000]],
|
||||
[[9, 1500000000000], [3, 1500000001000], [4, 1500000002000], [8, 1500000003000]],
|
||||
];
|
||||
});
|
||||
|
||||
describe('When apply groupBy() functions', () => {
|
||||
it('should return series average', () => {
|
||||
let aggregateBy = dataProcessor.metricFunctions['groupBy'];
|
||||
const avg2s = _.map(ctx.datapoints, (dp) => aggregateBy('2s', 'avg', dp));
|
||||
expect(avg2s).toEqual([
|
||||
[[6, 1500000000000], [4, 1500000002000]],
|
||||
[[6, 1500000000000], [6, 1500000002000]],
|
||||
]);
|
||||
|
||||
const avg10s = _.map(ctx.datapoints, (dp) => aggregateBy('10s', 'avg', dp));
|
||||
expect(avg10s).toEqual([
|
||||
[[5, 1500000000000]],
|
||||
[[6, 1500000000000]],
|
||||
]);
|
||||
|
||||
// not aligned
|
||||
const dp = [[10, 1500000001000], [2, 1500000002000], [7, 1500000003000], [1, 1500000004000]];
|
||||
expect(aggregateBy('2s', 'avg', dp)).toEqual([
|
||||
[10, 1500000000000], [4.5, 1500000002000], [1, 1500000004000]
|
||||
]);
|
||||
});
|
||||
});
|
||||
|
||||
describe('When apply aggregateBy() functions', () => {
|
||||
it('should return series average', () => {
|
||||
let aggregateBy = dataProcessor.metricFunctions['aggregateBy'];
|
||||
const avg1s = aggregateBy('1s', 'avg', ctx.datapoints);
|
||||
expect(avg1s).toEqual([
|
||||
[9.5, 1500000000000], [2.5, 1500000001000], [5.5, 1500000002000], [4.5, 1500000003000]
|
||||
]);
|
||||
|
||||
const avg10s = aggregateBy('10s', 'avg', ctx.datapoints);
|
||||
expect(avg10s).toEqual([
|
||||
[5.5, 1500000000000]
|
||||
]);
|
||||
});
|
||||
});
|
||||
});
|
||||
import _ from 'lodash';
|
||||
import dataProcessor from '../dataProcessor';
|
||||
|
||||
describe('dataProcessor', () => {
|
||||
let ctx = {};
|
||||
|
||||
beforeEach(() => {
|
||||
ctx.datapoints = [
|
||||
[[10, 1500000000000], [2, 1500000001000], [7, 1500000002000], [1, 1500000003000]],
|
||||
[[9, 1500000000000], [3, 1500000001000], [4, 1500000002000], [8, 1500000003000]],
|
||||
];
|
||||
});
|
||||
|
||||
describe('When apply groupBy() functions', () => {
|
||||
it('should return series average', () => {
|
||||
let aggregateBy = dataProcessor.metricFunctions['groupBy'];
|
||||
const avg2s = _.map(ctx.datapoints, (dp) => aggregateBy('2s', 'avg', dp));
|
||||
expect(avg2s).toEqual([
|
||||
[[6, 1500000000000], [4, 1500000002000]],
|
||||
[[6, 1500000000000], [6, 1500000002000]],
|
||||
]);
|
||||
|
||||
const avg10s = _.map(ctx.datapoints, (dp) => aggregateBy('10s', 'avg', dp));
|
||||
expect(avg10s).toEqual([
|
||||
[[5, 1500000000000]],
|
||||
[[6, 1500000000000]],
|
||||
]);
|
||||
|
||||
// not aligned
|
||||
const dp = [[10, 1500000001000], [2, 1500000002000], [7, 1500000003000], [1, 1500000004000]];
|
||||
expect(aggregateBy('2s', 'avg', dp)).toEqual([
|
||||
[10, 1500000000000], [4.5, 1500000002000], [1, 1500000004000]
|
||||
]);
|
||||
});
|
||||
});
|
||||
|
||||
describe('When apply aggregateBy() functions', () => {
|
||||
it('should return series average', () => {
|
||||
let aggregateBy = dataProcessor.metricFunctions['aggregateBy'];
|
||||
const avg1s = aggregateBy('1s', 'avg', ctx.datapoints);
|
||||
expect(avg1s).toEqual([
|
||||
[9.5, 1500000000000], [2.5, 1500000001000], [5.5, 1500000002000], [4.5, 1500000003000]
|
||||
]);
|
||||
|
||||
const avg10s = aggregateBy('10s', 'avg', ctx.datapoints);
|
||||
expect(avg10s).toEqual([
|
||||
[5.5, 1500000000000]
|
||||
]);
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
858
dist/datasource-zabbix/specs/datasource.spec.js
vendored
858
dist/datasource-zabbix/specs/datasource.spec.js
vendored
@@ -1,429 +1,429 @@
|
||||
import _ from 'lodash';
|
||||
import Q, { Promise } from "q";
|
||||
import {Datasource} from "../module";
|
||||
import {zabbixTemplateFormat} from "../datasource";
|
||||
|
||||
describe('ZabbixDatasource', () => {
|
||||
let ctx = {};
|
||||
|
||||
beforeEach(() => {
|
||||
ctx.instanceSettings = {
|
||||
jsonData: {
|
||||
alerting: true,
|
||||
username: 'zabbix',
|
||||
password: 'zabbix',
|
||||
trends: true,
|
||||
trendsFrom: '14d',
|
||||
trendsRange: '7d',
|
||||
dbConnection: {
|
||||
enabled: false
|
||||
}
|
||||
}
|
||||
};
|
||||
ctx.templateSrv = {};
|
||||
ctx.alertSrv = {};
|
||||
ctx.dashboardSrv = {};
|
||||
ctx.zabbixAlertingSrv = {
|
||||
setPanelAlertState: jest.fn(),
|
||||
removeZabbixThreshold: jest.fn(),
|
||||
};
|
||||
ctx.zabbix = () => {};
|
||||
|
||||
ctx.ds = new Datasource(ctx.instanceSettings, ctx.templateSrv, ctx.alertSrv, ctx.dashboardSrv, ctx.zabbixAlertingSrv, ctx.zabbix);
|
||||
});
|
||||
|
||||
describe('When querying data', () => {
|
||||
beforeEach(() => {
|
||||
ctx.ds.replaceTemplateVars = (str) => str;
|
||||
ctx.ds.alertQuery = () => Q.when([]);
|
||||
});
|
||||
|
||||
ctx.options = {
|
||||
targets: [
|
||||
{
|
||||
group: {filter: ""},
|
||||
host: {filter: ""},
|
||||
application: {filter: ""},
|
||||
item: {filter: ""}
|
||||
}
|
||||
],
|
||||
range: {from: 'now-7d', to: 'now'}
|
||||
};
|
||||
|
||||
it('should return an empty array when no targets are set', (done) => {
|
||||
let options = {
|
||||
targets: [],
|
||||
range: {from: 'now-6h', to: 'now'}
|
||||
};
|
||||
ctx.ds.query(options).then(result => {
|
||||
expect(result.data.length).toBe(0);
|
||||
done();
|
||||
});
|
||||
});
|
||||
|
||||
it('should use trends if it enabled and time more than trendsFrom', (done) => {
|
||||
let ranges = ['now-7d', 'now-168h', 'now-1M', 'now-1y'];
|
||||
|
||||
_.forEach(ranges, range => {
|
||||
ctx.options.range.from = range;
|
||||
ctx.ds.queryNumericData = jest.fn();
|
||||
ctx.ds.query(ctx.options);
|
||||
|
||||
// Check that useTrends options is true
|
||||
let callArgs = ctx.ds.queryNumericData.mock.calls[0];
|
||||
expect(callArgs[2]).toBe(true);
|
||||
ctx.ds.queryNumericData.mockClear();
|
||||
});
|
||||
|
||||
done();
|
||||
});
|
||||
|
||||
it('shouldnt use trends if it enabled and time less than trendsFrom', (done) => {
|
||||
let ranges = ['now-6d', 'now-167h', 'now-1h', 'now-30m', 'now-30s'];
|
||||
|
||||
_.forEach(ranges, range => {
|
||||
ctx.options.range.from = range;
|
||||
ctx.ds.queryNumericData = jest.fn();
|
||||
ctx.ds.query(ctx.options);
|
||||
|
||||
// Check that useTrends options is false
|
||||
let callArgs = ctx.ds.queryNumericData.mock.calls[0];
|
||||
expect(callArgs[2]).toBe(false);
|
||||
ctx.ds.queryNumericData.mockClear();
|
||||
});
|
||||
done();
|
||||
});
|
||||
|
||||
});
|
||||
|
||||
describe('When querying text data', () => {
|
||||
beforeEach(() => {
|
||||
ctx.ds.replaceTemplateVars = (str) => str;
|
||||
ctx.ds.alertQuery = () => Q.when([]);
|
||||
ctx.ds.zabbix.getHistory = jest.fn().mockReturnValue(Promise.resolve([
|
||||
{clock: "1500010200", itemid:"10100", ns:"900111000", value:"Linux first"},
|
||||
{clock: "1500010300", itemid:"10100", ns:"900111000", value:"Linux 2nd"},
|
||||
{clock: "1500010400", itemid:"10100", ns:"900111000", value:"Linux last"}
|
||||
]));
|
||||
|
||||
ctx.ds.zabbix.getItemsFromTarget = jest.fn().mockReturnValue(Promise.resolve([
|
||||
{
|
||||
hosts: [{hostid: "10001", name: "Zabbix server"}],
|
||||
itemid: "10100",
|
||||
name: "System information",
|
||||
key_: "system.uname",
|
||||
}
|
||||
]));
|
||||
|
||||
ctx.options = {
|
||||
range: {from: 'now-1h', to: 'now'},
|
||||
targets: [
|
||||
{
|
||||
group: {filter: ""},
|
||||
host: {filter: "Zabbix server"},
|
||||
application: {filter: ""},
|
||||
item: {filter: "System information"},
|
||||
textFilter: "",
|
||||
useCaptureGroups: true,
|
||||
mode: 2,
|
||||
resultFormat: "table",
|
||||
options: {
|
||||
skipEmptyValues: false
|
||||
}
|
||||
}
|
||||
],
|
||||
};
|
||||
});
|
||||
|
||||
it('should return data in table format', (done) => {
|
||||
ctx.ds.query(ctx.options).then(result => {
|
||||
expect(result.data.length).toBe(1);
|
||||
|
||||
let tableData = result.data[0];
|
||||
expect(tableData.columns).toEqual([
|
||||
{text: 'Host'}, {text: 'Item'}, {text: 'Key'}, {text: 'Last value'}
|
||||
]);
|
||||
expect(tableData.rows).toEqual([
|
||||
['Zabbix server', 'System information', 'system.uname', 'Linux last']
|
||||
]);
|
||||
done();
|
||||
});
|
||||
});
|
||||
|
||||
it('should extract value if regex with capture group is used', (done) => {
|
||||
ctx.options.targets[0].textFilter = "Linux (.*)";
|
||||
ctx.ds.query(ctx.options).then(result => {
|
||||
let tableData = result.data[0];
|
||||
expect(tableData.rows[0][3]).toEqual('last');
|
||||
done();
|
||||
});
|
||||
});
|
||||
|
||||
it('should skip item when last value is empty', () => {
|
||||
ctx.ds.zabbix.getItemsFromTarget = jest.fn().mockReturnValue(Promise.resolve([
|
||||
{
|
||||
hosts: [{hostid: "10001", name: "Zabbix server"}],
|
||||
itemid: "10100", name: "System information", key_: "system.uname"
|
||||
},
|
||||
{
|
||||
hosts: [{hostid: "10002", name: "Server02"}],
|
||||
itemid: "90109", name: "System information", key_: "system.uname"
|
||||
}
|
||||
]));
|
||||
|
||||
ctx.options.targets[0].options.skipEmptyValues = true;
|
||||
ctx.ds.zabbix.getHistory = jest.fn().mockReturnValue(Promise.resolve([
|
||||
{clock: "1500010200", itemid:"10100", ns:"900111000", value:"Linux first"},
|
||||
{clock: "1500010300", itemid:"10100", ns:"900111000", value:"Linux 2nd"},
|
||||
{clock: "1500010400", itemid:"10100", ns:"900111000", value:"Linux last"},
|
||||
{clock: "1500010200", itemid:"90109", ns:"900111000", value:"Non empty value"},
|
||||
{clock: "1500010500", itemid:"90109", ns:"900111000", value:""}
|
||||
]));
|
||||
return ctx.ds.query(ctx.options).then(result => {
|
||||
let tableData = result.data[0];
|
||||
expect(tableData.rows.length).toBe(1);
|
||||
expect(tableData.rows[0][3]).toEqual('Linux last');
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
describe('When replacing template variables', () => {
|
||||
|
||||
function testReplacingVariable(target, varValue, expectedResult, done) {
|
||||
ctx.ds.templateSrv.replace = () => {
|
||||
return zabbixTemplateFormat(varValue);
|
||||
};
|
||||
|
||||
let result = ctx.ds.replaceTemplateVars(target);
|
||||
expect(result).toBe(expectedResult);
|
||||
done();
|
||||
}
|
||||
|
||||
/*
|
||||
* Alphanumerics, spaces, dots, dashes and underscores
|
||||
* are allowed in Zabbix host name.
|
||||
* 'AaBbCc0123 .-_'
|
||||
*/
|
||||
it('should return properly escaped regex', (done) => {
|
||||
let target = '$host';
|
||||
let template_var_value = 'AaBbCc0123 .-_';
|
||||
let expected_result = '/^AaBbCc0123 \\.-_$/';
|
||||
|
||||
testReplacingVariable(target, template_var_value, expected_result, done);
|
||||
});
|
||||
|
||||
/*
|
||||
* Single-value variable
|
||||
* $host = backend01
|
||||
* $host => /^backend01|backend01$/
|
||||
*/
|
||||
it('should return proper regex for single value', (done) => {
|
||||
let target = '$host';
|
||||
let template_var_value = 'backend01';
|
||||
let expected_result = '/^backend01$/';
|
||||
|
||||
testReplacingVariable(target, template_var_value, expected_result, done);
|
||||
});
|
||||
|
||||
/*
|
||||
* Multi-value variable
|
||||
* $host = [backend01, backend02]
|
||||
* $host => /^(backend01|backend01)$/
|
||||
*/
|
||||
it('should return proper regex for multi-value', (done) => {
|
||||
let target = '$host';
|
||||
let template_var_value = ['backend01', 'backend02'];
|
||||
let expected_result = '/^(backend01|backend02)$/';
|
||||
|
||||
testReplacingVariable(target, template_var_value, expected_result, done);
|
||||
});
|
||||
});
|
||||
|
||||
describe('When invoking metricFindQuery()', () => {
|
||||
beforeEach(() => {
|
||||
ctx.ds.replaceTemplateVars = (str) => str;
|
||||
ctx.ds.zabbix = {
|
||||
getGroups: jest.fn().mockReturnValue(Q.when([])),
|
||||
getHosts: jest.fn().mockReturnValue(Q.when([])),
|
||||
getApps: jest.fn().mockReturnValue(Q.when([])),
|
||||
getItems: jest.fn().mockReturnValue(Q.when([]))
|
||||
};
|
||||
});
|
||||
|
||||
it('should return groups', (done) => {
|
||||
const tests = [
|
||||
{query: '*', expect: '/.*/'},
|
||||
{query: '', expect: ''},
|
||||
{query: 'Backend', expect: 'Backend'},
|
||||
{query: 'Back*', expect: 'Back*'},
|
||||
];
|
||||
|
||||
for (const test of tests) {
|
||||
ctx.ds.metricFindQuery(test.query);
|
||||
expect(ctx.ds.zabbix.getGroups).toBeCalledWith(test.expect);
|
||||
ctx.ds.zabbix.getGroups.mockClear();
|
||||
}
|
||||
done();
|
||||
});
|
||||
|
||||
it('should return hosts', (done) => {
|
||||
const tests = [
|
||||
{query: '*.*', expect: ['/.*/', '/.*/']},
|
||||
{query: '.', expect: ['', '']},
|
||||
{query: 'Backend.*', expect: ['Backend', '/.*/']},
|
||||
{query: 'Back*.', expect: ['Back*', '']},
|
||||
];
|
||||
|
||||
for (const test of tests) {
|
||||
ctx.ds.metricFindQuery(test.query);
|
||||
expect(ctx.ds.zabbix.getHosts).toBeCalledWith(test.expect[0], test.expect[1]);
|
||||
ctx.ds.zabbix.getHosts.mockClear();
|
||||
}
|
||||
done();
|
||||
});
|
||||
|
||||
it('should return applications', (done) => {
|
||||
const tests = [
|
||||
{query: '*.*.*', expect: ['/.*/', '/.*/', '/.*/']},
|
||||
{query: '.*.', expect: ['', '/.*/', '']},
|
||||
{query: 'Backend.backend01.*', expect: ['Backend', 'backend01', '/.*/']},
|
||||
{query: 'Back*.*.', expect: ['Back*', '/.*/', '']}
|
||||
];
|
||||
|
||||
for (const test of tests) {
|
||||
ctx.ds.metricFindQuery(test.query);
|
||||
expect(ctx.ds.zabbix.getApps).toBeCalledWith(test.expect[0], test.expect[1], test.expect[2]);
|
||||
ctx.ds.zabbix.getApps.mockClear();
|
||||
}
|
||||
done();
|
||||
});
|
||||
|
||||
it('should return items', (done) => {
|
||||
const tests = [
|
||||
{query: '*.*.*.*', expect: ['/.*/', '/.*/', '', '/.*/']},
|
||||
{query: '.*.*.*', expect: ['', '/.*/', '', '/.*/']},
|
||||
{query: 'Backend.backend01.*.*', expect: ['Backend', 'backend01', '', '/.*/']},
|
||||
{query: 'Back*.*.cpu.*', expect: ['Back*', '/.*/', 'cpu', '/.*/']}
|
||||
];
|
||||
|
||||
for (const test of tests) {
|
||||
ctx.ds.metricFindQuery(test.query);
|
||||
expect(ctx.ds.zabbix.getItems)
|
||||
.toBeCalledWith(test.expect[0], test.expect[1], test.expect[2], test.expect[3]);
|
||||
ctx.ds.zabbix.getItems.mockClear();
|
||||
}
|
||||
done();
|
||||
});
|
||||
|
||||
it('should invoke method with proper arguments', (done) => {
|
||||
let query = '*.*';
|
||||
|
||||
ctx.ds.metricFindQuery(query);
|
||||
expect(ctx.ds.zabbix.getHosts).toBeCalledWith('/.*/', '/.*/');
|
||||
done();
|
||||
});
|
||||
});
|
||||
|
||||
describe('When querying alerts', () => {
|
||||
let options = {};
|
||||
|
||||
beforeEach(() => {
|
||||
ctx.ds.replaceTemplateVars = (str) => str;
|
||||
|
||||
let targetItems = [{
|
||||
"itemid": "1",
|
||||
"name": "test item",
|
||||
"key_": "test.key",
|
||||
"value_type": "3",
|
||||
"hostid": "10631",
|
||||
"status": "0",
|
||||
"state": "0",
|
||||
"hosts": [{"hostid": "10631", "name": "Test host"}],
|
||||
"item": "Test item"
|
||||
}];
|
||||
ctx.ds.zabbix.getItemsFromTarget = () => Promise.resolve(targetItems);
|
||||
|
||||
options = {
|
||||
"panelId": 10,
|
||||
"targets": [{
|
||||
"application": {"filter": ""},
|
||||
"group": {"filter": "Test group"},
|
||||
"host": {"filter": "Test host"},
|
||||
"item": {"filter": "Test item"},
|
||||
}]
|
||||
};
|
||||
});
|
||||
|
||||
it('should return threshold when comparative symbol is `less than`', () => {
|
||||
|
||||
let itemTriggers = [{
|
||||
"triggerid": "15383",
|
||||
"priority": "4",
|
||||
"expression": "{15915}<100",
|
||||
}];
|
||||
|
||||
ctx.ds.zabbix.getAlerts = () => Promise.resolve(itemTriggers);
|
||||
|
||||
return ctx.ds.alertQuery(options)
|
||||
.then(resp => {
|
||||
expect(resp.thresholds).toHaveLength(1);
|
||||
expect(resp.thresholds[0]).toBe(100);
|
||||
return resp;
|
||||
});
|
||||
});
|
||||
|
||||
it('should return threshold when comparative symbol is `less than or equal`', () => {
|
||||
|
||||
let itemTriggers = [{
|
||||
"triggerid": "15383",
|
||||
"priority": "4",
|
||||
"expression": "{15915}<=100",
|
||||
}];
|
||||
|
||||
ctx.ds.zabbix.getAlerts = () => Promise.resolve(itemTriggers);
|
||||
|
||||
return ctx.ds.alertQuery(options)
|
||||
.then(resp => {
|
||||
expect(resp.thresholds.length).toBe(1);
|
||||
expect(resp.thresholds[0]).toBe(100);
|
||||
return resp;
|
||||
});
|
||||
});
|
||||
|
||||
it('should return threshold when comparative symbol is `greater than or equal`', () => {
|
||||
|
||||
let itemTriggers = [{
|
||||
"triggerid": "15383",
|
||||
"priority": "4",
|
||||
"expression": "{15915}>=30",
|
||||
}];
|
||||
|
||||
ctx.ds.zabbix.getAlerts = () => Promise.resolve(itemTriggers);
|
||||
|
||||
return ctx.ds.alertQuery(options)
|
||||
.then(resp => {
|
||||
expect(resp.thresholds.length).toBe(1);
|
||||
expect(resp.thresholds[0]).toBe(30);
|
||||
return resp;
|
||||
});
|
||||
});
|
||||
|
||||
it('should return threshold when comparative symbol is `equal`', () => {
|
||||
|
||||
let itemTriggers = [{
|
||||
"triggerid": "15383",
|
||||
"priority": "4",
|
||||
"expression": "{15915}=50",
|
||||
}];
|
||||
|
||||
ctx.ds.zabbix.getAlerts = () => Promise.resolve(itemTriggers);
|
||||
|
||||
return ctx.ds.alertQuery(options)
|
||||
.then(resp => {
|
||||
expect(resp.thresholds.length).toBe(1);
|
||||
expect(resp.thresholds[0]).toBe(50);
|
||||
return resp;
|
||||
});
|
||||
});
|
||||
});
|
||||
});
|
||||
import _ from 'lodash';
|
||||
import Q, { Promise } from "q";
|
||||
import {Datasource} from "../module";
|
||||
import {zabbixTemplateFormat} from "../datasource";
|
||||
|
||||
describe('ZabbixDatasource', () => {
|
||||
let ctx = {};
|
||||
|
||||
beforeEach(() => {
|
||||
ctx.instanceSettings = {
|
||||
jsonData: {
|
||||
alerting: true,
|
||||
username: 'zabbix',
|
||||
password: 'zabbix',
|
||||
trends: true,
|
||||
trendsFrom: '14d',
|
||||
trendsRange: '7d',
|
||||
dbConnection: {
|
||||
enabled: false
|
||||
}
|
||||
}
|
||||
};
|
||||
ctx.templateSrv = {};
|
||||
ctx.alertSrv = {};
|
||||
ctx.dashboardSrv = {};
|
||||
ctx.zabbixAlertingSrv = {
|
||||
setPanelAlertState: jest.fn(),
|
||||
removeZabbixThreshold: jest.fn(),
|
||||
};
|
||||
ctx.zabbix = () => {};
|
||||
|
||||
ctx.ds = new Datasource(ctx.instanceSettings, ctx.templateSrv, ctx.alertSrv, ctx.dashboardSrv, ctx.zabbixAlertingSrv, ctx.zabbix);
|
||||
});
|
||||
|
||||
describe('When querying data', () => {
|
||||
beforeEach(() => {
|
||||
ctx.ds.replaceTemplateVars = (str) => str;
|
||||
ctx.ds.alertQuery = () => Q.when([]);
|
||||
});
|
||||
|
||||
ctx.options = {
|
||||
targets: [
|
||||
{
|
||||
group: {filter: ""},
|
||||
host: {filter: ""},
|
||||
application: {filter: ""},
|
||||
item: {filter: ""}
|
||||
}
|
||||
],
|
||||
range: {from: 'now-7d', to: 'now'}
|
||||
};
|
||||
|
||||
it('should return an empty array when no targets are set', (done) => {
|
||||
let options = {
|
||||
targets: [],
|
||||
range: {from: 'now-6h', to: 'now'}
|
||||
};
|
||||
ctx.ds.query(options).then(result => {
|
||||
expect(result.data.length).toBe(0);
|
||||
done();
|
||||
});
|
||||
});
|
||||
|
||||
it('should use trends if it enabled and time more than trendsFrom', (done) => {
|
||||
let ranges = ['now-7d', 'now-168h', 'now-1M', 'now-1y'];
|
||||
|
||||
_.forEach(ranges, range => {
|
||||
ctx.options.range.from = range;
|
||||
ctx.ds.queryNumericData = jest.fn();
|
||||
ctx.ds.query(ctx.options);
|
||||
|
||||
// Check that useTrends options is true
|
||||
let callArgs = ctx.ds.queryNumericData.mock.calls[0];
|
||||
expect(callArgs[2]).toBe(true);
|
||||
ctx.ds.queryNumericData.mockClear();
|
||||
});
|
||||
|
||||
done();
|
||||
});
|
||||
|
||||
it('shouldnt use trends if it enabled and time less than trendsFrom', (done) => {
|
||||
let ranges = ['now-6d', 'now-167h', 'now-1h', 'now-30m', 'now-30s'];
|
||||
|
||||
_.forEach(ranges, range => {
|
||||
ctx.options.range.from = range;
|
||||
ctx.ds.queryNumericData = jest.fn();
|
||||
ctx.ds.query(ctx.options);
|
||||
|
||||
// Check that useTrends options is false
|
||||
let callArgs = ctx.ds.queryNumericData.mock.calls[0];
|
||||
expect(callArgs[2]).toBe(false);
|
||||
ctx.ds.queryNumericData.mockClear();
|
||||
});
|
||||
done();
|
||||
});
|
||||
|
||||
});
|
||||
|
||||
describe('When querying text data', () => {
|
||||
beforeEach(() => {
|
||||
ctx.ds.replaceTemplateVars = (str) => str;
|
||||
ctx.ds.alertQuery = () => Q.when([]);
|
||||
ctx.ds.zabbix.getHistory = jest.fn().mockReturnValue(Promise.resolve([
|
||||
{clock: "1500010200", itemid:"10100", ns:"900111000", value:"Linux first"},
|
||||
{clock: "1500010300", itemid:"10100", ns:"900111000", value:"Linux 2nd"},
|
||||
{clock: "1500010400", itemid:"10100", ns:"900111000", value:"Linux last"}
|
||||
]));
|
||||
|
||||
ctx.ds.zabbix.getItemsFromTarget = jest.fn().mockReturnValue(Promise.resolve([
|
||||
{
|
||||
hosts: [{hostid: "10001", name: "Zabbix server"}],
|
||||
itemid: "10100",
|
||||
name: "System information",
|
||||
key_: "system.uname",
|
||||
}
|
||||
]));
|
||||
|
||||
ctx.options = {
|
||||
range: {from: 'now-1h', to: 'now'},
|
||||
targets: [
|
||||
{
|
||||
group: {filter: ""},
|
||||
host: {filter: "Zabbix server"},
|
||||
application: {filter: ""},
|
||||
item: {filter: "System information"},
|
||||
textFilter: "",
|
||||
useCaptureGroups: true,
|
||||
mode: 2,
|
||||
resultFormat: "table",
|
||||
options: {
|
||||
skipEmptyValues: false
|
||||
}
|
||||
}
|
||||
],
|
||||
};
|
||||
});
|
||||
|
||||
it('should return data in table format', (done) => {
|
||||
ctx.ds.query(ctx.options).then(result => {
|
||||
expect(result.data.length).toBe(1);
|
||||
|
||||
let tableData = result.data[0];
|
||||
expect(tableData.columns).toEqual([
|
||||
{text: 'Host'}, {text: 'Item'}, {text: 'Key'}, {text: 'Last value'}
|
||||
]);
|
||||
expect(tableData.rows).toEqual([
|
||||
['Zabbix server', 'System information', 'system.uname', 'Linux last']
|
||||
]);
|
||||
done();
|
||||
});
|
||||
});
|
||||
|
||||
it('should extract value if regex with capture group is used', (done) => {
|
||||
ctx.options.targets[0].textFilter = "Linux (.*)";
|
||||
ctx.ds.query(ctx.options).then(result => {
|
||||
let tableData = result.data[0];
|
||||
expect(tableData.rows[0][3]).toEqual('last');
|
||||
done();
|
||||
});
|
||||
});
|
||||
|
||||
it('should skip item when last value is empty', () => {
|
||||
ctx.ds.zabbix.getItemsFromTarget = jest.fn().mockReturnValue(Promise.resolve([
|
||||
{
|
||||
hosts: [{hostid: "10001", name: "Zabbix server"}],
|
||||
itemid: "10100", name: "System information", key_: "system.uname"
|
||||
},
|
||||
{
|
||||
hosts: [{hostid: "10002", name: "Server02"}],
|
||||
itemid: "90109", name: "System information", key_: "system.uname"
|
||||
}
|
||||
]));
|
||||
|
||||
ctx.options.targets[0].options.skipEmptyValues = true;
|
||||
ctx.ds.zabbix.getHistory = jest.fn().mockReturnValue(Promise.resolve([
|
||||
{clock: "1500010200", itemid:"10100", ns:"900111000", value:"Linux first"},
|
||||
{clock: "1500010300", itemid:"10100", ns:"900111000", value:"Linux 2nd"},
|
||||
{clock: "1500010400", itemid:"10100", ns:"900111000", value:"Linux last"},
|
||||
{clock: "1500010200", itemid:"90109", ns:"900111000", value:"Non empty value"},
|
||||
{clock: "1500010500", itemid:"90109", ns:"900111000", value:""}
|
||||
]));
|
||||
return ctx.ds.query(ctx.options).then(result => {
|
||||
let tableData = result.data[0];
|
||||
expect(tableData.rows.length).toBe(1);
|
||||
expect(tableData.rows[0][3]).toEqual('Linux last');
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
describe('When replacing template variables', () => {
|
||||
|
||||
function testReplacingVariable(target, varValue, expectedResult, done) {
|
||||
ctx.ds.templateSrv.replace = () => {
|
||||
return zabbixTemplateFormat(varValue);
|
||||
};
|
||||
|
||||
let result = ctx.ds.replaceTemplateVars(target);
|
||||
expect(result).toBe(expectedResult);
|
||||
done();
|
||||
}
|
||||
|
||||
/*
|
||||
* Alphanumerics, spaces, dots, dashes and underscores
|
||||
* are allowed in Zabbix host name.
|
||||
* 'AaBbCc0123 .-_'
|
||||
*/
|
||||
it('should return properly escaped regex', (done) => {
|
||||
let target = '$host';
|
||||
let template_var_value = 'AaBbCc0123 .-_';
|
||||
let expected_result = '/^AaBbCc0123 \\.-_$/';
|
||||
|
||||
testReplacingVariable(target, template_var_value, expected_result, done);
|
||||
});
|
||||
|
||||
/*
|
||||
* Single-value variable
|
||||
* $host = backend01
|
||||
* $host => /^backend01|backend01$/
|
||||
*/
|
||||
it('should return proper regex for single value', (done) => {
|
||||
let target = '$host';
|
||||
let template_var_value = 'backend01';
|
||||
let expected_result = '/^backend01$/';
|
||||
|
||||
testReplacingVariable(target, template_var_value, expected_result, done);
|
||||
});
|
||||
|
||||
/*
|
||||
* Multi-value variable
|
||||
* $host = [backend01, backend02]
|
||||
* $host => /^(backend01|backend01)$/
|
||||
*/
|
||||
it('should return proper regex for multi-value', (done) => {
|
||||
let target = '$host';
|
||||
let template_var_value = ['backend01', 'backend02'];
|
||||
let expected_result = '/^(backend01|backend02)$/';
|
||||
|
||||
testReplacingVariable(target, template_var_value, expected_result, done);
|
||||
});
|
||||
});
|
||||
|
||||
describe('When invoking metricFindQuery()', () => {
|
||||
beforeEach(() => {
|
||||
ctx.ds.replaceTemplateVars = (str) => str;
|
||||
ctx.ds.zabbix = {
|
||||
getGroups: jest.fn().mockReturnValue(Q.when([])),
|
||||
getHosts: jest.fn().mockReturnValue(Q.when([])),
|
||||
getApps: jest.fn().mockReturnValue(Q.when([])),
|
||||
getItems: jest.fn().mockReturnValue(Q.when([]))
|
||||
};
|
||||
});
|
||||
|
||||
it('should return groups', (done) => {
|
||||
const tests = [
|
||||
{query: '*', expect: '/.*/'},
|
||||
{query: '', expect: ''},
|
||||
{query: 'Backend', expect: 'Backend'},
|
||||
{query: 'Back*', expect: 'Back*'},
|
||||
];
|
||||
|
||||
for (const test of tests) {
|
||||
ctx.ds.metricFindQuery(test.query);
|
||||
expect(ctx.ds.zabbix.getGroups).toBeCalledWith(test.expect);
|
||||
ctx.ds.zabbix.getGroups.mockClear();
|
||||
}
|
||||
done();
|
||||
});
|
||||
|
||||
it('should return hosts', (done) => {
|
||||
const tests = [
|
||||
{query: '*.*', expect: ['/.*/', '/.*/']},
|
||||
{query: '.', expect: ['', '']},
|
||||
{query: 'Backend.*', expect: ['Backend', '/.*/']},
|
||||
{query: 'Back*.', expect: ['Back*', '']},
|
||||
];
|
||||
|
||||
for (const test of tests) {
|
||||
ctx.ds.metricFindQuery(test.query);
|
||||
expect(ctx.ds.zabbix.getHosts).toBeCalledWith(test.expect[0], test.expect[1]);
|
||||
ctx.ds.zabbix.getHosts.mockClear();
|
||||
}
|
||||
done();
|
||||
});
|
||||
|
||||
it('should return applications', (done) => {
|
||||
const tests = [
|
||||
{query: '*.*.*', expect: ['/.*/', '/.*/', '/.*/']},
|
||||
{query: '.*.', expect: ['', '/.*/', '']},
|
||||
{query: 'Backend.backend01.*', expect: ['Backend', 'backend01', '/.*/']},
|
||||
{query: 'Back*.*.', expect: ['Back*', '/.*/', '']}
|
||||
];
|
||||
|
||||
for (const test of tests) {
|
||||
ctx.ds.metricFindQuery(test.query);
|
||||
expect(ctx.ds.zabbix.getApps).toBeCalledWith(test.expect[0], test.expect[1], test.expect[2]);
|
||||
ctx.ds.zabbix.getApps.mockClear();
|
||||
}
|
||||
done();
|
||||
});
|
||||
|
||||
it('should return items', (done) => {
|
||||
const tests = [
|
||||
{query: '*.*.*.*', expect: ['/.*/', '/.*/', '', '/.*/']},
|
||||
{query: '.*.*.*', expect: ['', '/.*/', '', '/.*/']},
|
||||
{query: 'Backend.backend01.*.*', expect: ['Backend', 'backend01', '', '/.*/']},
|
||||
{query: 'Back*.*.cpu.*', expect: ['Back*', '/.*/', 'cpu', '/.*/']}
|
||||
];
|
||||
|
||||
for (const test of tests) {
|
||||
ctx.ds.metricFindQuery(test.query);
|
||||
expect(ctx.ds.zabbix.getItems)
|
||||
.toBeCalledWith(test.expect[0], test.expect[1], test.expect[2], test.expect[3]);
|
||||
ctx.ds.zabbix.getItems.mockClear();
|
||||
}
|
||||
done();
|
||||
});
|
||||
|
||||
it('should invoke method with proper arguments', (done) => {
|
||||
let query = '*.*';
|
||||
|
||||
ctx.ds.metricFindQuery(query);
|
||||
expect(ctx.ds.zabbix.getHosts).toBeCalledWith('/.*/', '/.*/');
|
||||
done();
|
||||
});
|
||||
});
|
||||
|
||||
describe('When querying alerts', () => {
|
||||
let options = {};
|
||||
|
||||
beforeEach(() => {
|
||||
ctx.ds.replaceTemplateVars = (str) => str;
|
||||
|
||||
let targetItems = [{
|
||||
"itemid": "1",
|
||||
"name": "test item",
|
||||
"key_": "test.key",
|
||||
"value_type": "3",
|
||||
"hostid": "10631",
|
||||
"status": "0",
|
||||
"state": "0",
|
||||
"hosts": [{"hostid": "10631", "name": "Test host"}],
|
||||
"item": "Test item"
|
||||
}];
|
||||
ctx.ds.zabbix.getItemsFromTarget = () => Promise.resolve(targetItems);
|
||||
|
||||
options = {
|
||||
"panelId": 10,
|
||||
"targets": [{
|
||||
"application": {"filter": ""},
|
||||
"group": {"filter": "Test group"},
|
||||
"host": {"filter": "Test host"},
|
||||
"item": {"filter": "Test item"},
|
||||
}]
|
||||
};
|
||||
});
|
||||
|
||||
it('should return threshold when comparative symbol is `less than`', () => {
|
||||
|
||||
let itemTriggers = [{
|
||||
"triggerid": "15383",
|
||||
"priority": "4",
|
||||
"expression": "{15915}<100",
|
||||
}];
|
||||
|
||||
ctx.ds.zabbix.getAlerts = () => Promise.resolve(itemTriggers);
|
||||
|
||||
return ctx.ds.alertQuery(options)
|
||||
.then(resp => {
|
||||
expect(resp.thresholds).toHaveLength(1);
|
||||
expect(resp.thresholds[0]).toBe(100);
|
||||
return resp;
|
||||
});
|
||||
});
|
||||
|
||||
it('should return threshold when comparative symbol is `less than or equal`', () => {
|
||||
|
||||
let itemTriggers = [{
|
||||
"triggerid": "15383",
|
||||
"priority": "4",
|
||||
"expression": "{15915}<=100",
|
||||
}];
|
||||
|
||||
ctx.ds.zabbix.getAlerts = () => Promise.resolve(itemTriggers);
|
||||
|
||||
return ctx.ds.alertQuery(options)
|
||||
.then(resp => {
|
||||
expect(resp.thresholds.length).toBe(1);
|
||||
expect(resp.thresholds[0]).toBe(100);
|
||||
return resp;
|
||||
});
|
||||
});
|
||||
|
||||
it('should return threshold when comparative symbol is `greater than or equal`', () => {
|
||||
|
||||
let itemTriggers = [{
|
||||
"triggerid": "15383",
|
||||
"priority": "4",
|
||||
"expression": "{15915}>=30",
|
||||
}];
|
||||
|
||||
ctx.ds.zabbix.getAlerts = () => Promise.resolve(itemTriggers);
|
||||
|
||||
return ctx.ds.alertQuery(options)
|
||||
.then(resp => {
|
||||
expect(resp.thresholds.length).toBe(1);
|
||||
expect(resp.thresholds[0]).toBe(30);
|
||||
return resp;
|
||||
});
|
||||
});
|
||||
|
||||
it('should return threshold when comparative symbol is `equal`', () => {
|
||||
|
||||
let itemTriggers = [{
|
||||
"triggerid": "15383",
|
||||
"priority": "4",
|
||||
"expression": "{15915}=50",
|
||||
}];
|
||||
|
||||
ctx.ds.zabbix.getAlerts = () => Promise.resolve(itemTriggers);
|
||||
|
||||
return ctx.ds.alertQuery(options)
|
||||
.then(resp => {
|
||||
expect(resp.thresholds.length).toBe(1);
|
||||
expect(resp.thresholds[0]).toBe(50);
|
||||
return resp;
|
||||
});
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
68
dist/datasource-zabbix/specs/timeseries.spec.js
vendored
68
dist/datasource-zabbix/specs/timeseries.spec.js
vendored
@@ -1,34 +1,34 @@
|
||||
// import _ from 'lodash';
|
||||
import ts from '../timeseries';
|
||||
|
||||
describe('timeseries processing functions', () => {
|
||||
|
||||
describe('sumSeries()', () => {
|
||||
it('should properly sum series', (done) => {
|
||||
let series = [
|
||||
[[0, 1], [1, 2], [1, 3]],
|
||||
[[2, 1], [3, 2], [4, 3]]
|
||||
];
|
||||
|
||||
let expected = [[2, 1], [4, 2], [5, 3]];
|
||||
|
||||
let result = ts.sumSeries(series);
|
||||
expect(result).toEqual(expected);
|
||||
done();
|
||||
});
|
||||
|
||||
it('should properly sum series with nulls', (done) => {
|
||||
// issue #286
|
||||
let series = [
|
||||
[[1, 1], [1, 2], [1, 3]],
|
||||
[[3, 2], [4, 3]]
|
||||
];
|
||||
|
||||
let expected = [[1, 1], [4, 2], [5, 3]];
|
||||
|
||||
let result = ts.sumSeries(series);
|
||||
expect(result).toEqual(expected);
|
||||
done();
|
||||
});
|
||||
});
|
||||
});
|
||||
// import _ from 'lodash';
|
||||
import ts from '../timeseries';
|
||||
|
||||
describe('timeseries processing functions', () => {
|
||||
|
||||
describe('sumSeries()', () => {
|
||||
it('should properly sum series', (done) => {
|
||||
let series = [
|
||||
[[0, 1], [1, 2], [1, 3]],
|
||||
[[2, 1], [3, 2], [4, 3]]
|
||||
];
|
||||
|
||||
let expected = [[2, 1], [4, 2], [5, 3]];
|
||||
|
||||
let result = ts.sumSeries(series);
|
||||
expect(result).toEqual(expected);
|
||||
done();
|
||||
});
|
||||
|
||||
it('should properly sum series with nulls', (done) => {
|
||||
// issue #286
|
||||
let series = [
|
||||
[[1, 1], [1, 2], [1, 3]],
|
||||
[[3, 2], [4, 3]]
|
||||
];
|
||||
|
||||
let expected = [[1, 1], [4, 2], [5, 3]];
|
||||
|
||||
let result = ts.sumSeries(series);
|
||||
expect(result).toEqual(expected);
|
||||
done();
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
282
dist/datasource-zabbix/specs/utils.spec.js
vendored
282
dist/datasource-zabbix/specs/utils.spec.js
vendored
@@ -1,141 +1,141 @@
|
||||
import _ from 'lodash';
|
||||
import * as utils from '../utils';
|
||||
|
||||
describe('Utils', () => {
|
||||
|
||||
describe('expandItemName()', () => {
|
||||
|
||||
it('should properly expand unquoted params', (done) => {
|
||||
let test_cases = [
|
||||
{
|
||||
name: `CPU $2 time`,
|
||||
key: `system.cpu.util[,user,avg1]`,
|
||||
expected: "CPU user time"
|
||||
},
|
||||
{
|
||||
name: `CPU $2 time - $3`,
|
||||
key: `system.cpu.util[,system,avg1]`,
|
||||
expected: "CPU system time - avg1"
|
||||
},
|
||||
{
|
||||
name: `CPU - $1 - $2 - $3`,
|
||||
key: `system.cpu.util[,system,avg1]`,
|
||||
expected: "CPU - - system - avg1"
|
||||
}
|
||||
];
|
||||
|
||||
_.each(test_cases, test_case => {
|
||||
let expandedName = utils.expandItemName(test_case.name, test_case.key);
|
||||
expect(expandedName).toBe(test_case.expected);
|
||||
});
|
||||
done();
|
||||
});
|
||||
|
||||
it('should properly expand quoted params with commas', (done) => {
|
||||
let test_cases = [
|
||||
{
|
||||
name: `CPU $2 time`,
|
||||
key: `system.cpu.util["type=user,value=avg",user]`,
|
||||
expected: "CPU user time"
|
||||
},
|
||||
{
|
||||
name: `CPU $1 time`,
|
||||
key: `system.cpu.util["type=user,value=avg","user"]`,
|
||||
expected: "CPU type=user,value=avg time"
|
||||
},
|
||||
{
|
||||
name: `CPU $1 time $3`,
|
||||
key: `system.cpu.util["type=user,value=avg",,"user"]`,
|
||||
expected: "CPU type=user,value=avg time user"
|
||||
},
|
||||
{
|
||||
name: `CPU $1 $2 $3`,
|
||||
key: `system.cpu.util["type=user,value=avg",time,"user"]`,
|
||||
expected: "CPU type=user,value=avg time user"
|
||||
}
|
||||
];
|
||||
|
||||
_.each(test_cases, test_case => {
|
||||
let expandedName = utils.expandItemName(test_case.name, test_case.key);
|
||||
expect(expandedName).toBe(test_case.expected);
|
||||
});
|
||||
done();
|
||||
});
|
||||
|
||||
it('should properly expand array params', (done) => {
|
||||
let test_cases = [
|
||||
{
|
||||
name: `CPU $2 - $3 time`,
|
||||
key: `system.cpu.util[,[user,system],avg1]`,
|
||||
expected: "CPU user,system - avg1 time"
|
||||
},
|
||||
{
|
||||
name: `CPU $2 - $3 time`,
|
||||
key: `system.cpu.util[,["user,system",iowait],avg1]`,
|
||||
expected: `CPU "user,system",iowait - avg1 time`
|
||||
},
|
||||
{
|
||||
name: `CPU - $2 - $3 - $4`,
|
||||
key: `system.cpu.util[,[],["user,system",iowait],avg1]`,
|
||||
expected: `CPU - - "user,system",iowait - avg1`
|
||||
}
|
||||
];
|
||||
|
||||
_.each(test_cases, test_case => {
|
||||
let expandedName = utils.expandItemName(test_case.name, test_case.key);
|
||||
expect(expandedName).toBe(test_case.expected);
|
||||
});
|
||||
done();
|
||||
});
|
||||
});
|
||||
|
||||
describe('splitTemplateQuery()', () => {
|
||||
|
||||
// Backward compatibility
|
||||
it('should properly split query in old format', (done) => {
|
||||
let test_cases = [
|
||||
{
|
||||
query: `/alu/./tw-(nyc|que|brx|dwt|brk)-sta_(\w|\d)*-alu-[0-9{2}/`,
|
||||
expected: ['/alu/', '/tw-(nyc|que|brx|dwt|brk)-sta_(\w|\d)*-alu-[0-9{2}/']
|
||||
},
|
||||
{
|
||||
query: `a.b.c.d`,
|
||||
expected: ['a', 'b', 'c', 'd']
|
||||
}
|
||||
];
|
||||
|
||||
_.each(test_cases, test_case => {
|
||||
let splitQuery = utils.splitTemplateQuery(test_case.query);
|
||||
expect(splitQuery).toEqual(test_case.expected);
|
||||
});
|
||||
done();
|
||||
});
|
||||
|
||||
it('should properly split query', (done) => {
|
||||
let test_cases = [
|
||||
{
|
||||
query: `{alu}{/tw-(nyc|que|brx|dwt|brk)-sta_(\w|\d)*-alu-[0-9]*/}`,
|
||||
expected: ['alu', '/tw-(nyc|que|brx|dwt|brk)-sta_(\w|\d)*-alu-[0-9]*/']
|
||||
},
|
||||
{
|
||||
query: `{alu}{/tw-(nyc|que|brx|dwt|brk)-sta_(\w|\d)*-alu-[0-9]{2}/}`,
|
||||
expected: ['alu', '/tw-(nyc|que|brx|dwt|brk)-sta_(\w|\d)*-alu-[0-9]{2}/']
|
||||
},
|
||||
{
|
||||
query: `{a}{b}{c}{d}`,
|
||||
expected: ['a', 'b', 'c', 'd']
|
||||
},
|
||||
{
|
||||
query: `{a}{b.c.d}`,
|
||||
expected: ['a', 'b.c.d']
|
||||
}
|
||||
];
|
||||
|
||||
_.each(test_cases, test_case => {
|
||||
let splitQuery = utils.splitTemplateQuery(test_case.query);
|
||||
expect(splitQuery).toEqual(test_case.expected);
|
||||
});
|
||||
done();
|
||||
});
|
||||
});
|
||||
});
|
||||
import _ from 'lodash';
|
||||
import * as utils from '../utils';
|
||||
|
||||
describe('Utils', () => {
|
||||
|
||||
describe('expandItemName()', () => {
|
||||
|
||||
it('should properly expand unquoted params', (done) => {
|
||||
let test_cases = [
|
||||
{
|
||||
name: `CPU $2 time`,
|
||||
key: `system.cpu.util[,user,avg1]`,
|
||||
expected: "CPU user time"
|
||||
},
|
||||
{
|
||||
name: `CPU $2 time - $3`,
|
||||
key: `system.cpu.util[,system,avg1]`,
|
||||
expected: "CPU system time - avg1"
|
||||
},
|
||||
{
|
||||
name: `CPU - $1 - $2 - $3`,
|
||||
key: `system.cpu.util[,system,avg1]`,
|
||||
expected: "CPU - - system - avg1"
|
||||
}
|
||||
];
|
||||
|
||||
_.each(test_cases, test_case => {
|
||||
let expandedName = utils.expandItemName(test_case.name, test_case.key);
|
||||
expect(expandedName).toBe(test_case.expected);
|
||||
});
|
||||
done();
|
||||
});
|
||||
|
||||
it('should properly expand quoted params with commas', (done) => {
|
||||
let test_cases = [
|
||||
{
|
||||
name: `CPU $2 time`,
|
||||
key: `system.cpu.util["type=user,value=avg",user]`,
|
||||
expected: "CPU user time"
|
||||
},
|
||||
{
|
||||
name: `CPU $1 time`,
|
||||
key: `system.cpu.util["type=user,value=avg","user"]`,
|
||||
expected: "CPU type=user,value=avg time"
|
||||
},
|
||||
{
|
||||
name: `CPU $1 time $3`,
|
||||
key: `system.cpu.util["type=user,value=avg",,"user"]`,
|
||||
expected: "CPU type=user,value=avg time user"
|
||||
},
|
||||
{
|
||||
name: `CPU $1 $2 $3`,
|
||||
key: `system.cpu.util["type=user,value=avg",time,"user"]`,
|
||||
expected: "CPU type=user,value=avg time user"
|
||||
}
|
||||
];
|
||||
|
||||
_.each(test_cases, test_case => {
|
||||
let expandedName = utils.expandItemName(test_case.name, test_case.key);
|
||||
expect(expandedName).toBe(test_case.expected);
|
||||
});
|
||||
done();
|
||||
});
|
||||
|
||||
it('should properly expand array params', (done) => {
|
||||
let test_cases = [
|
||||
{
|
||||
name: `CPU $2 - $3 time`,
|
||||
key: `system.cpu.util[,[user,system],avg1]`,
|
||||
expected: "CPU user,system - avg1 time"
|
||||
},
|
||||
{
|
||||
name: `CPU $2 - $3 time`,
|
||||
key: `system.cpu.util[,["user,system",iowait],avg1]`,
|
||||
expected: `CPU "user,system",iowait - avg1 time`
|
||||
},
|
||||
{
|
||||
name: `CPU - $2 - $3 - $4`,
|
||||
key: `system.cpu.util[,[],["user,system",iowait],avg1]`,
|
||||
expected: `CPU - - "user,system",iowait - avg1`
|
||||
}
|
||||
];
|
||||
|
||||
_.each(test_cases, test_case => {
|
||||
let expandedName = utils.expandItemName(test_case.name, test_case.key);
|
||||
expect(expandedName).toBe(test_case.expected);
|
||||
});
|
||||
done();
|
||||
});
|
||||
});
|
||||
|
||||
describe('splitTemplateQuery()', () => {
|
||||
|
||||
// Backward compatibility
|
||||
it('should properly split query in old format', (done) => {
|
||||
let test_cases = [
|
||||
{
|
||||
query: `/alu/./tw-(nyc|que|brx|dwt|brk)-sta_(\w|\d)*-alu-[0-9{2}/`,
|
||||
expected: ['/alu/', '/tw-(nyc|que|brx|dwt|brk)-sta_(\w|\d)*-alu-[0-9{2}/']
|
||||
},
|
||||
{
|
||||
query: `a.b.c.d`,
|
||||
expected: ['a', 'b', 'c', 'd']
|
||||
}
|
||||
];
|
||||
|
||||
_.each(test_cases, test_case => {
|
||||
let splitQuery = utils.splitTemplateQuery(test_case.query);
|
||||
expect(splitQuery).toEqual(test_case.expected);
|
||||
});
|
||||
done();
|
||||
});
|
||||
|
||||
it('should properly split query', (done) => {
|
||||
let test_cases = [
|
||||
{
|
||||
query: `{alu}{/tw-(nyc|que|brx|dwt|brk)-sta_(\w|\d)*-alu-[0-9]*/}`,
|
||||
expected: ['alu', '/tw-(nyc|que|brx|dwt|brk)-sta_(\w|\d)*-alu-[0-9]*/']
|
||||
},
|
||||
{
|
||||
query: `{alu}{/tw-(nyc|que|brx|dwt|brk)-sta_(\w|\d)*-alu-[0-9]{2}/}`,
|
||||
expected: ['alu', '/tw-(nyc|que|brx|dwt|brk)-sta_(\w|\d)*-alu-[0-9]{2}/']
|
||||
},
|
||||
{
|
||||
query: `{a}{b}{c}{d}`,
|
||||
expected: ['a', 'b', 'c', 'd']
|
||||
},
|
||||
{
|
||||
query: `{a}{b.c.d}`,
|
||||
expected: ['a', 'b.c.d']
|
||||
}
|
||||
];
|
||||
|
||||
_.each(test_cases, test_case => {
|
||||
let splitQuery = utils.splitTemplateQuery(test_case.query);
|
||||
expect(splitQuery).toEqual(test_case.expected);
|
||||
});
|
||||
done();
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
60
dist/datasource-zabbix/timeseries.js
vendored
60
dist/datasource-zabbix/timeseries.js
vendored
@@ -5,8 +5,8 @@ System.register(['lodash', './utils'], function (_export, _context) {
|
||||
|
||||
var _, utils, POINT_VALUE, POINT_TIMESTAMP, exportedFunctions;
|
||||
|
||||
/**
|
||||
* Downsample time series by using given function (avg, min, max).
|
||||
/**
|
||||
* Downsample time series by using given function (avg, min, max).
|
||||
*/
|
||||
function downsample(datapoints, time_to, ms_interval, func) {
|
||||
var downsampledSeries = [];
|
||||
@@ -54,9 +54,9 @@ System.register(['lodash', './utils'], function (_export, _context) {
|
||||
return downsampledSeries.reverse();
|
||||
}
|
||||
|
||||
/**
|
||||
* Group points by given time interval
|
||||
* datapoints: [[<value>, <unixtime>], ...]
|
||||
/**
|
||||
* Group points by given time interval
|
||||
* datapoints: [[<value>, <unixtime>], ...]
|
||||
*/
|
||||
function groupBy(datapoints, interval, groupByCallback) {
|
||||
var ms_interval = utils.parseInterval(interval);
|
||||
@@ -120,9 +120,9 @@ System.register(['lodash', './utils'], function (_export, _context) {
|
||||
return grouped_series;
|
||||
}
|
||||
|
||||
/**
|
||||
* Summarize set of time series into one.
|
||||
* @param {datapoints[]} timeseries array of time series
|
||||
/**
|
||||
* Summarize set of time series into one.
|
||||
* @param {datapoints[]} timeseries array of time series
|
||||
*/
|
||||
function sumSeries(timeseries) {
|
||||
|
||||
@@ -173,9 +173,9 @@ System.register(['lodash', './utils'], function (_export, _context) {
|
||||
return datapoints;
|
||||
}
|
||||
|
||||
/**
|
||||
* Simple delta. Calculate value delta between points.
|
||||
* @param {*} datapoints
|
||||
/**
|
||||
* Simple delta. Calculate value delta between points.
|
||||
* @param {*} datapoints
|
||||
*/
|
||||
function delta(datapoints) {
|
||||
var newSeries = [];
|
||||
@@ -187,9 +187,9 @@ System.register(['lodash', './utils'], function (_export, _context) {
|
||||
return newSeries;
|
||||
}
|
||||
|
||||
/**
|
||||
* Calculates rate per second. Resistant to counter reset.
|
||||
* @param {*} datapoints
|
||||
/**
|
||||
* Calculates rate per second. Resistant to counter reset.
|
||||
* @param {*} datapoints
|
||||
*/
|
||||
function rate(datapoints) {
|
||||
var newSeries = [];
|
||||
@@ -359,13 +359,13 @@ System.register(['lodash', './utils'], function (_export, _context) {
|
||||
// Utility functions //
|
||||
///////////////////////
|
||||
|
||||
/**
|
||||
* For given point calculate corresponding time frame.
|
||||
*
|
||||
* |__*_|_*__|___*| -> |*___|*___|*___|
|
||||
*
|
||||
* @param {*} timestamp
|
||||
* @param {*} ms_interval
|
||||
/**
|
||||
* For given point calculate corresponding time frame.
|
||||
*
|
||||
* |__*_|_*__|___*| -> |*___|*___|*___|
|
||||
*
|
||||
* @param {*} timestamp
|
||||
* @param {*} ms_interval
|
||||
*/
|
||||
function getPointTimeFrame(timestamp, ms_interval) {
|
||||
return Math.floor(timestamp / ms_interval) * ms_interval;
|
||||
@@ -377,13 +377,13 @@ System.register(['lodash', './utils'], function (_export, _context) {
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Fill empty front and end of series by zeroes.
|
||||
*
|
||||
* | *** | | *** |
|
||||
* |___ ___| -> |*** ***|
|
||||
* @param {*} series
|
||||
* @param {*} timestamps
|
||||
/**
|
||||
* Fill empty front and end of series by zeroes.
|
||||
*
|
||||
* | *** | | *** |
|
||||
* |___ ___| -> |*** ***|
|
||||
* @param {*} series
|
||||
* @param {*} timestamps
|
||||
*/
|
||||
function fillZeroes(series, timestamps) {
|
||||
var prepend = [];
|
||||
@@ -401,8 +401,8 @@ System.register(['lodash', './utils'], function (_export, _context) {
|
||||
return _.concat(_.concat(prepend, series), append);
|
||||
}
|
||||
|
||||
/**
|
||||
* Interpolate series with gaps
|
||||
/**
|
||||
* Interpolate series with gaps
|
||||
*/
|
||||
function interpolateSeries(series) {
|
||||
var left, right;
|
||||
|
||||
2
dist/datasource-zabbix/timeseries.js.map
vendored
2
dist/datasource-zabbix/timeseries.js.map
vendored
File diff suppressed because one or more lines are too long
36
dist/datasource-zabbix/utils.js
vendored
36
dist/datasource-zabbix/utils.js
vendored
@@ -5,12 +5,12 @@ System.register(['lodash', 'moment'], function (_export, _context) {
|
||||
|
||||
var _, moment, MACRO_PATTERN, regexPattern;
|
||||
|
||||
/**
|
||||
* Expand Zabbix item name
|
||||
*
|
||||
* @param {string} name item name, ie "CPU $2 time"
|
||||
* @param {string} key item key, ie system.cpu.util[,system,avg1]
|
||||
* @return {string} expanded name, ie "CPU system time"
|
||||
/**
|
||||
* Expand Zabbix item name
|
||||
*
|
||||
* @param {string} name item name, ie "CPU $2 time"
|
||||
* @param {string} key item key, ie system.cpu.util[,system,avg1]
|
||||
* @return {string} expanded name, ie "CPU system time"
|
||||
*/
|
||||
function expandItemName(name, key) {
|
||||
|
||||
@@ -105,10 +105,10 @@ System.register(['lodash', 'moment'], function (_export, _context) {
|
||||
return macro;
|
||||
}
|
||||
|
||||
/**
|
||||
* Split template query to parts of zabbix entities
|
||||
* group.host.app.item -> [group, host, app, item]
|
||||
* {group}{host.com} -> [group, host.com]
|
||||
/**
|
||||
* Split template query to parts of zabbix entities
|
||||
* group.host.app.item -> [group, host, app, item]
|
||||
* {group}{host.com} -> [group, host.com]
|
||||
*/
|
||||
function splitTemplateQuery(query) {
|
||||
var splitPattern = /\{[^\{\}]*\}|\{\/.*\/\}/g;
|
||||
@@ -194,11 +194,11 @@ System.register(['lodash', 'moment'], function (_export, _context) {
|
||||
return duration;
|
||||
}
|
||||
|
||||
/**
|
||||
* Format acknowledges.
|
||||
*
|
||||
* @param {array} acknowledges array of Zabbix acknowledge objects
|
||||
* @return {string} HTML-formatted table
|
||||
/**
|
||||
* Format acknowledges.
|
||||
*
|
||||
* @param {array} acknowledges array of Zabbix acknowledge objects
|
||||
* @return {string} HTML-formatted table
|
||||
*/
|
||||
|
||||
_export('parseTimeShiftInterval', parseTimeShiftInterval);
|
||||
@@ -231,9 +231,9 @@ System.register(['lodash', 'moment'], function (_export, _context) {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Wrap function to prevent multiple calls
|
||||
* when waiting for result.
|
||||
/**
|
||||
* Wrap function to prevent multiple calls
|
||||
* when waiting for result.
|
||||
*/
|
||||
|
||||
_export('convertToZabbixAPIUrl', convertToZabbixAPIUrl);
|
||||
|
||||
2
dist/datasource-zabbix/utils.js.map
vendored
2
dist/datasource-zabbix/utils.js.map
vendored
File diff suppressed because one or more lines are too long
24
dist/datasource-zabbix/zabbix.js
vendored
24
dist/datasource-zabbix/zabbix.js
vendored
@@ -251,11 +251,11 @@ System.register(['angular', 'lodash', './utils', './zabbixAPI.service.js', './za
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
/**
|
||||
* Find group, host, app or item by given name.
|
||||
* @param list list of groups, apps or other
|
||||
* @param name visible name
|
||||
* @return array with finded element or empty array
|
||||
/**
|
||||
* Find group, host, app or item by given name.
|
||||
* @param list list of groups, apps or other
|
||||
* @param name visible name
|
||||
* @return array with finded element or empty array
|
||||
*/
|
||||
function findByName(list, name) {
|
||||
var finded = _.find(list, { 'name': name });
|
||||
@@ -266,13 +266,13 @@ System.register(['angular', 'lodash', './utils', './zabbixAPI.service.js', './za
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Different hosts can contains applications and items with same name.
|
||||
* For this reason use _.filter, which return all elements instead _.find,
|
||||
* which return only first finded.
|
||||
* @param {[type]} list list of elements
|
||||
* @param {[type]} name app name
|
||||
* @return {[type]} array with finded element or empty array
|
||||
/**
|
||||
* Different hosts can contains applications and items with same name.
|
||||
* For this reason use _.filter, which return all elements instead _.find,
|
||||
* which return only first finded.
|
||||
* @param {[type]} list list of elements
|
||||
* @param {[type]} name app name
|
||||
* @return {[type]} array with finded element or empty array
|
||||
*/
|
||||
function filterByName(list, name) {
|
||||
var finded = _.filter(list, { 'name': name });
|
||||
|
||||
2
dist/datasource-zabbix/zabbix.js.map
vendored
2
dist/datasource-zabbix/zabbix.js.map
vendored
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
@@ -43,9 +43,9 @@ System.register(['angular'], function (_export, _context) {
|
||||
this.backendSrv = backendSrv;
|
||||
}
|
||||
|
||||
/**
|
||||
* Request data from Zabbix API
|
||||
* @return {object} response.result
|
||||
/**
|
||||
* Request data from Zabbix API
|
||||
* @return {object} response.result
|
||||
*/
|
||||
|
||||
|
||||
|
||||
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
@@ -195,9 +195,9 @@ System.register(['angular', 'lodash'], function (_export, _context) {
|
||||
return ZabbixCachingProxy;
|
||||
}
|
||||
|
||||
/**
|
||||
* Wrap zabbix API request to prevent multiple calls
|
||||
* with same params when waiting for result.
|
||||
/**
|
||||
* Wrap zabbix API request to prevent multiple calls
|
||||
* with same params when waiting for result.
|
||||
*/
|
||||
function callAPIRequestOnce(func, promiseKeeper, argsHashFunc) {
|
||||
return function () {
|
||||
|
||||
File diff suppressed because one or more lines are too long
6
dist/datasource-zabbix/zabbixDBConnector.js
vendored
6
dist/datasource-zabbix/zabbixDBConnector.js
vendored
@@ -28,9 +28,9 @@ System.register(['angular', 'lodash'], function (_export, _context) {
|
||||
this.loadSQLDataSource(sqlDataSourceId);
|
||||
}
|
||||
|
||||
/**
|
||||
* Try to load DS with given id to check it's exist.
|
||||
* @param {*} datasourceId ID of SQL data source
|
||||
/**
|
||||
* Try to load DS with given id to check it's exist.
|
||||
* @param {*} datasourceId ID of SQL data source
|
||||
*/
|
||||
|
||||
|
||||
|
||||
File diff suppressed because one or more lines are too long
Reference in New Issue
Block a user