Create function check status for other system
This commit is contained in:
parent
c944e29c51
commit
300bd5651f
|
|
@ -862,6 +862,18 @@ const checkMultipleRequest = async () => {
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
const runExec = (command) => {
|
||||||
|
return new Promise((resolve, reject) => {
|
||||||
|
exec(command, (error, stdout, stderr) => {
|
||||||
|
if (error) {
|
||||||
|
reject(error);
|
||||||
|
} else {
|
||||||
|
resolve(stdout);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
const promises = requests.map(async (req, index) => {
|
const promises = requests.map(async (req, index) => {
|
||||||
if (req.method === "POST") {
|
if (req.method === "POST") {
|
||||||
await axios
|
await axios
|
||||||
|
|
@ -915,57 +927,46 @@ const checkMultipleRequest = async () => {
|
||||||
}
|
}
|
||||||
|
|
||||||
if (req.method === "SSH") {
|
if (req.method === "SSH") {
|
||||||
await exec(req.url, (error, stdout, stderr) => {
|
|
||||||
if (error) {
|
|
||||||
allResponse+=JSON.stringify(req.name+"\n"+error)
|
|
||||||
report.push({
|
|
||||||
group: req.group,
|
|
||||||
name: req.name,
|
|
||||||
status: ":red_circle:",
|
|
||||||
code: error.status,
|
|
||||||
lengthOrData: "Error: " + error,
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
if (stdout !== "") {
|
const stdout = await runExec(req.url);
|
||||||
allResponse+=JSON.stringify(req.name+"\n"+stdout)
|
if (stdout !== "") {
|
||||||
console.log("stdout ", stdout)
|
allResponse+=JSON.stringify(req.name+"\n"+stdout)
|
||||||
console.log(typeof stdout)
|
console.log("stdout ", stdout)
|
||||||
console.log("req.name ", req.name)
|
console.log(typeof stdout)
|
||||||
console.log(req.name==="Perthmint")
|
console.log("req.name ", req.name)
|
||||||
console.log((stdout.toString().split("true").length-1)>1)
|
console.log(req.name==="Perthmint")
|
||||||
if(req.name==="Perthmint"){
|
console.log((stdout.toString().split("true").length-1)>1)
|
||||||
if((stdout.toString().split("true").length-1)>1){
|
if(req.name==="Perthmint"){
|
||||||
report.push({
|
if((stdout.toString().split("true").length-1)>1){
|
||||||
group: req.group,
|
report.push({
|
||||||
name: req.name,
|
group: req.group,
|
||||||
status: ":check:",
|
name: req.name,
|
||||||
code: "good",
|
status: ":check:",
|
||||||
lengthOrData: stdout,
|
code: "good",
|
||||||
});
|
lengthOrData: stdout,
|
||||||
}else{
|
});
|
||||||
report.push({
|
}else{
|
||||||
group: req.group,
|
report.push({
|
||||||
name: req.name,
|
group: req.group,
|
||||||
status: ":red_circle:",
|
name: req.name,
|
||||||
code: "fail",
|
status: ":red_circle:",
|
||||||
lengthOrData: stdout,
|
code: "fail",
|
||||||
});
|
lengthOrData: stdout,
|
||||||
}
|
});
|
||||||
|
|
||||||
}
|
}
|
||||||
} else {
|
|
||||||
console.log(stderr)
|
|
||||||
allResponse+=JSON.stringify(req.name+"\n"+stderr)
|
|
||||||
report.push({
|
|
||||||
group: req.group,
|
|
||||||
name: req.name,
|
|
||||||
status: ":red_circle:",
|
|
||||||
code: "fail",
|
|
||||||
lengthOrData: stderr,
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
});
|
} else {
|
||||||
|
console.log(stderr)
|
||||||
|
allResponse+=JSON.stringify(req.name+"\n"+stderr)
|
||||||
|
report.push({
|
||||||
|
group: req.group,
|
||||||
|
name: req.name,
|
||||||
|
status: ":red_circle:",
|
||||||
|
code: "fail",
|
||||||
|
lengthOrData: stderr,
|
||||||
|
});
|
||||||
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue