Skip to content

Commit

Permalink
Zebra to DDS authorization Update
Browse files Browse the repository at this point in the history
Signed-off-by: Salisu Ali <salisbuk7897@gmail.com>
  • Loading branch information
salisbuk7897 committed Mar 22, 2021
1 parent d64165e commit 4a1a066
Show file tree
Hide file tree
Showing 10 changed files with 185 additions and 106 deletions.
3 changes: 3 additions & 0 deletions src/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
my.db
my.dbrefresh
node_modules/
126 changes: 100 additions & 26 deletions src/app_server/Controllers/RMF3Controller.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,11 @@ let baseurl = Zconfig.ddsbaseurl;
let baseport = Zconfig.ddsbaseport;
let rmf3filename = Zconfig.rmf3filename;
let mvsResource = Zconfig.mvsResource;
let ddshttp = Zconfig.ddshhttptype;
let lspr = Zconfig.PCI
let ddsauth = Zconfig.ddsauth;
let ddsid = Zconfig.ddsuser;
let ddspass = Zconfig.ddspwd;

/**
* RMFMonitor3getRequest is the GET function for retrieving data from RMF monitor III.
Expand All @@ -18,37 +23,85 @@ let mvsResource = Zconfig.mvsResource;
*/
function RMFMonitor3getRequest(baseurl, baseport, rmf3filename, urlReport, mvsResource, fn) { //fn is to return value from callback
//Use backtick for URL string formatting
var RMF3URL = `https://${baseurl}:${baseport}/gpm/${rmf3filename}?report=${urlReport}&resource=${mvsResource}`; //Dynamically create URL
axios.get(RMF3URL)
.then(function (response) {
// handle success
fn(response.data);
})
.catch(function (error) {
// handle error
fn(error);
})
.then(function () {
// always executed
});
var RMF3URL = `${ddshttp}://${baseurl}:${baseport}/gpm/${rmf3filename}?report=${urlReport}&resource=${mvsResource}`; //Dynamically create URL
if(ddsauth === 'true'){
axios.get(RMF3URL, {
auth: {
username: ddsid,
password: ddspass
}
})
.then(function (response) {
// handle success
fn(response.data);
})
.catch(function (error) {
// handle error
//console.log(error)
fn(error);
})
.then(function () {
// always executed
});
}else{
axios.get(RMF3URL)
.then(function (response) {
// handle success
fn(response.data);
})
.catch(function (error) {
// handle error
//console.log(error)
fn(error);
})
.then(function () {
// always executed
});

}

}

//***** */
function RMFMonitor3getInfo(baseurl, baseport, rmf3filenames, mvsResource, fn) { //fn is to return value from callback
//Use backtick for URL string formatting
var RMF3URL = `https://${baseurl}:${baseport}/gpm/reports/${rmf3filenames}?resource=${mvsResource}`; //Dynamically create URL
axios.get(RMF3URL)
.then(function (response) {
// handle success
fn(response.data);
})
.catch(function (error) {
// handle error
fn(error);
})
.then(function () {
// always executed
});
var RMF3URL = `${ddshttp}://${baseurl}:${baseport}/gpm/reports/${rmf3filenames}?resource=${mvsResource}`; //Dynamically create URL

if(ddsauth === 'true'){
axios.get(RMF3URL, {
auth: {
username: ddsid,
password: ddspass
}
})
.then(function (response) {
// handle success
fn(response.data);
})
.catch(function (error) {
// handle error
//console.log(error)
fn(error);
})
.then(function () {
// always executed
});
}else{
axios.get(RMF3URL)
.then(function (response) {
// handle success
fn(response.data);
})
.catch(function (error) {
// handle error
//console.log(error)
fn(error);
})
.then(function () {
// always executed
});

}
}

