suseendhiran
This commit is contained in:
parent
126ad3deb9
commit
d756ed3e58
@ -5,18 +5,20 @@ const request = require('request');
|
||||
|
||||
|
||||
|
||||
|
||||
// api status check Api
|
||||
exports.APIstatus = async (req, res) =>
|
||||
{
|
||||
try
|
||||
{
|
||||
token_data = await TestHelper.TokenAPI();
|
||||
apiArr = [ ];
|
||||
serverArr = [ ];
|
||||
dbArr = [ ];
|
||||
StatusFailArr = [ ];
|
||||
ApiData = JSON.parse(process.env.STATUSARRAY);
|
||||
token_data = await TestHelper.TokenAPI();
|
||||
if (token_data.status == 200) { apiArr.push({ "Api" : "Token Api" , "StatusCode" : token_data.status , "Status" : "Up"}); }
|
||||
else { apiArr.push({ "Api" : "Token Api" , "StatusCode" : token_data.status , "Status" : "Down"}); StatusFailArr.push(token_data.status) }
|
||||
ApiData = await JSON.parse(process.env.STATUSARRAY);
|
||||
if (token_data.status == 200) { apiArr.push({ "Api" : "Token API" , "StatusCode" : token_data.status , "Status" : "Up"}); }
|
||||
else { apiArr.push({ "Api" : "Token API" , "StatusCode" : token_data.status , "Status" : "Down"}); StatusFailArr.push(token_data.status) }
|
||||
for (const object of ApiData)
|
||||
{
|
||||
reqObj = { };
|
||||
@ -28,16 +30,18 @@ exports.APIstatus = async (req, res) =>
|
||||
request(reqObj, async function (error, response, body) {
|
||||
if (response.statusCode == 200)
|
||||
{
|
||||
if (object.type == "api") { apiArr.push({ "Api" : object.name , "StatusCode" : response.statusCode , "Status" : "Up"}); }
|
||||
else { serverArr.push({ "Api" : object.name , "StatusCode" : response.statusCode , "Status" : "Up"}); }
|
||||
if (object.type == "api") { apiArr.push({ "Api" : object.name , "StatusCode" : response.statusCode , "Status" : "Up"}); }
|
||||
if (object.type == "server") { serverArr.push({ "Api" : object.name , "StatusCode" : response.statusCode , "Status" : "Up"}); }
|
||||
if (object.type == "db") { dbArr.push({ "Api" : object.name , "StatusCode" : response.statusCode , "Status" : "Up"}); }
|
||||
}
|
||||
if (response.statusCode != 200)
|
||||
{
|
||||
if (object.type == "api") { apiArr.push({ "Api" : object.name , "StatusCode" : response.statusCode , "Status" : "Down"}); StatusFailArr.push(token_data.status) }
|
||||
else { serverArr.push({ "Api" : object.name , "StatusCode" : response.statusCode , "Status" : "Down"}); StatusFailArr.push(token_data.status) }
|
||||
if (object.type == "api") { apiArr.push({ "Api" : object.name , "StatusCode" : response.statusCode , "Status" : "Down"}); StatusFailArr.push(response.statusCode) }
|
||||
if (object.type == "server") { serverArr.push({ "Api" : object.name , "StatusCode" : response.statusCode , "Status" : "Down"}); StatusFailArr.push(response.statusCode) }
|
||||
if (object.type == "db") { dbArr.push({ "Api" : object.name , "StatusCode" : response.statusCode , "Status" : "Down"}); StatusFailArr.push(response.statusCode) }
|
||||
}
|
||||
if (ApiData.length + 1 == apiArr.length + serverArr.length) {
|
||||
await TestHelper.HTML( req , res , apiArr , serverArr , StatusFailArr );
|
||||
if (ApiData.length + 1 == apiArr.length + serverArr.length + dbArr.length) {
|
||||
await TestHelper.HTML( req , res , apiArr , serverArr , dbArr , StatusFailArr );
|
||||
}
|
||||
})
|
||||
};
|
||||
@ -60,10 +64,10 @@ exports.SingleApiStatus = async (req, res) =>
|
||||
ApiName = req.body.api;
|
||||
ApiData = JSON.parse(process.env.STATUSARRAY);
|
||||
token_data = await TestHelper.TokenAPI();
|
||||
if (ApiName == "Token Api")
|
||||
if (ApiName == "Token API")
|
||||
{
|
||||
if (token_data.status == 200) { res.send({ "Api" : "Token Api" , "StatusCode" : token_data.status , "Status" : "Up" , "success" : true}) }
|
||||
else { res.send({ "Api" : "Token Api" , "StatusCode" : token_data.status , "Status" : "Down" , "success" : true}) }
|
||||
if (token_data.status == 200) { res.send({ "Api" : "Token API" , "StatusCode" : token_data.status , "Status" : "Up" , "success" : true}) }
|
||||
else { res.send({ "Api" : "Token API" , "StatusCode" : token_data.status , "Status" : "Down" , "success" : true}) }
|
||||
}
|
||||
else
|
||||
{
|
||||
|
||||
@ -16,7 +16,6 @@ module.exports = app => {
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
// routes started here
|
||||
app.use('/api', router);
|
||||
|
||||
@ -23,33 +23,32 @@ function TokenAPI()
|
||||
}
|
||||
}
|
||||
|
||||
function HTML( req , res , apiStatusArr , serverStatusArr , apiFailStatusArr )
|
||||
|
||||
function HTML( req , res , apiStatusArr , serverStatusArr , dbStatusArr , apiFailStatusArr )
|
||||
{
|
||||
try
|
||||
{
|
||||
date = new Date().toLocaleTimeString();
|
||||
if (apiFailStatusArr.length == 0)
|
||||
{
|
||||
res.render( 'status' , { data : apiStatusArr , data1 : serverStatusArr , down : 0 , date : date } , function (err, html ) {
|
||||
res.render( 'status' , { data : apiStatusArr , data1 : serverStatusArr , data2 : dbStatusArr , down : 0 , date : date } , function (err, html ) {
|
||||
res.send(html)
|
||||
})
|
||||
}
|
||||
else
|
||||
{
|
||||
res.render( 'status' , { data : apiStatusArr , data1 : serverStatusArr , down : 1 , date : date } , function (err, html ) {
|
||||
res.render( 'status' , { data : apiStatusArr , data1 : serverStatusArr , data2 : dbStatusArr , down : 1 , date : date } , function (err, html ) {
|
||||
res.send(html)
|
||||
})
|
||||
}
|
||||
}
|
||||
}
|
||||
catch (error) {
|
||||
console.log(error);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
module.exports = {
|
||||
|
||||
TokenAPI : TokenAPI,
|
||||
HTML : HTML
|
||||
|
||||
HTML : HTML
|
||||
}
|
||||
@ -3,32 +3,25 @@
|
||||
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/4.7.0/css/font-awesome.min.css">
|
||||
<link href="//maxcdn.bootstrapcdn.com/bootstrap/4.1.1/css/bootstrap.min.css" rel="stylesheet" id="bootstrap-css">
|
||||
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
|
||||
<!-- CSS -->
|
||||
<link rel="stylesheet" href="//cdn.jsdelivr.net/npm/alertifyjs@1.13.1/build/css/alertify.min.css" />
|
||||
<!-- Default theme -->
|
||||
<link rel="stylesheet" href="//cdn.jsdelivr.net/npm/alertifyjs@1.13.1/build/css/themes/default.min.css" />
|
||||
<!-- JavaScript -->
|
||||
<script src="//cdn.jsdelivr.net/npm/alertifyjs@1.13.1/build/alertify.min.js"></script>
|
||||
<script>
|
||||
setInterval(function() {
|
||||
window.location.reload();
|
||||
}, 300000);
|
||||
</script>
|
||||
<style>
|
||||
/* table, th, td {
|
||||
border:1px solid rgb(20, 2, 2);
|
||||
padding: 8px;
|
||||
border-bottom: 1px solid #DDD;
|
||||
text-align: center;
|
||||
}
|
||||
table {
|
||||
border-collapse: collapse;
|
||||
border: 2px solid #161614;
|
||||
width: 87%;
|
||||
}
|
||||
th {
|
||||
font-size: 20px;
|
||||
}
|
||||
th , h1 , td {
|
||||
font-family: Arial, Helvetica, sans-serif;
|
||||
} */
|
||||
b {
|
||||
font-family: Arial, Helvetica, sans-serif;
|
||||
color: #3bd671 !important
|
||||
color: #3bd671 !important;
|
||||
}
|
||||
b1 {
|
||||
font-family: Arial, Helvetica, sans-serif;
|
||||
color: red
|
||||
}
|
||||
.dot {
|
||||
height: 25px;
|
||||
@ -153,6 +146,24 @@
|
||||
left: 220px;
|
||||
top: 100px;
|
||||
}
|
||||
.header6 {
|
||||
background: white;
|
||||
text-align: left;
|
||||
padding: 10px 0;
|
||||
width: 80%;
|
||||
position: relative;
|
||||
left: 220px;
|
||||
top: 100px;
|
||||
}
|
||||
.header7 {
|
||||
background: white;
|
||||
text-align: left;
|
||||
padding: 10px 0;
|
||||
width: 80%;
|
||||
position: relative;
|
||||
left: 220px;
|
||||
top: 100px;
|
||||
}
|
||||
.uk-text-primary {
|
||||
color: #3bd671 !important;
|
||||
}
|
||||
@ -166,24 +177,28 @@
|
||||
width: 87%;
|
||||
}
|
||||
|
||||
#tab-des td, #tab-des th {
|
||||
#tab-des th , #tab-des td {
|
||||
border: 1px solid #ddd;
|
||||
width: 0em;
|
||||
padding: 8px;
|
||||
text-align: center;
|
||||
|
||||
}
|
||||
|
||||
#tab-des tr:nth-child(even){background-color: #f2f2f2;}
|
||||
|
||||
#tab-des tr:hover {background-color: #ddd;}
|
||||
#tab-des tr:hover {
|
||||
background-color: #ddd;
|
||||
}
|
||||
|
||||
#tab-des th {
|
||||
padding-top: 12px;
|
||||
padding-bottom: 12px;
|
||||
text-align: left;
|
||||
text-align: center;
|
||||
background-color: #04AA6D;
|
||||
color: white;
|
||||
}
|
||||
|
||||
|
||||
#tab-des-2 {
|
||||
font-family: Arial, Helvetica, sans-serif;
|
||||
border-collapse: collapse;
|
||||
@ -195,6 +210,7 @@
|
||||
border: 1px solid #ddd;
|
||||
width: 0em;
|
||||
padding: 8px;
|
||||
text-align: center;
|
||||
}
|
||||
|
||||
#tab-des-2 tr:nth-child(even){background-color: #f2f2f2;}
|
||||
@ -204,10 +220,21 @@
|
||||
#tab-des-2 th {
|
||||
padding-top: 12px;
|
||||
padding-bottom: 12px;
|
||||
text-align: left;
|
||||
text-align: center;
|
||||
background-color: #04AA6D;
|
||||
color: white;
|
||||
}
|
||||
|
||||
.xd-content .xd-body .xd-body-inner {
|
||||
max-height: unset;
|
||||
}
|
||||
.xd-content .xd-body p {
|
||||
color: #f0f;
|
||||
text-shadow: 0 0 5px rgba(0, 0, 0, 0.75);
|
||||
}
|
||||
.xd-content .xd-button.xd-ok {
|
||||
background: #734caf;
|
||||
}
|
||||
</style>
|
||||
<title class="bi-alarm">Status</title>
|
||||
<% if ( down == 0) { %>
|
||||
@ -220,7 +247,7 @@
|
||||
<body>
|
||||
<div class = "header">
|
||||
<div>
|
||||
<h1 class="with-in-header">Service status</h1>
|
||||
<h1 class="with-in-header">Service Status</h1>
|
||||
<div class="last-update">
|
||||
Last updated <%=date %>
|
||||
</div>
|
||||
@ -236,12 +263,12 @@
|
||||
<% } %>
|
||||
</div>
|
||||
</div>
|
||||
<div class = "header2"><h1><i style="font-size:18px;color:black"></i> <strong>Api Services</strong></h1></div>
|
||||
<div class = "header2"><h1><i style="font-size:18px;color:black"></i> <strong>API Services</strong></h1></div>
|
||||
<div class = "header3">
|
||||
<table id="tab-des">
|
||||
<thead>
|
||||
<tr>
|
||||
<th>Api</th>
|
||||
<th>API</th>
|
||||
<th>StatusCode</th>
|
||||
<th>Status</th>
|
||||
<th>Refresh</th>
|
||||
@ -249,8 +276,8 @@
|
||||
</thead>
|
||||
<% data.forEach(function(status , index ) { %>
|
||||
<tbody>
|
||||
<tr class=index>
|
||||
<td><%=status.Api %></td>
|
||||
<tr>
|
||||
<td><div style="text-align: left;"><%=status.Api %></div></td>
|
||||
<td><%=status.StatusCode %></td>
|
||||
<td>
|
||||
<% if( status.Status == "Up") { %>
|
||||
@ -260,7 +287,7 @@
|
||||
<i class="dot1" style="font-size:14px;color: red;height:15px;width:15px;"></i> <b1><%=status.Status %></b1>
|
||||
<% } %>
|
||||
</td>
|
||||
<td><a href="#" class="btn btn-info btn-sm" style="color: white;background-color: #3bd671 !important;">Refresh</a></td>
|
||||
<td class=index><a href="#" class="btn btn-info btn-sm" style="color: white;background-color: #3bd671 !important;">Refresh</a></td>
|
||||
</tr>
|
||||
</tbody>
|
||||
<% }) %>
|
||||
@ -279,8 +306,8 @@
|
||||
</thead>
|
||||
<% data1.forEach(function(status , index ) { %>
|
||||
<tbody>
|
||||
<tr class=index>
|
||||
<td><%=status.Api %></td>
|
||||
<tr>
|
||||
<td><div style="text-align: left;"><%=status.Api %></div></td>
|
||||
<td><%=status.StatusCode %></td>
|
||||
<td>
|
||||
<% if( status.Status == "Up") { %>
|
||||
@ -290,7 +317,37 @@
|
||||
<i class="dot1" style="font-size:14px;color: red;height:15px;width:15px;"></i> <b1><%=status.Status %></b1>
|
||||
<% } %>
|
||||
</td>
|
||||
<td><a href="#" class="btn btn-info btn-sm" style="color: white;background-color: #3bd671 !important;">Refresh</a></td>
|
||||
<td class=index><a href="#" class="btn btn-info btn-sm" style="color: white;background-color: #3bd671 !important;">Refresh</a></td>
|
||||
</tr>
|
||||
</tbody>
|
||||
<% }) %>
|
||||
</table>
|
||||
</div>
|
||||
<div class = "header6"><h1><i style="font-size:18px;color:black"></i> <strong>Database Services</strong></h1></div>
|
||||
<div class = "header7">
|
||||
<table id="tab-des-2">
|
||||
<thead>
|
||||
<tr>
|
||||
<th>Database</th>
|
||||
<th>StatusCode</th>
|
||||
<th>Status</th>
|
||||
<th>Refresh</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<% data2.forEach(function(status , index ) { %>
|
||||
<tbody>
|
||||
<tr>
|
||||
<td><div style="text-align: left;"><%=status.Api %></div></td>
|
||||
<td><%=status.StatusCode %></td>
|
||||
<td>
|
||||
<% if( status.Status == "Up") { %>
|
||||
<i class="dot" style="font-size:14px;color: #3bd671 !important;height:15px;width:15px;"></i> <b><%=status.Status %></b>
|
||||
<% } %>
|
||||
<% if( status.Status == "Down") { %>
|
||||
<i class="dot1" style="font-size:14px;color: red;height:15px;width:15px;"></i> <b1><%=status.Status %></b1>
|
||||
<% } %>
|
||||
</td>
|
||||
<td class=index><a href="#" class="btn btn-info btn-sm" style="color: white;background-color: #3bd671 !important;">Refresh</a></td>
|
||||
</tr>
|
||||
</tbody>
|
||||
<% }) %>
|
||||
@ -309,7 +366,10 @@
|
||||
success: function(response) {
|
||||
if (response.success == true)
|
||||
{
|
||||
alert(response.Api+" called");
|
||||
alertify.alert(response.Api+" called", () => {
|
||||
// alertify.message('OK');
|
||||
}).set('title', 'Status')
|
||||
// alert(response.Api+" called");
|
||||
if (response.Status == "Up")
|
||||
{
|
||||
var success = '<i class="dot" style="font-size:14px;color: #3bd671 !important;height:15px;width:15px;"></i> <b>'+response.Status+'</b>'
|
||||
|
||||
15
package-lock.json
generated
15
package-lock.json
generated
@ -22,6 +22,7 @@
|
||||
"sequelize": "^6.6.5",
|
||||
"swagger-jsdoc": "^6.1.0",
|
||||
"swagger-ui-express": "^4.1.6",
|
||||
"sweetalert2": "^11.4.32",
|
||||
"winston": "^3.3.3",
|
||||
"winston-daily-rotate-file": "^4.5.5"
|
||||
},
|
||||
@ -10676,6 +10677,15 @@
|
||||
"express": ">=4.0.0"
|
||||
}
|
||||
},
|
||||
"node_modules/sweetalert2": {
|
||||
"version": "11.4.32",
|
||||
"resolved": "https://registry.npmjs.org/sweetalert2/-/sweetalert2-11.4.32.tgz",
|
||||
"integrity": "sha512-fcXWPzWjqYoLqlfPLL4GHpZDZr4Lm7opkaADKAD1LDM4KHJ5ZHN/8/Les5HWP7+yl+0mrqHHkbsSxjXdvDHHlg==",
|
||||
"funding": {
|
||||
"type": "individual",
|
||||
"url": "https://sweetalert2.github.io/#donations"
|
||||
}
|
||||
},
|
||||
"node_modules/tapable": {
|
||||
"version": "0.2.9",
|
||||
"resolved": "https://registry.npmjs.org/tapable/-/tapable-0.2.9.tgz",
|
||||
@ -21473,6 +21483,11 @@
|
||||
"swagger-ui-dist": ">=4.1.3"
|
||||
}
|
||||
},
|
||||
"sweetalert2": {
|
||||
"version": "11.4.32",
|
||||
"resolved": "https://registry.npmjs.org/sweetalert2/-/sweetalert2-11.4.32.tgz",
|
||||
"integrity": "sha512-fcXWPzWjqYoLqlfPLL4GHpZDZr4Lm7opkaADKAD1LDM4KHJ5ZHN/8/Les5HWP7+yl+0mrqHHkbsSxjXdvDHHlg=="
|
||||
},
|
||||
"tapable": {
|
||||
"version": "0.2.9",
|
||||
"resolved": "https://registry.npmjs.org/tapable/-/tapable-0.2.9.tgz",
|
||||
|
||||
@ -22,6 +22,7 @@
|
||||
"sequelize": "^6.6.5",
|
||||
"swagger-jsdoc": "^6.1.0",
|
||||
"swagger-ui-express": "^4.1.6",
|
||||
"sweetalert2": "^11.4.32",
|
||||
"winston": "^3.3.3",
|
||||
"winston-daily-rotate-file": "^4.5.5"
|
||||
},
|
||||
|
||||
Loading…
Reference in New Issue
Block a user