Fixed #132 - support text items in template variables.

This commit is contained in:
Alexander Zobnin
2016-04-12 15:28:02 +03:00
parent cdc6b96c41
commit 59b0f14465
2 changed files with 7 additions and 6 deletions

View File

@@ -135,7 +135,7 @@ export class ZabbixAPIDatasource {
// Build query in asynchronous manner // Build query in asynchronous manner
return self.queryProcessor return self.queryProcessor
.build(groupFilter, hostFilter, appFilter, itemFilter) .build(groupFilter, hostFilter, appFilter, itemFilter, 'num')
.then(items => { .then(items => {
// Add hostname for items from multiple hosts // Add hostname for items from multiple hosts
var addHostName = utils.isRegex(target.host.filter); var addHostName = utils.isRegex(target.host.filter);

View File

@@ -152,7 +152,7 @@ function ZabbixAPIService($q, alertSrv, zabbixAPICoreService) {
* @param {String} itemtype 'num' or 'text' * @param {String} itemtype 'num' or 'text'
* @return {[type]} array of items * @return {[type]} array of items
*/ */
getItems(hostids, appids, itemtype='num') { getItems(hostids, appids, itemtype) {
var params = { var params = {
output: [ output: [
'name', 'key_', 'name', 'key_',
@@ -163,10 +163,7 @@ function ZabbixAPIService($q, alertSrv, zabbixAPICoreService) {
], ],
sortfield: 'name', sortfield: 'name',
webitems: true, webitems: true,
filter: { filter: {},
// Return only numeric items by default
value_type: [0, 3]
},
selectHosts: [ selectHosts: [
'hostid', 'hostid',
'name' 'name'
@@ -178,6 +175,10 @@ function ZabbixAPIService($q, alertSrv, zabbixAPICoreService) {
if (appids) { if (appids) {
params.applicationids = appids; params.applicationids = appids;
} }
if (itemtype === 'num') {
// Return only numeric metrics
params.filter.value_type = [0, 3];
}
if (itemtype === 'text') { if (itemtype === 'text') {
// Return only text metrics // Return only text metrics
params.filter.value_type = [1, 2, 4]; params.filter.value_type = [1, 2, 4];