/**
Expand Down Expand Up @@ -97,6 +150,27 @@ module.exports.rmfIII = async function (req, res) { //Controller Function for Re
displayUSAGE(urlReport, ulrParm, urlJobParm, function (result) { //A call to displayUSAGE function is made with a callback function as parameter
res.json(result); //Express respond with the result returned from displayUSAGE function
});
} else if (urlReport === "MIPS") { // checks if user has specify the value "USAGE" for report parameter in the URL
displayCPC("CPC", ulrParm, urlJobParm, function (result) { //A call to displayCPC function is mgoing to return a json formatted RMFIII CPC Report
for(i in result["table"]){
if (result["table"][i]["CPCPPNAM"] === "VIRPT"){
var virpt_tou = result["table"][i]['CPCPLTOU'];
var virpt_normalise = parseFloat(virpt_tou) / 100
var virpt_mips = virpt_normalise * lspr

var response = {};
response['lpar_name'] = result["table"][i]['CPCPPNAM'];
response['lpar_tou'] = result["table"][i]['CPCPLTOU'];
response['lpar_tou_normalized'] = virpt_normalise;
response['lpar_mips'] = virpt_mips;

//console.log(response);
res.json(response);
}
}
//console.log(result["table"]["CPCPPNAM"] === "VIRPT");
// //Express respond with the result returned from displayUSAGE function
});
}
}
};
Expand Down
53 changes: 40 additions & 13 deletions src/app_server/Controllers/RMFPPcontroller.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,10 @@ let baseurl = Zconfig.ddsbaseurl;
let baseport = Zconfig.ddsbaseport;
let rmfppfilename = Zconfig.rmfppfilename;
var minutesInterval = Zconfig.ppminutesInterval;
var ddshttp = Zconfig.ddshhttptype;
let ddsauth = Zconfig.ddsauth;
let ddsid = Zconfig.ddsuser;
let ddspass = Zconfig.ddspwd;

/**
* RMFPPgetRequest is the Function for Sending GET Request to RMF Monitor I (Post-Processor Report).
Expand All @@ -17,19 +21,42 @@ var minutesInterval = Zconfig.ppminutesInterval;
*/
function RMFPPgetRequest(baseurl, baseport, rmfppfilename, urlReport, urlDate, fn) { //fn is to return value from callback
//Use backtick for URL string formatting
var RMFPPURL = `https://${baseurl}:${baseport}/gpm/${rmfppfilename}?reports=${urlReport}&date=${urlDate}`; //Dynamically create URL
axios.get(RMFPPURL)
.then(function (response) {
// handle success
fn(response.data);
})
.catch(function (error) {
// handle error
fn(error);
})
.then(function () {
// always executed
});
var RMFPPURL = `${ddshttp}://${baseurl}:${baseport}/gpm/${rmfppfilename}?reports=${urlReport}&date=${urlDate}`; //Dynamically create URL
if(ddsauth === 'true'){
axios.get(RMFPPURL, {
auth: {
username: ddsid,
password: ddspass
}
})
.then(function (response) {
// handle success
fn(response.data);
})
.catch(function (error) {
// handle error
//console.log(error)
fn(error);
})
.then(function () {
// always executed
});
}else{
axios.get(RMFPPURL)
.then(function (response) {
// handle success
fn(response.data);
})
.catch(function (error) {
// handle error
//console.log(error)
fn(error);
})
.then(function () {
// always executed
});

}
};

/**
Expand Down
4 changes: 2 additions & 2 deletions src/app_server/routes/mainRouter.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,9 @@ const fs = require('fs');
var Zconfig = require("../../config/Zconfig");
let grafanabaseurl = Zconfig.grafanaurl;
let grafanabaseport = Zconfig.grafanaport;
let httptype = Zconfig.httptype;
let grafanahttptype = Zconfig.grafanahttptype;
const axios = require('axios');
const grafanaServer = `${httptype}://${grafanabaseurl}:${grafanabaseport}`
const grafanaServer = `${grafanahttptype}://${grafanabaseurl}:${grafanabaseport}`

// Zebra UI routers

Expand Down
29 changes: 14 additions & 15 deletions src/bin/www
Original file line number Diff line number Diff line change
Expand Up @@ -73,28 +73,27 @@ if (httpsparm === "true"){
};

const httpsServer = https.createServer(credentials, app);
httpsServer.listen(config.port+1);
console.log(`https server listening at port ${config.port + 1}`);
httpsServer.listen(config.port);
console.log(`https server listening at secured port ${config.port}`);

}else{
app.set('port', port);
console.log(`http server listening at port ${port}`);
}

/**
* Create HTTP server.
*/

