Skip to content

Instantly share code, notes, and snippets.

@fbraem
Created March 15, 2019 14:30
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save fbraem/06f1ad3512b3b7da7665af4e6a7fa740 to your computer and use it in GitHub Desktop.
Save fbraem/06f1ad3512b3b7da7665af4e6a7fa740 to your computer and use it in GitHub Desktop.
Check MQ attributes meet standards using JavaScript and MQWeb
// Doing the same as https://mqgem.wordpress.com/2019/03/11/attributes-standards-mqscx/
// But using JavaScript and MQWeb (https://www.mqweb.org)
var http = require('http');
var options = {
hostname : '127.0.0.1',
port : 8081,
path : '/api/queue/inquire/PIGEON',
method : 'GET',
headers : {
}
};
var localQStandards = [
{
test: 'MaxQDepth > 100',
func: ({MaxQDepth}) => MaxQDepth ? MaxQDepth.value > 100 : true
},
{
test: 'InhibitPut = Enabled',
func: ({InhibitPut}) => InhibitPut ? InhibitPut.text === 'Allowed' : true
},
{
test: 'InhibitGet = Enabled',
func: ({InhibitGet}) => InhibitGet ? InhibitGet.text === 'Allowed' : true
},
{
test: 'Queue depth events',
func: ({QDepthLowEvent, QDepthHighEvent}) => {
return QDepthLowEvent ?
QDepthLowEvent.text === 'Enabled' || QDepthHighEvent.text === 'Enabled'
: true;
}
}
];
var req = http.request(options, function(res) {
var output = '';
res.setEncoding('utf8');
res.on('data', function (data) {
output += data;
});
res.on('end', function() {
var json = JSON.parse(output);
if ( json.error ) {
console.log("An MQException occurred: RC= " + json.error.reason.code + " - " + json.error.reason.desc);
}
else {
if ( json.data ) {
for(q in json.data) {
localQStandards.forEach((standard) => {
var result = standard.func(json.data[q]);
if (!result) {
console.log('Queue', json.data[q].QName.value, 'does not meet standard', standard.test);
}
});
}
}
}
});
});
req.on('error', function(e) {
console.log('problem with request: ' + e.message);
});
req.end();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment