iss #43 - fixed code style errors.
This commit is contained in:
5
.gitignore
vendored
5
.gitignore
vendored
@@ -4,3 +4,8 @@
|
|||||||
.idea/
|
.idea/
|
||||||
|
|
||||||
*.bat
|
*.bat
|
||||||
|
|
||||||
|
# Grafana linter config
|
||||||
|
.jshintrc
|
||||||
|
.jscs.json
|
||||||
|
.jsfmtrc
|
||||||
@@ -1,3 +1,4 @@
|
|||||||
|
'use strict';
|
||||||
define([
|
define([
|
||||||
'angular',
|
'angular',
|
||||||
'lodash',
|
'lodash',
|
||||||
@@ -6,7 +7,7 @@ define([
|
|||||||
'./queryCtrl'
|
'./queryCtrl'
|
||||||
],
|
],
|
||||||
function (angular, _, kbn) {
|
function (angular, _, kbn) {
|
||||||
'use strict';
|
//'use strict';
|
||||||
|
|
||||||
var module = angular.module('grafana.services');
|
var module = angular.module('grafana.services');
|
||||||
|
|
||||||
@@ -37,7 +38,6 @@ function (angular, _, kbn) {
|
|||||||
zabbix.init(this.url, this.username, this.password);
|
zabbix.init(this.url, this.username, this.password);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Calls for each panel in dashboard.
|
* Calls for each panel in dashboard.
|
||||||
*
|
*
|
||||||
@@ -87,7 +87,7 @@ function (angular, _, kbn) {
|
|||||||
.then(function (items) {
|
.then(function (items) {
|
||||||
|
|
||||||
// Filter hosts by regex
|
// Filter hosts by regex
|
||||||
if (target.host.visible_name == 'All') {
|
if (target.host.visible_name === 'All') {
|
||||||
if (target.hostFilter && _.every(items, _.identity.hosts)) {
|
if (target.hostFilter && _.every(items, _.identity.hosts)) {
|
||||||
var host_pattern = new RegExp(target.hostFilter);
|
var host_pattern = new RegExp(target.hostFilter);
|
||||||
items = _.filter(items, function (item) {
|
items = _.filter(items, function (item) {
|
||||||
@@ -98,7 +98,7 @@ function (angular, _, kbn) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (itemnames == 'All') {
|
if (itemnames === 'All') {
|
||||||
|
|
||||||
// Filter items by regex
|
// Filter items by regex
|
||||||
if (target.itemFilter) {
|
if (target.itemFilter) {
|
||||||
@@ -154,7 +154,6 @@ function (angular, _, kbn) {
|
|||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
ZabbixAPIDatasource.prototype.handleTrendResponse = function(items, alias, scale, trends) {
|
ZabbixAPIDatasource.prototype.handleTrendResponse = function(items, alias, scale, trends) {
|
||||||
|
|
||||||
// Group items and trends by itemid
|
// Group items and trends by itemid
|
||||||
@@ -183,7 +182,6 @@ function (angular, _, kbn) {
|
|||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Convert Zabbix API data to Grafana format
|
* Convert Zabbix API data to Grafana format
|
||||||
*
|
*
|
||||||
@@ -237,7 +235,6 @@ function (angular, _, kbn) {
|
|||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* For templated query.
|
* For templated query.
|
||||||
* Find metrics from templated request.
|
* Find metrics from templated request.
|
||||||
@@ -260,13 +257,13 @@ function (angular, _, kbn) {
|
|||||||
parts.push(part);
|
parts.push(part);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
var template = _.object(['group', 'host', 'app', 'item'], parts)
|
var template = _.object(['group', 'host', 'app', 'item'], parts);
|
||||||
|
|
||||||
// Get items
|
// Get items
|
||||||
if (parts.length === 4) {
|
if (parts.length === 4) {
|
||||||
return zabbix.itemFindQuery(template.group, template.host, template.app).then(function (result) {
|
return zabbix.itemFindQuery(template.group, template.host, template.app).then(function (result) {
|
||||||
return _.map(result, function (item) {
|
return _.map(result, function (item) {
|
||||||
var itemname = zabbix.expandItemName(item)
|
var itemname = zabbix.expandItemName(item);
|
||||||
return {
|
return {
|
||||||
text: itemname,
|
text: itemname,
|
||||||
expandable: false
|
expandable: false
|
||||||
@@ -315,12 +312,10 @@ function (angular, _, kbn) {
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
/////////////////
|
/////////////////
|
||||||
// Annotations //
|
// Annotations //
|
||||||
/////////////////
|
/////////////////
|
||||||
|
|
||||||
|
|
||||||
ZabbixAPIDatasource.prototype.annotationQuery = function(annotation, rangeUnparsed) {
|
ZabbixAPIDatasource.prototype.annotationQuery = function(annotation, rangeUnparsed) {
|
||||||
var from = Math.ceil(kbn.parseDate(rangeUnparsed.from).getTime() / 1000);
|
var from = Math.ceil(kbn.parseDate(rangeUnparsed.from).getTime() / 1000);
|
||||||
var to = Math.ceil(kbn.parseDate(rangeUnparsed.to).getTime() / 1000);
|
var to = Math.ceil(kbn.parseDate(rangeUnparsed.to).getTime() / 1000);
|
||||||
@@ -356,7 +351,7 @@ function (angular, _, kbn) {
|
|||||||
.then(function (result) {
|
.then(function (result) {
|
||||||
var events = [];
|
var events = [];
|
||||||
_.each(result, function(e) {
|
_.each(result, function(e) {
|
||||||
var formatted_acknowledges = formatAcknowledges(e.acknowledges);;
|
var formatted_acknowledges = formatAcknowledges(e.acknowledges);
|
||||||
events.push({
|
events.push({
|
||||||
annotation: annotation,
|
annotation: annotation,
|
||||||
time: e.clock * 1000,
|
time: e.clock * 1000,
|
||||||
@@ -365,18 +360,17 @@ function (angular, _, kbn) {
|
|||||||
});
|
});
|
||||||
});
|
});
|
||||||
return events;
|
return events;
|
||||||
});
|
});
|
||||||
} else {
|
} else {
|
||||||
return [];
|
return [];
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
return ZabbixAPIDatasource;
|
return ZabbixAPIDatasource;
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Convert multiple mettrics to array
|
* Convert multiple mettrics to array
|
||||||
* "{metric1,metcic2,...,metricN}" --> [metric1, metcic2,..., metricN]
|
* "{metric1,metcic2,...,metricN}" --> [metric1, metcic2,..., metricN]
|
||||||
@@ -387,10 +381,9 @@ function (angular, _, kbn) {
|
|||||||
function splitMetrics(metrics) {
|
function splitMetrics(metrics) {
|
||||||
var remove_brackets_pattern = /^{|}$/g;
|
var remove_brackets_pattern = /^{|}$/g;
|
||||||
var metric_split_pattern = /,(?!\s)/g;
|
var metric_split_pattern = /,(?!\s)/g;
|
||||||
return metrics.replace(remove_brackets_pattern, '').split(metric_split_pattern)
|
return metrics.replace(remove_brackets_pattern, '').split(metric_split_pattern);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Convert Date object to local time in format
|
* Convert Date object to local time in format
|
||||||
* YYYY-MM-DD HH:mm:ss
|
* YYYY-MM-DD HH:mm:ss
|
||||||
@@ -407,7 +400,6 @@ function getShortTime(date) {
|
|||||||
return date.getFullYear() + '-' + MM + '-' + DD + ' ' + HH + ':' + mm + ':' + ss;
|
return date.getFullYear() + '-' + MM + '-' + DD + ' ' + HH + ':' + mm + ':' + ss;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Format acknowledges.
|
* Format acknowledges.
|
||||||
*
|
*
|
||||||
@@ -416,21 +408,22 @@ function getShortTime(date) {
|
|||||||
*/
|
*/
|
||||||
function formatAcknowledges(acknowledges) {
|
function formatAcknowledges(acknowledges) {
|
||||||
if (acknowledges.length) {
|
if (acknowledges.length) {
|
||||||
var formatted_acknowledges = '<br><br>Acknowledges:<br><table><tr><td><b>Time</b></td><td><b>User</b></td><td><b>Comments</b></td></tr>';
|
var formatted_acknowledges = '<br><br>Acknowledges:<br><table><tr><td><b>Time</b></td>'
|
||||||
|
+ '<td><b>User</b></td><td><b>Comments</b></td></tr>';
|
||||||
_.each(_.map(acknowledges, function (ack) {
|
_.each(_.map(acknowledges, function (ack) {
|
||||||
var time = new Date(ack.clock * 1000);
|
var time = new Date(ack.clock * 1000);
|
||||||
return '<tr><td><i>' + getShortTime(time) + '</i></td><td>' + ack.alias + ' (' + ack.name+ ' ' + ack.surname + ')' + '</td><td>' + ack.message + '</td></tr>';
|
return '<tr><td><i>' + getShortTime(time) + '</i></td><td>' + ack.alias
|
||||||
|
+ ' (' + ack.name + ' ' + ack.surname + ')' + '</td><td>' + ack.message + '</td></tr>';
|
||||||
}), function (ack) {
|
}), function (ack) {
|
||||||
formatted_acknowledges = formatted_acknowledges.concat(ack)
|
formatted_acknowledges = formatted_acknowledges.concat(ack);
|
||||||
});
|
});
|
||||||
formatted_acknowledges = formatted_acknowledges.concat('</table>')
|
formatted_acknowledges = formatted_acknowledges.concat('</table>');
|
||||||
return formatted_acknowledges;
|
return formatted_acknowledges;
|
||||||
} else {
|
} else {
|
||||||
return '';
|
return '';
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Downsample datapoints series
|
* Downsample datapoints series
|
||||||
*
|
*
|
||||||
@@ -440,7 +433,7 @@ function formatAcknowledges(acknowledges) {
|
|||||||
* @return {array} [[<value>, <unixtime>], ...]
|
* @return {array} [[<value>, <unixtime>], ...]
|
||||||
*/
|
*/
|
||||||
function downsampleSeries(datapoints, time_to, ms_interval) {
|
function downsampleSeries(datapoints, time_to, ms_interval) {
|
||||||
var downsampledSeries = new Array();
|
var downsampledSeries = [];
|
||||||
var timeWindow = {
|
var timeWindow = {
|
||||||
from: time_to * 1000 - ms_interval,
|
from: time_to * 1000 - ms_interval,
|
||||||
to: time_to * 1000
|
to: time_to * 1000
|
||||||
|
|||||||
@@ -31,7 +31,6 @@ function (angular, _) {
|
|||||||
$scope.target.errors = validateTarget($scope.target);
|
$scope.target.errors = validateTarget($scope.target);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Take alias from item name by default
|
* Take alias from item name by default
|
||||||
*/
|
*/
|
||||||
@@ -39,8 +38,7 @@ function (angular, _) {
|
|||||||
if (!$scope.target.alias && $scope.target.item) {
|
if (!$scope.target.alias && $scope.target.item) {
|
||||||
$scope.target.alias = $scope.target.item.name;
|
$scope.target.alias = $scope.target.item.name;
|
||||||
}
|
}
|
||||||
};
|
}
|
||||||
|
|
||||||
|
|
||||||
$scope.targetBlur = function() {
|
$scope.targetBlur = function() {
|
||||||
setItemAlias();
|
setItemAlias();
|
||||||
@@ -51,12 +49,11 @@ function (angular, _) {
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Call when host group selected
|
* Call when host group selected
|
||||||
*/
|
*/
|
||||||
$scope.selectHostGroup = function() {
|
$scope.selectHostGroup = function() {
|
||||||
$scope.updateHostList()
|
$scope.updateHostList();
|
||||||
$scope.updateAppList();
|
$scope.updateAppList();
|
||||||
$scope.updateItemList();
|
$scope.updateItemList();
|
||||||
|
|
||||||
@@ -67,7 +64,6 @@ function (angular, _) {
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Call when host selected
|
* Call when host selected
|
||||||
*/
|
*/
|
||||||
@@ -82,7 +78,6 @@ function (angular, _) {
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Call when application selected
|
* Call when application selected
|
||||||
*/
|
*/
|
||||||
@@ -96,7 +91,6 @@ function (angular, _) {
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Call when item selected
|
* Call when item selected
|
||||||
*/
|
*/
|
||||||
@@ -109,13 +103,11 @@ function (angular, _) {
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
$scope.duplicate = function() {
|
$scope.duplicate = function() {
|
||||||
var clone = angular.copy($scope.target);
|
var clone = angular.copy($scope.target);
|
||||||
$scope.panel.targets.push(clone);
|
$scope.panel.targets.push(clone);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
$scope.moveMetricQuery = function(fromIndex, toIndex) {
|
$scope.moveMetricQuery = function(fromIndex, toIndex) {
|
||||||
_.move($scope.panel.targets, fromIndex, toIndex);
|
_.move($scope.panel.targets, fromIndex, toIndex);
|
||||||
};
|
};
|
||||||
@@ -124,7 +116,6 @@ function (angular, _) {
|
|||||||
// SUGGESTION QUERIES
|
// SUGGESTION QUERIES
|
||||||
//////////////////////////////
|
//////////////////////////////
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Update list of host groups
|
* Update list of host groups
|
||||||
*/
|
*/
|
||||||
@@ -137,7 +128,6 @@ function (angular, _) {
|
|||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Update list of hosts
|
* Update list of hosts
|
||||||
*/
|
*/
|
||||||
@@ -151,7 +141,6 @@ function (angular, _) {
|
|||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Update list of host applications
|
* Update list of host applications
|
||||||
*/
|
*/
|
||||||
@@ -162,19 +151,18 @@ function (angular, _) {
|
|||||||
var groups = $scope.target.group ? splitMetrics(templateSrv.replace($scope.target.group.name)) : undefined;
|
var groups = $scope.target.group ? splitMetrics(templateSrv.replace($scope.target.group.name)) : undefined;
|
||||||
var hosts = $scope.target.host ? splitMetrics(templateSrv.replace($scope.target.host.name)) : undefined;
|
var hosts = $scope.target.host ? splitMetrics(templateSrv.replace($scope.target.host.name)) : undefined;
|
||||||
zabbix.appFindQuery(hosts, groups).then(function (apps) {
|
zabbix.appFindQuery(hosts, groups).then(function (apps) {
|
||||||
var apps = _.map(_.uniq(_.map(apps, 'name')), function (appname) {
|
apps = _.map(_.uniq(_.map(apps, 'name')), function (appname) {
|
||||||
return {name: appname};
|
return {name: appname};
|
||||||
});
|
});
|
||||||
$scope.metric.applicationList = $scope.metric.applicationList.concat(apps);
|
$scope.metric.applicationList = $scope.metric.applicationList.concat(apps);
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Update list of items
|
* Update list of items
|
||||||
*/
|
*/
|
||||||
$scope.updateItemList = function() {
|
$scope.updateItemList = function() {
|
||||||
$scope.metric.itemList = [{name: 'All'}];;
|
$scope.metric.itemList = [{name: 'All'}];
|
||||||
addTemplatedVariables($scope.metric.itemList);
|
addTemplatedVariables($scope.metric.itemList);
|
||||||
|
|
||||||
var groups = $scope.target.group ? splitMetrics(templateSrv.replace($scope.target.group.name)) : undefined;
|
var groups = $scope.target.group ? splitMetrics(templateSrv.replace($scope.target.group.name)) : undefined;
|
||||||
@@ -185,13 +173,12 @@ function (angular, _) {
|
|||||||
var uniq_items = _.map(_.uniq(items, function (item) {
|
var uniq_items = _.map(_.uniq(items, function (item) {
|
||||||
return zabbix.expandItemName(item);
|
return zabbix.expandItemName(item);
|
||||||
}), function (item) {
|
}), function (item) {
|
||||||
return {name: zabbix.expandItemName(item)}
|
return {name: zabbix.expandItemName(item)};
|
||||||
});
|
});
|
||||||
$scope.metric.itemList = $scope.metric.itemList.concat(uniq_items);
|
$scope.metric.itemList = $scope.metric.itemList.concat(uniq_items);
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Add templated variables to list of available metrics
|
* Add templated variables to list of available metrics
|
||||||
*
|
*
|
||||||
@@ -202,10 +189,9 @@ function (angular, _) {
|
|||||||
metricList.push({
|
metricList.push({
|
||||||
name: '$' + variable.name,
|
name: '$' + variable.name,
|
||||||
templated: true
|
templated: true
|
||||||
})
|
});
|
||||||
});
|
});
|
||||||
};
|
}
|
||||||
|
|
||||||
|
|
||||||
//////////////////////////////
|
//////////////////////////////
|
||||||
// VALIDATION
|
// VALIDATION
|
||||||
@@ -213,7 +199,9 @@ function (angular, _) {
|
|||||||
|
|
||||||
function validateTarget(target) {
|
function validateTarget(target) {
|
||||||
var errs = {};
|
var errs = {};
|
||||||
|
if (!target) {
|
||||||
|
errs = 'Not defined';
|
||||||
|
}
|
||||||
return errs;
|
return errs;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -221,7 +209,6 @@ function (angular, _) {
|
|||||||
|
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Convert multiple mettrics to array
|
* Convert multiple mettrics to array
|
||||||
* "{metric1,metcic2,...,metricN}" --> [metric1, metcic2,..., metricN]
|
* "{metric1,metcic2,...,metricN}" --> [metric1, metcic2,..., metricN]
|
||||||
@@ -230,7 +217,8 @@ function (angular, _) {
|
|||||||
* @return {Array} [metric1, metcic2,..., metricN]
|
* @return {Array} [metric1, metcic2,..., metricN]
|
||||||
*/
|
*/
|
||||||
function splitMetrics(metrics) {
|
function splitMetrics(metrics) {
|
||||||
|
'use strict';
|
||||||
var remove_brackets_pattern = /^{|}$/g;
|
var remove_brackets_pattern = /^{|}$/g;
|
||||||
var metric_split_pattern = /,(?!\s)/g;
|
var metric_split_pattern = /,(?!\s)/g;
|
||||||
return metrics.replace(remove_brackets_pattern, '').split(metric_split_pattern)
|
return metrics.replace(remove_brackets_pattern, '').split(metric_split_pattern);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -16,14 +16,12 @@ function (angular, _) {
|
|||||||
this.url = api_url;
|
this.url = api_url;
|
||||||
this.username = username;
|
this.username = username;
|
||||||
this.password = password;
|
this.password = password;
|
||||||
}
|
};
|
||||||
|
|
||||||
|
|
||||||
//////////////////
|
//////////////////
|
||||||
// Core methods //
|
// Core methods //
|
||||||
//////////////////
|
//////////////////
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Request data from Zabbix API
|
* Request data from Zabbix API
|
||||||
*
|
*
|
||||||
@@ -56,9 +54,9 @@ function (angular, _) {
|
|||||||
else if (response.data.error) {
|
else if (response.data.error) {
|
||||||
|
|
||||||
// Handle auth errors
|
// Handle auth errors
|
||||||
if (response.data.error.data == "Session terminated, re-login, please." ||
|
if (response.data.error.data === "Session terminated, re-login, please." ||
|
||||||
response.data.error.data == "Not authorised." ||
|
response.data.error.data === "Not authorised." ||
|
||||||
response.data.error.data == "Not authorized") {
|
response.data.error.data === "Not authorized") {
|
||||||
return self.performZabbixAPILogin().then(function (response) {
|
return self.performZabbixAPILogin().then(function (response) {
|
||||||
self.auth = response;
|
self.auth = response;
|
||||||
return self.performZabbixAPIRequest(method, params);
|
return self.performZabbixAPIRequest(method, params);
|
||||||
@@ -69,7 +67,6 @@ function (angular, _) {
|
|||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get authentication token.
|
* Get authentication token.
|
||||||
*
|
*
|
||||||
@@ -99,13 +96,10 @@ function (angular, _) {
|
|||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/////////////////////////
|
/////////////////////////
|
||||||
// API method wrappers //
|
// API method wrappers //
|
||||||
/////////////////////////
|
/////////////////////////
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Perform history query from Zabbix API
|
* Perform history query from Zabbix API
|
||||||
*
|
*
|
||||||
@@ -141,7 +135,6 @@ function (angular, _) {
|
|||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Perform trends query from Zabbix API
|
* Perform trends query from Zabbix API
|
||||||
* Use trends api extension from ZBXNEXT-1193 patch.
|
* Use trends api extension from ZBXNEXT-1193 patch.
|
||||||
@@ -178,7 +171,6 @@ function (angular, _) {
|
|||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get the list of host groups
|
* Get the list of host groups
|
||||||
*
|
*
|
||||||
@@ -197,7 +189,6 @@ function (angular, _) {
|
|||||||
return this.performZabbixAPIRequest('hostgroup.get', params);
|
return this.performZabbixAPIRequest('hostgroup.get', params);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get the list of hosts
|
* Get the list of hosts
|
||||||
*
|
*
|
||||||
@@ -220,7 +211,6 @@ function (angular, _) {
|
|||||||
return this.performZabbixAPIRequest('host.get', params);
|
return this.performZabbixAPIRequest('host.get', params);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get the list of applications
|
* Get the list of applications
|
||||||
*
|
*
|
||||||
@@ -243,7 +233,6 @@ function (angular, _) {
|
|||||||
return this.performZabbixAPIRequest('application.get', params);
|
return this.performZabbixAPIRequest('application.get', params);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Items request
|
* Items request
|
||||||
*
|
*
|
||||||
@@ -287,7 +276,6 @@ function (angular, _) {
|
|||||||
return this.performZabbixAPIRequest('item.get', params);
|
return this.performZabbixAPIRequest('item.get', params);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get groups by names
|
* Get groups by names
|
||||||
*
|
*
|
||||||
@@ -298,7 +286,7 @@ function (angular, _) {
|
|||||||
var params = {
|
var params = {
|
||||||
output: ['name']
|
output: ['name']
|
||||||
};
|
};
|
||||||
if (group != '*') {
|
if (group !== '*') {
|
||||||
params.filter = {
|
params.filter = {
|
||||||
name: group
|
name: group
|
||||||
};
|
};
|
||||||
@@ -306,7 +294,6 @@ function (angular, _) {
|
|||||||
return this.performZabbixAPIRequest('hostgroup.get', params);
|
return this.performZabbixAPIRequest('hostgroup.get', params);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Search group by name.
|
* Search group by name.
|
||||||
*
|
*
|
||||||
@@ -324,7 +311,6 @@ function (angular, _) {
|
|||||||
return this.performZabbixAPIRequest('hostgroup.get', params);
|
return this.performZabbixAPIRequest('hostgroup.get', params);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get hosts by names
|
* Get hosts by names
|
||||||
*
|
*
|
||||||
@@ -335,7 +321,7 @@ function (angular, _) {
|
|||||||
var params = {
|
var params = {
|
||||||
output: ['host', 'name']
|
output: ['host', 'name']
|
||||||
};
|
};
|
||||||
if (hostnames != '*') {
|
if (hostnames !== '*') {
|
||||||
params.filter = {
|
params.filter = {
|
||||||
name: hostnames
|
name: hostnames
|
||||||
};
|
};
|
||||||
@@ -343,7 +329,6 @@ function (angular, _) {
|
|||||||
return this.performZabbixAPIRequest('host.get', params);
|
return this.performZabbixAPIRequest('host.get', params);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get applications by names
|
* Get applications by names
|
||||||
*
|
*
|
||||||
@@ -353,16 +338,15 @@ function (angular, _) {
|
|||||||
this.getAppByName = function (application) {
|
this.getAppByName = function (application) {
|
||||||
var params = {
|
var params = {
|
||||||
output: ['name']
|
output: ['name']
|
||||||
}
|
};
|
||||||
if (application != '*') {
|
if (application !== '*') {
|
||||||
params.filter = {
|
params.filter = {
|
||||||
name: application
|
name: application
|
||||||
};
|
};
|
||||||
};
|
}
|
||||||
return this.performZabbixAPIRequest('application.get', params);
|
return this.performZabbixAPIRequest('application.get', params);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get items belongs to passed groups, hosts and
|
* Get items belongs to passed groups, hosts and
|
||||||
* applications
|
* applications
|
||||||
@@ -376,7 +360,7 @@ function (angular, _) {
|
|||||||
var promises = [];
|
var promises = [];
|
||||||
|
|
||||||
// Get hostids from names
|
// Get hostids from names
|
||||||
if (hosts && hosts != '*') {
|
if (hosts && hosts !== '*') {
|
||||||
promises.push(this.getHostByName(hosts));
|
promises.push(this.getHostByName(hosts));
|
||||||
}
|
}
|
||||||
// Get groupids from names
|
// Get groupids from names
|
||||||
@@ -391,18 +375,21 @@ function (angular, _) {
|
|||||||
var self = this;
|
var self = this;
|
||||||
return $q.all(promises).then(function (results) {
|
return $q.all(promises).then(function (results) {
|
||||||
results = _.flatten(results);
|
results = _.flatten(results);
|
||||||
|
var groupids;
|
||||||
|
var hostids;
|
||||||
|
var applicationids;
|
||||||
if (groups) {
|
if (groups) {
|
||||||
var groupids = _.map(_.filter(results, function (object) {
|
groupids = _.map(_.filter(results, function (object) {
|
||||||
return object.groupid;
|
return object.groupid;
|
||||||
}), 'groupid');
|
}), 'groupid');
|
||||||
}
|
}
|
||||||
if (hosts && hosts != '*') {
|
if (hosts && hosts !== '*') {
|
||||||
var hostids = _.map(_.filter(results, function (object) {
|
hostids = _.map(_.filter(results, function (object) {
|
||||||
return object.hostid;
|
return object.hostid;
|
||||||
}), 'hostid');
|
}), 'hostid');
|
||||||
}
|
}
|
||||||
if (apps) {
|
if (apps) {
|
||||||
var applicationids = _.map(_.filter(results, function (object) {
|
applicationids = _.map(_.filter(results, function (object) {
|
||||||
return object.applicationid;
|
return object.applicationid;
|
||||||
}), 'applicationid');
|
}), 'applicationid');
|
||||||
}
|
}
|
||||||
@@ -411,7 +398,6 @@ function (angular, _) {
|
|||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Find applications belongs to passed groups and hosts
|
* Find applications belongs to passed groups and hosts
|
||||||
*
|
*
|
||||||
@@ -423,7 +409,7 @@ function (angular, _) {
|
|||||||
var promises = [];
|
var promises = [];
|
||||||
|
|
||||||
// Get hostids from names
|
// Get hostids from names
|
||||||
if (hosts && hosts != '*') {
|
if (hosts && hosts !== '*') {
|
||||||
promises.push(this.getHostByName(hosts));
|
promises.push(this.getHostByName(hosts));
|
||||||
}
|
}
|
||||||
// Get groupids from names
|
// Get groupids from names
|
||||||
@@ -434,13 +420,15 @@ function (angular, _) {
|
|||||||
var self = this;
|
var self = this;
|
||||||
return $q.all(promises).then(function (results) {
|
return $q.all(promises).then(function (results) {
|
||||||
results = _.flatten(results);
|
results = _.flatten(results);
|
||||||
|
var groupids;
|
||||||
|
var hostids;
|
||||||
if (groups) {
|
if (groups) {
|
||||||
var groupids = _.map(_.filter(results, function (object) {
|
groupids = _.map(_.filter(results, function (object) {
|
||||||
return object.groupid;
|
return object.groupid;
|
||||||
}), 'groupid');
|
}), 'groupid');
|
||||||
}
|
}
|
||||||
if (hosts && hosts != '*') {
|
if (hosts && hosts !== '*') {
|
||||||
var hostids = _.map(_.filter(results, function (object) {
|
hostids = _.map(_.filter(results, function (object) {
|
||||||
return object.hostid;
|
return object.hostid;
|
||||||
}), 'hostid');
|
}), 'hostid');
|
||||||
}
|
}
|
||||||
@@ -449,7 +437,6 @@ function (angular, _) {
|
|||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Find hosts belongs to passed groups
|
* Find hosts belongs to passed groups
|
||||||
*
|
*
|
||||||
@@ -468,7 +455,6 @@ function (angular, _) {
|
|||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Expand item parameters, for example:
|
* Expand item parameters, for example:
|
||||||
* CPU $2 time ($3) --> CPU system time (avg1)
|
* CPU $2 time ($3) --> CPU system time (avg1)
|
||||||
@@ -487,9 +473,9 @@ function (angular, _) {
|
|||||||
// replace item parameters
|
// replace item parameters
|
||||||
for (var i = key_params.length; i >= 1; i--) {
|
for (var i = key_params.length; i >= 1; i--) {
|
||||||
name = name.replace('$' + i, key_params[i - 1]);
|
name = name.replace('$' + i, key_params[i - 1]);
|
||||||
};
|
}
|
||||||
return name;
|
return name;
|
||||||
}
|
};
|
||||||
|
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|||||||
Reference in New Issue
Block a user