Skip to content

Commit

Permalink
Merge pull request #1086 from mountaindude/1084
Browse files Browse the repository at this point in the history
1084
  • Loading branch information
mountaindude authored Apr 12, 2024
2 parents 5c06f13 + 165df1b commit 52bfc4d
Show file tree
Hide file tree
Showing 3 changed files with 66 additions and 49 deletions.
24 changes: 12 additions & 12 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 3 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@
"mkdirp": "^3.0.1",
"moment": "^2.30.1",
"moment-precise-range-plugin": "^1.3.0",
"mqtt": "^5.5.0",
"mqtt": "^5.5.2",
"ms-teams-wrapper": "^1.0.2",
"nodemailer": "^6.9.13",
"nodemailer-express-handlebars": "^6.1.2",
Expand All @@ -103,15 +103,15 @@
"winston": "^3.13.0",
"winston-daily-rotate-file": "^5.0.0",
"ws": "^8.16.0",
"xstate": "^5.9.1"
"xstate": "^5.10.0"
},
"devDependencies": {
"@babel/eslint-parser": "^7.24.1",
"@babel/plugin-syntax-import-assertions": "^7.24.1",
"eslint-plugin-import": "^2.29.1",
"jest": "^29.7.0",
"prettier": "^3.2.5",
"snyk": "^1.1287.0"
"snyk": "^1.1288.0"
},
"pkg": {
"assets": [
Expand Down
85 changes: 51 additions & 34 deletions src/lib/post_to_influxdb.js
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,6 @@ export async function postQlikSenseLicenseStatusToInfluxDB(qlikSenseLicenseStatu
const configTags = globals.config.get('Butler.qlikSenseLicense.licenseMonitor.destination.influxDb.tag.static');

const tags = {
license_type: 'analyzer_access',
butler_instance: instanceTag,
};

Expand All @@ -116,11 +115,14 @@ export async function postQlikSenseLicenseStatusToInfluxDB(qlikSenseLicenseStatu

// Is there any data for "analyzerAccess" license type?
if (qlikSenseLicenseStatus.analyzerAccess.enabled === true) {
tags.license_type = 'analyzer_access';
tags.license_type = 'analyzer';

// Do a deep clone of the tags object
const tagsCloned = _.cloneDeep(tags);

datapoint.push({
measurement: 'qlik_sense_license',
tags,
tags: tagsCloned,
fields: {
allocated: qlikSenseLicenseStatus.analyzerAccess.allocated,
available: qlikSenseLicenseStatus.analyzerAccess.available,
Expand All @@ -134,42 +136,32 @@ export async function postQlikSenseLicenseStatusToInfluxDB(qlikSenseLicenseStatu

// Is there any data for "analyzerTimeAccess" license type?
if (qlikSenseLicenseStatus.analyzerTimeAccess.enabled === true) {
tags.license_type = 'analyzer_time_access';

datapoint.push({
measurement: 'qlik_sense_license',
tags,
fields: {
allocatedMinutes: qlikSenseLicenseStatus.analyzerTimeAccess.allocatedMinutes,
unavailableMinutes: qlikSenseLicenseStatus.analyzerTimeAccess.unavailableMinutes,
usedMinutes: qlikSenseLicenseStatus.analyzerTimeAccess.usedMinutes,
},
});
}
tags.license_type = 'analyzer_capacity';

// Is there any data for "loginAccess" license type?
if (qlikSenseLicenseStatus.loginAccess.enabled === true) {
tags.license_type = 'login_access';
// Do a deep clone of the tags object
const tagsCloned = _.cloneDeep(tags);

datapoint.push({
measurement: 'qlik_sense_license',
tags,
tags: tagsCloned,
fields: {
allocatedTokens: qlikSenseLicenseStatus.loginAccess.allocatedTokens,
tokenCost: qlikSenseLicenseStatus.loginAccess.tokenCost,
unavailableTokens: qlikSenseLicenseStatus.loginAccess.unavailableTokens,
usedTokens: qlikSenseLicenseStatus.loginAccess.usedTokens,
allocated_minutes: qlikSenseLicenseStatus.analyzerTimeAccess.allocatedMinutes,
unavailable_minutes: qlikSenseLicenseStatus.analyzerTimeAccess.unavailableMinutes,
used_minutes: qlikSenseLicenseStatus.analyzerTimeAccess.usedMinutes,
},
});
}

// Is there any data for "professionalAccess" license type?
if (qlikSenseLicenseStatus.professionalAccess.enabled === true) {
tags.license_type = 'professional_access';
tags.license_type = 'professional';

// Do a deep clone of the tags object
const tagsCloned = _.cloneDeep(tags);

datapoint.push({
measurement: 'qlik_sense_license',
tags,
tags: tagsCloned,
fields: {
allocated: qlikSenseLicenseStatus.professionalAccess.allocated,
available: qlikSenseLicenseStatus.professionalAccess.available,
Expand All @@ -181,18 +173,40 @@ export async function postQlikSenseLicenseStatusToInfluxDB(qlikSenseLicenseStatu
});
}

// Is there any data for "loginAccess" license type?
if (qlikSenseLicenseStatus.loginAccess.enabled === true) {
tags.license_type = 'token_login';

// Do a deep clone of the tags object
const tagsCloned = _.cloneDeep(tags);

datapoint.push({
measurement: 'qlik_sense_license',
tags: tagsCloned,
fields: {
allocated_tokens: qlikSenseLicenseStatus.loginAccess.allocatedTokens,
token_cost: qlikSenseLicenseStatus.loginAccess.tokenCost,
unavailable_tokens: qlikSenseLicenseStatus.loginAccess.unavailableTokens,
used_tokens: qlikSenseLicenseStatus.loginAccess.usedTokens,
},
});
}

// Is there any data for "userAccess" license type?
if (qlikSenseLicenseStatus.userAccess.enabled === true) {
tags.license_type = 'user_access';
tags.license_type = 'token_user';

// Do a deep clone of the tags object
const tagsCloned = _.cloneDeep(tags);

datapoint.push({
measurement: 'qlik_sense_license',
tags,
tags: tagsCloned,
fields: {
allocatedTokens: qlikSenseLicenseStatus.userAccess.allocatedTokens,
quarantinedTokens: qlikSenseLicenseStatus.userAccess.quarantinedTokens,
tokenCost: qlikSenseLicenseStatus.userAccess.tokenCost,
userTokens: qlikSenseLicenseStatus.userAccess.userTokens,
allocated_tokens: qlikSenseLicenseStatus.userAccess.allocatedTokens,
quarantined_tokens: qlikSenseLicenseStatus.userAccess.quarantinedTokens,
token_cost: qlikSenseLicenseStatus.userAccess.tokenCost,
used_tokens: qlikSenseLicenseStatus.userAccess.userTokens,
},
});
}
Expand All @@ -201,12 +215,15 @@ export async function postQlikSenseLicenseStatusToInfluxDB(qlikSenseLicenseStatu
if (qlikSenseLicenseStatus.tokensEnabled === true) {
tags.license_type = 'tokens_available';

// Do a deep clone of the tags object
const tagsCloned = _.cloneDeep(tags);

datapoint.push({
measurement: 'qlik_sense_license',
tags,
tags: tagsCloned,
fields: {
availableTokens: qlikSenseLicenseStatus.availableTokens,
totalTokens: qlikSenseLicenseStatus.totalTokens,
available_tokens: qlikSenseLicenseStatus.availableTokens,
total_tokens: qlikSenseLicenseStatus.totalTokens,
},
});
}
Expand Down

0 comments on commit 52bfc4d

Please sign in to comment.