Skip to content

Commit

Permalink
Merge pull request #1049 from mountaindude/1042
Browse files Browse the repository at this point in the history
1042
  • Loading branch information
mountaindude authored Apr 8, 2024
2 parents d82c202 + bac1258 commit b7d64b6
Show file tree
Hide file tree
Showing 6 changed files with 710 additions and 343 deletions.
52 changes: 42 additions & 10 deletions src/butler.js
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ const start = async () => {
globals.logger.verbose(`START: Globals init done: ${globals.initialised}`);

const setupServiceMonitorTimer = (await import('./lib/service_monitor.js')).default;
const setupQlikSenseLicenseMonitor = (await import('./lib/qliksense_license_monitor.js')).default;
const { setupQlikSenseLicenseMonitor, setupQlikSenseLicenseRelease } = await import('./lib/qliksense_license.js');

// The build function creates a new instance of the App class and returns it.
const build = (await import('./app.js')).default;
Expand All @@ -41,22 +41,43 @@ const start = async () => {
'./lib/assert/assert_config_file.js'
);

// Verify correct structure of config file
configFileStructureAssert(globals.config, globals.logger);

// Verify that config file is valid YAML
configFileStructureAssert(globals.config, globals.logger);
let resAssert = await configFileYamlAssert(globals.configFileExpanded);
if (resAssert === false) {
globals.logger.error('MAIN: Config file is not valid YAML. Exiting.');
process.exit(1);
} else {
globals.logger.info('MAIN: Config file is valid YAML - all good.');
}

// Verify that config file is valid YAML
configFileYamlAssert(globals.configFileExpanded);
// Verify correct structure of config file
resAssert = await configFileStructureAssert(globals.config, globals.logger);
if (resAssert === false) {
globals.logger.error('MAIN: Config file structure is incorrect. Exiting.');
process.exit(1);
} else {
globals.logger.info('MAIN: Config file structure is correct - all good.');
}

// Verify select parts/values in config file
if (globals.options.qsConnection) {
// Verify that the config file contains the required data related to New Relic
configFileNewRelicAssert(globals.config, globals.configQRS, globals.logger);
resAssert = await configFileNewRelicAssert(globals.config, globals.configQRS, globals.logger);
if (resAssert === false) {
globals.logger.error('MAIN: Config file does not contain required New Relic data. Exiting.');
process.exit(1);
} else {
globals.logger.info('MAIN: Config file contains required New Relic data - all good.');
}

// Verify that the config file contains the required data related to InfluxDb
configFileInfluxDbAssert(globals.config, globals.configQRS, globals.logger);
resAssert = await configFileInfluxDbAssert(globals.config, globals.configQRS, globals.logger);
if (resAssert === false) {
globals.logger.error('MAIN: Config file does not contain required InfluxDb data. Exiting.');
process.exit(1);
} else {
globals.logger.info('MAIN: Config file contains required InfluxDb data - all good.');
}
}

// Ensure that initialisation of globals is complete
Expand All @@ -71,7 +92,7 @@ const start = async () => {
globals.logger.info('START: Sleeping 5 seconds to allow globals to be initialised.');
await sleepLocal(5000);
} else {
globals.logger.info('START: Globals initialised, all good.');
globals.logger.info('START: Globals initialised - all good.');
}

const apps = await build({});
Expand Down Expand Up @@ -183,6 +204,17 @@ const start = async () => {
setupQlikSenseLicenseMonitor(globals.config, globals.logger);
}

// Set up Qlik Sense license release, if enabled in the config file
// Enable only if at least one license type is enabled for automatic release
if (
globals.config.has('Butler.qlikSenseLicense.licenseRelease.enable') &&
globals.config.get('Butler.qlikSenseLicense.licenseRelease.enable') === true &&
(globals.config.get('Butler.qlikSenseLicense.licenseRelease.licenseType.analyzer.enable') === true ||
globals.config.get('Butler.qlikSenseLicense.licenseRelease.licenseType.professional.enable') === true)
) {
setupQlikSenseLicenseRelease(globals.config, globals.logger);
}

// Prepare to listen on port Y for incoming UDP connections regarding failed tasks
globals.udpServerReloadTaskSocket = dgram.createSocket({
type: 'udp4',
Expand Down
30 changes: 27 additions & 3 deletions src/config/production_template.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -140,12 +140,36 @@ Butler:
qlikSenseLicense:
licenseMonitor:
enable: true
frequency: every 5 minutes
frequency: every 6 hours
destination:
influxDb: # Send service alerts to InfluxDB
influxDb: # Store license data in InfluxDB
enable: true
tag:
static: # Static attributes/dimensions to attach to the data sent to New Relic.
static: # Static attributes/tags to attach to the data sent to InflixDB
- name: foo
value: bar
licenseRelease:
enable: true
frequency: every 6 hours
neverReleaseUsers:
- userDir: 'INTERNAL'
userId: 'sa_repository'
- userDir: 'INTERNAL'
userId: 'sa_api'
- userDir: 'USERDIR'
userId: 'qs_admin_account'
licenseType: # License types to monitor and release
analyzer:
enable: true
releaseThresholdDays: 5
professional:
enable: true
releaseThresholdDays: 5
destination:
influxDb: # Store info about released licenses in InfluxDB
enable: true
tag:
static: # Static attributes/tags to attach to the data sent to InflixDB
- name: foo
value: bar

Expand Down
Loading

0 comments on commit b7d64b6

Please sign in to comment.