autodetect zabbix version
This commit is contained in:
@@ -9,6 +9,8 @@ import responseHandler from './responseHandler';
|
||||
import { Zabbix } from './zabbix/zabbix';
|
||||
import { ZabbixAPIError } from './zabbix/connectors/zabbix_api/zabbixAPICore';
|
||||
|
||||
const DEFAULT_ZABBIX_VERSION = 3;
|
||||
|
||||
export class ZabbixDatasource {
|
||||
|
||||
/** @ngInject */
|
||||
@@ -47,6 +49,7 @@ export class ZabbixDatasource {
|
||||
|
||||
// Other options
|
||||
this.disableReadOnlyUsersAck = jsonData.disableReadOnlyUsersAck;
|
||||
this.zabbixVersion = jsonData.zabbixVersion || DEFAULT_ZABBIX_VERSION;
|
||||
|
||||
// Direct DB Connection options
|
||||
this.enableDirectDBConnection = jsonData.dbConnectionEnable || false;
|
||||
@@ -59,6 +62,7 @@ export class ZabbixDatasource {
|
||||
password: this.password,
|
||||
basicAuth: this.basicAuth,
|
||||
withCredentials: this.withCredentials,
|
||||
zabbixVersion: this.zabbixVersion,
|
||||
cacheTTL: this.cacheTTL,
|
||||
enableDirectDBConnection: this.enableDirectDBConnection,
|
||||
dbConnectionDatasourceId: this.dbConnectionDatasourceId,
|
||||
@@ -380,6 +384,20 @@ export class ZabbixDatasource {
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Get Zabbix version
|
||||
*/
|
||||
getVersion() {
|
||||
return this.zabbix.getVersion()
|
||||
.then(version => {
|
||||
const zabbixVersion = utils.parseVersion(version);
|
||||
if (!zabbixVersion) {
|
||||
return null;
|
||||
}
|
||||
return zabbixVersion.major;
|
||||
});
|
||||
}
|
||||
|
||||
////////////////
|
||||
// Templating //
|
||||
////////////////
|
||||
|
||||
Reference in New Issue
Block a user