/**
* Create HTTP server.
*/
var server = http.createServer(app);

var server = http.createServer(app);
/**
* Listen on provided port, on all network interfaces.
*/

/**
* Listen on provided port, on all network interfaces.
*/
server.listen(port);
server.on('error', onError);
server.on('listening', onListening);
console.log(`http server listening at port ${port}`);
}

server.listen(port);
server.on('error', onError);
server.on('listening', onListening);

/**
* Normalize a port into a number, string, or false.
Expand Down
8 changes: 7 additions & 1 deletion src/config/Zconfig.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,10 @@
{
"ddshhttptype":"https",
"ddsbaseurl":"salisuali.com",
"ddsbaseport":"8908",
"ddsauth":"false",
"ddsuser":"username",
"ddspwd":"password",
"rmf3filename":"rmfm3.xml",
"rmfppfilename":"rmfpp.xml",
"mvsResource":",SYS,_IMAGE",
Expand All @@ -21,5 +25,7 @@
"usePrometheus":"false",
"https": "false",
"grafanaurl":"localhost",
"grafanaport":"3000"
"grafanaport":"3000",
"grafanahttptype": "http",
"PCI": 2951
}
16 changes: 15 additions & 1 deletion src/cpuRealTimeMetrics.js
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,8 @@ setInterval(() => { // Set interval function allows this routine to run at a spe
var value = 'CPCPLTOU';
var name2 = "EFU_" + JSONBody_lpar['CPCPPNAM']; //append EFU(Effective Utilization) to lpar name
var value2 = 'CPCPPEFU';
var name4 = "MIPS_" + JSONBody_lpar['CPCPPNAM'];
var value4 = 'MIPS';
try {
cpu_lpar = new Prometheus.Gauge({ //create custom prometheus metric for lpar Total Urilization
name: name, // dynamicall add name
Expand All @@ -63,7 +65,19 @@ setInterval(() => { // Set interval function allows this routine to run at a spe
parm: value2 //dynamically set the label value
}, parseFloat(JSONBody_lpar['CPCPPEFU'])); //dynamically set the custom metric value

} catch (err) {
cpu_lpar = new Prometheus.Gauge({ //create custom prometheus metric for lpar MIPS Urilization
name: name4, // dynamicall add name
help: 'lpar MIPS Utilization', //help statement
labelNames: ['parm'] //custom metric label
});

cpu_lpar.set({ //set custom metric value for lpar Total Urilization
parm: value4 //dynamically set the label value
}, (parseFloat(JSONBody_lpar['CPCPLTOU'])/100)*2951); //dynamically set the custom metric value
//console.log();

//
} catch (err) {
//console.log('Caught one' + name);
}
}
Expand Down
2 changes: 1 addition & 1 deletion src/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@
"multer": "^1.4.2",
"nedb": "^1.8.0",
"prom-client": "^12.0.0",
"pug": "^3.0.0",
"pug": "^3.0.1",
"readline": "0.0.x",
"swagger-ui-express": "^4.1.4",
"sweetalert": "^2.1.2",
Expand Down
21 changes: 1 addition & 20 deletions src/sslcert/server.cert
Original file line number Diff line number Diff line change
@@ -1,22 +1,3 @@
-----BEGIN CERTIFICATE-----
MIIENzCCAx+gAwIBAgIEBUx4bjANBgkqhkiG9w0BAQsFADCBnjELMAkGA1UEBhMC
Q1oxDzANBgNVBAgTBlByYWd1ZTEPMA0GA1UEBxMGUHJhZ3VlMRQwEgYDVQQKEwta
b3dlIFNhbXBsZTEcMBoGA1UECxMTQVBJIE1lZGlhdGlvbiBMYXllcjE5MDcGA1UE
AxMwWm93ZSBEZXZlbG9wbWVudCBJbnN0YW5jZXMgQ2VydGlmaWNhdGUgQXV0aG9y
aXR5MB4XDTE5MDExMTEyMTIwN1oXDTI5MDEwODEyMTIwN1owejELMAkGA1UEBhMC
Q1oxDzANBgNVBAgTBlByYWd1ZTEPMA0GA1UEBxMGUHJhZ3VlMRQwEgYDVQQKEwta
b3dlIFNhbXBsZTEcMBoGA1UECxMTQVBJIE1lZGlhdGlvbiBMYXllcjEVMBMGA1UE
AxMMWm93ZSBTZXJ2aWNlMIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEA
jo7rxDzO51tfSmqahMbY6lsXLO+/tXYk1ZcIufsh5L+UMs5StHlfSglbiRgWhfdJ
DTZb9R760klXL7QRYwBcYn3yhdYTsTB0+RJddPlTQzxAx45xV7b+fCtsQqBFZk5a
es/TduyHCHXQRl+iLos13isrl5LSB66ohKxMtflPBeqTM/ptNBbq72XqFCQIZClC
lvMMYnxrW2FNfftxpLQbeFu3KN/8V4gcQoSUvE8YU8PYbVUnuhURActywrxHpke5
q/tYQR8iDb6D1ZwLU8+/rTrnPbZq+O2DP7vRyBP9pHS/WNSxY1sTnz7gQ2OlUL+B
EQLgRXRPc5ev1kwn0kVd8QIDAQABo4GfMIGcMB8GA1UdIwQYMBaAFPA6lVzMZhd6
jkR4JClljOSWs0J1MB0GA1UdJQQWMBQGCCsGAQUFBwMCBggrBgEFBQcDATAOBgNV
HQ8BAf8EBAMCBPAwKwYDVR0RBCQwIoIVbG9jYWxob3N0LmxvY2FsZG9tYWluggls
b2NhbGhvc3QwHQYDVR0OBBYEFJDw32hIl2AHqtLlFJtyVkrIlaGjMA0GCSqGSIb3
DQEBCwUAA4IBAQAwO1TPIg5ebOiotTtJgj2wbyYFBfqljLrBMEfgP6h6ZOkj5fQI
dZSLNmyY/PSk8IHUPE43QzEPV8Bd2zOwtDzbrnfvtuKLuLzPr+shih3gpUoSYGLU
adfdggfy
// Enter your Certificate here
-----END CERTIFICATE-----
29 changes: 2 additions & 27 deletions src/sslcert/server.key
Original file line number Diff line number Diff line change
@@ -1,28 +1,3 @@
-----BEGIN PRIV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esViSj2gmqt3t8ImfGCmwPR9gqm5yhfmQUHXkz
kLK2nlhlywKBgA1nM1HrKT/eouJVA9mtpLJvm7tOFTtKdr5HCKGLUGaMuHE9awZb
be6NFNmcrk0lJk/ddzpyz5jnPwmZ6jGGgVa/oh8kODva28IRGrq1n1tSxZdtqmuX
v6fRP5TzZ93UMjqYtBTk/UtXydvifXRqpX5J87Mqn5yUZPndWRHDq3VbAoGASY/X
l7172ZBAkdjHvDpXJD+lMGIbEI3905uLeYFzTXxcliwa1FFAnFWEs4cGiwMh9M2q
N3V4gXX3XbjWri8hEiM+i9aWmX2zbxjdmndw/vXLAiKovG5sepRidil0kENxQ/dS
GwgnaNp8BB7ToylEs0cr4Z2RZ5/NaOPTUBDerYsCgYAqdGUHDFrRglatMXEDOQAR
nfGRBHcG5wxN+Vp7IsvzbQVRGWexbw5vh+Z1t/JrE3YC0lvKYhKUQTupydrUV9q7
Nol3hUZ31vbpNmd6A+r78wvMletwNxe8/vjsnMEtBX8zjjPtroCqNL1mRvm83qLL
kRv/iliKTDgkH9gupKiElA==
-----END PRIVATE KEY-----
// Enter your Private key here
-----END PRIVATE KEY-----

0 comments on commit 4a1a066

Please sign in to comment.