diff --git a/src/.gitignore b/src/.gitignore new file mode 100644 index 0000000..38afcca --- /dev/null +++ b/src/.gitignore @@ -0,0 +1,3 @@ +my.db +my.dbrefresh +node_modules/ diff --git a/src/app_server/Controllers/RMF3Controller.js b/src/app_server/Controllers/RMF3Controller.js index ac44bae..e109dd9 100644 --- a/src/app_server/Controllers/RMF3Controller.js +++ b/src/app_server/Controllers/RMF3Controller.js @@ -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. @@ -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 + }); + + } } /** @@ -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 + }); } } }; diff --git a/src/app_server/Controllers/RMFPPcontroller.js b/src/app_server/Controllers/RMFPPcontroller.js index b58f6d5..cef57c8 100644 --- a/src/app_server/Controllers/RMFPPcontroller.js +++ b/src/app_server/Controllers/RMFPPcontroller.js @@ -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). @@ -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 + }); + + } }; /** diff --git a/src/app_server/routes/mainRouter.js b/src/app_server/routes/mainRouter.js index 1c9bcd6..0930625 100644 --- a/src/app_server/routes/mainRouter.js +++ b/src/app_server/routes/mainRouter.js @@ -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 diff --git a/src/bin/www b/src/bin/www index 5b235e0..f2d8984 100644 --- a/src/bin/www +++ b/src/bin/www @@ -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. diff --git a/src/config/Zconfig.json b/src/config/Zconfig.json index deb9a49..58cc426 100644 --- a/src/config/Zconfig.json +++ b/src/config/Zconfig.json @@ -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", @@ -21,5 +25,7 @@ "usePrometheus":"false", "https": "false", "grafanaurl":"localhost", - "grafanaport":"3000" + "grafanaport":"3000", + "grafanahttptype": "http", + "PCI": 2951 } \ No newline at end of file diff --git a/src/cpuRealTimeMetrics.js b/src/cpuRealTimeMetrics.js index 4a8875e..e7c1ddd 100644 --- a/src/cpuRealTimeMetrics.js +++ b/src/cpuRealTimeMetrics.js @@ -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 @@ -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); } } diff --git a/src/package.json b/src/package.json index 7be2eac..3d9d7fd 100644 --- a/src/package.json +++ b/src/package.json @@ -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", diff --git a/src/sslcert/server.cert b/src/sslcert/server.cert index 8432f7f..34ec222 100644 --- a/src/sslcert/server.cert +++ b/src/sslcert/server.cert @@ -1,22 +1,3 @@ -----BEGIN CERTIFICATE----- -MIIENzCCAx+gAwIBAgIEBUx4bjANBgkqhkiG9w0BAQsFADCBnjELMAkGA1UEBhMC -Q1oxDzANBgNVBAgTBlByYWd1ZTEPMA0GA1UEBxMGUHJhZ3VlMRQwEgYDVQQKEwta -b3dlIFNhbXBsZTEcMBoGA1UECxMTQVBJIE1lZGlhdGlvbiBMYXllcjE5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Certificate here -----END CERTIFICATE----- diff --git a/src/sslcert/server.key b/src/sslcert/server.key index 97e60ee..0f4e12e 100644 --- a/src/sslcert/server.key +++ b/src/sslcert/server.key @@ -1,28 +1,3 @@ -----BEGIN PRIVATE KEY----- -MIIEvAIBADANBgkqhkiG9w0BAQEFAASCBKYwggSiAgEAAoIBAQCOjuvEPM7nW19K -apqExtjqWxcs77+1diTVlwi5+yHkv5QyzlK0eV9KCVuJGBaF90kNNlv1HvrSSVcv -tBFjAFxiffKF1hOxMHT5El10+VNDPEDHjnFXtv58K2xCoEVmTlp6z9N27IcIddBG -X6IuizXeKyuXktIHrqiErEy1+U8F6pMz+m00FurvZeoUJAhkKUKW8wxifGtbYU19 -+3GktBt4W7co3/xXiBxChJS8TxhTw9htVSe6FREBy3LCvEemR7mr+1hBHyINvoPV -nAtTz7+tOuc9tmr47YM/u9HIE/2kdL9Y1LFjWxOfPuBDY6VQv4ERAuBFdE9zl6/W -TCfSRV3xAgMBAAECggEAPU1sSSi0+HwsT/3jkHFJ2g1tu98lG01ArbCTChbaDlnr -yqU6n20J8vZvLFb1aIpcGZhkltXJmh/7pAHU8DO5hokOf0r9kNZ7lpe1JJYKngEN -AkNYrhV8/bxWg5gT/9h1xBYWoy83KgYvl/OL9GPcuDrsNfPm6XLL+LF3E1GwD6SW -tQSrKtgCeWylhEq+EFXqKxJRuzdYKoJMG/trGOjm68LG6yyP6kUy62Juuxg0EHVZ -8UJ2HK8kCtgm9erCH+ZBwvZKISiqmQYEqbncN1VM7PPZY5kUuiKBbBq8KGrZjJzk -MzyrK35Ch10QaRHUf+NyYtYqU8gNf1N0LKnN0cw5+QKBgQDlaEe/LgJ5zte/zzSp -627KENwGRbO9Y43bFFGbClv83aJlWQGF0EhW2YQ5mbOAqlGASTdJNlvYE0BOsFux -J2/wBN85dDmAxmjDBCGvIAeNJW9VD5Fd8nHDfKZ9ffLYOTwGWNVAMEjDkNQNZRy+ -JsWPxl4Tz8fJLTu4wDZ/NrRzswKBgQCfFV+UUixf9sJ2DlttRLb1ueGj3buDflW4 -qhcSBrbPjRCJQpDgmfzr8DqZsMwbjYdAaJreP/JoUCgJzP9oq7anLX7MA/lYFYgr -0/Gq4Bs4mJyDhiT5qm9c3sBNaWesViSj2gmqt3t8ImfGCmwPR9gqm5yhfmQUHXkz -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----- \ No newline at end of file