Added timestamps to logs
This commit is contained in:
20
hosts.js
20
hosts.js
@@ -5,7 +5,7 @@ var monitorInterval;
|
||||
|
||||
async function Monitoring() {
|
||||
await initHostList();
|
||||
console.log("\nInizio monitoring");
|
||||
console.log(`[${shared.now}] \nInizio monitoring`);
|
||||
//monitora tutti gli host della lista
|
||||
shared.eventEmitter.on("tokenRenewalStart", () => {
|
||||
clearInterval(monitorInterval);
|
||||
@@ -38,7 +38,7 @@ async function isConnected(hostID) {
|
||||
},
|
||||
}
|
||||
);
|
||||
console.log(`${hostID} connected: ${response.data.connected}`);
|
||||
console.log(`[${shared.now}] ${hostID} connected: ${response.data.connected}`);
|
||||
return response.data.connected;
|
||||
}
|
||||
|
||||
@@ -70,7 +70,7 @@ async function initHostList() {
|
||||
});
|
||||
} catch (error) {
|
||||
console.log(
|
||||
"Errore nella verifica e aggiunta al monitoraggio di un host."
|
||||
`[${shared.now}] Errore nella verifica e aggiunta al monitoraggio di un host: ${error}`
|
||||
);
|
||||
process.exit(3);
|
||||
}
|
||||
@@ -89,7 +89,7 @@ async function initHostList() {
|
||||
hostIDs.push(response.data[0].id);
|
||||
} catch (error) {
|
||||
console.log(
|
||||
"Errore nella verifica e aggiunta al monitoraggio di un host."
|
||||
`[${shared.now}] Errore nella verifica e aggiunta al monitoraggio di un host: ${error}`
|
||||
);
|
||||
process.exit(3);
|
||||
}
|
||||
@@ -116,7 +116,7 @@ async function initHostList() {
|
||||
hostIDs.push(response.data.id);
|
||||
} catch (error) {
|
||||
console.log(
|
||||
"Errore nella verifica e aggiunta al monitoraggio di un host."
|
||||
`[${shared.now}] Errore nella verifica e aggiunta al monitoraggio di un host: ${error}`
|
||||
);
|
||||
process.exit(3);
|
||||
}
|
||||
@@ -135,7 +135,7 @@ async function initHostList() {
|
||||
hostIDs.push(response.data.id);
|
||||
} catch (error) {
|
||||
console.log(
|
||||
"Errore nella verifica e aggiunta al monitoraggio di un host."
|
||||
`[${shared.now}] Errore nella verifica e aggiunta al monitoraggio di un host: ${error}`
|
||||
);
|
||||
process.exit(3);
|
||||
}
|
||||
@@ -143,7 +143,7 @@ async function initHostList() {
|
||||
}
|
||||
} else {
|
||||
console.log(
|
||||
"Nessun peer specificato, verranno monitorati tutti i peer disponibili"
|
||||
`[${shared.now}] Nessun peer specificato, verranno monitorati tutti i peer disponibili`
|
||||
);
|
||||
try {
|
||||
const response = await axios.get(`https://api.netbird.io/api/peers`, {
|
||||
@@ -156,13 +156,13 @@ async function initHostList() {
|
||||
hostIDs.push(element.id);
|
||||
});
|
||||
} catch (error) {
|
||||
console.log(error);
|
||||
console.log(`[${shared.now}] ${error}`);
|
||||
}
|
||||
}
|
||||
|
||||
console.log("ID rilevati:");
|
||||
console.log(`[${shared.now}] ID rilevati:`);
|
||||
hostIDs.forEach((element) => {
|
||||
console.log(element);
|
||||
console.log(`[${shared.now}] ${element}`);
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user