Little improvements
This commit is contained in:
24
hosts.js
24
hosts.js
@@ -2,7 +2,7 @@ const axios = require("axios");
|
||||
const shared = require("./shared.js");
|
||||
const { Log } = require("./logs.js");
|
||||
let hostIDs = [];
|
||||
var monitorInterval;
|
||||
let monitorInterval;
|
||||
|
||||
async function Monitoring() {
|
||||
await initHostList();
|
||||
@@ -18,9 +18,9 @@ async function Monitoring() {
|
||||
}
|
||||
|
||||
async function Request() {
|
||||
var hosts = [];
|
||||
let hosts = [];
|
||||
for (const element of hostIDs) {
|
||||
var obj = {
|
||||
let obj = {
|
||||
id: element,
|
||||
[element]: await isConnected(element),
|
||||
};
|
||||
@@ -75,9 +75,14 @@ async function initHostList() {
|
||||
},
|
||||
}
|
||||
);
|
||||
for (const host of response.data) {
|
||||
hostIDs.push(host.id);
|
||||
}
|
||||
/*
|
||||
response.data.forEach((host) => {
|
||||
hostIDs.push(host.id);
|
||||
});
|
||||
*/
|
||||
} catch (error) {
|
||||
Log(
|
||||
`[${shared.now()}] Errore nella verifica e aggiunta al monitoraggio di un host.`
|
||||
@@ -170,9 +175,16 @@ async function initHostList() {
|
||||
Authorization: `Token ${shared.getToken()}`,
|
||||
},
|
||||
});
|
||||
|
||||
for (const element of response.data) {
|
||||
hostIDs.push(element.id);
|
||||
}
|
||||
|
||||
/*
|
||||
response.data.forEach((element) => {
|
||||
hostIDs.push(element.id);
|
||||
});
|
||||
*/
|
||||
} catch (error) {
|
||||
Log(`[${shared.now()}] Errore nel tentativo di reperire tutti i peer.`);
|
||||
Log(`[${shared.now()}] ${error}`);
|
||||
@@ -182,9 +194,15 @@ async function initHostList() {
|
||||
}
|
||||
|
||||
Log(`[${shared.now()}] ID rilevati:`);
|
||||
for (const element of hostIDs) {
|
||||
Log(`[${shared.now()}] ${element}`);
|
||||
}
|
||||
|
||||
/*
|
||||
hostIDs.forEach((element) => {
|
||||
Log(`[${shared.now()}] ${element}`);
|
||||
});
|
||||
*/
|
||||
}
|
||||
|
||||
module.exports = { Monitoring };
|
||||
|
||||
Reference in New Issue
Block a user