Skip to content

Commit

Permalink
Merge pull request #1138 from mountaindude/1135
Browse files Browse the repository at this point in the history
feat(qs-license): Send license expiration info to MQTT
  • Loading branch information
mountaindude authored May 6, 2024
2 parents e47655e + 89684ea commit b3b8500
Showing 1 changed file with 25 additions and 0 deletions.
25 changes: 25 additions & 0 deletions src/lib/qliksense_license.js
Original file line number Diff line number Diff line change
Expand Up @@ -129,6 +129,31 @@ async function checkQlikSenseServerLicenseStatus(config, logger) {
daysUntilExpiry,
});
}

// Check if we should send data to MQTT
if (config.has('Butler.mqttConfig.enable') && config.get('Butler.mqttConfig.enable') === true) {
// Prepare general license payload for MQTT
const mqttPayload = {
licenseExpired,
expiryDateStr,
daysUntilExpiry,
};

// Publish to MQTT
globals.mqttClient.publish(config.get('Butler.mqttConfig.qlikSenseServerLicenseTopic'), JSON.stringify(mqttPayload));

// Should we also publish to a specific topic if the license is about to expire, or has already expired?
if (licenseExpired === true) {
globals.mqttClient.publish(
config.get('Butler.mqttConfig.qlikSenseServerLicenseExpireTopic'),
`Qlik Sense server license expired on ${expiryDateStr}`
);
} else if (daysUntilExpiry <= config.get('Butler.qlikSenseLicense.serverLicenseMonitor.alert.thresholdDays')) {
const mqttAlertPayload = `Qlik Sense server license is about to expire in ${daysUntilExpiry} days, on ${expiryDateStr}`;

globals.mqttClient.publish(config.get('Butler.mqttConfig.qlikSenseServerLicenseExpireTopic'), mqttAlertPayload);
}
}
} catch (err) {
logger.error(`QLIKSENSE SERVER LICENSE MONITOR: ${err}`);
if (err.stack) {
Expand Down

0 comments on commit b3b8500

Please sign in to comment.