Reduce ping interval from 30 seconds to 10 seconds and update log output format
This commit is contained in:
@@ -13,11 +13,10 @@ class Uptime {
|
||||
console.log('Starting...');
|
||||
console.log(`Starting at ${this.startTime.toLocaleDateString()} ${this.startTime.toLocaleTimeString()}`);
|
||||
this.handle();
|
||||
setInterval(() => this.handle(), 1000 * 30);
|
||||
setInterval(() => this.handle(), 1000 * 10);
|
||||
}
|
||||
|
||||
async handle() {
|
||||
console.log('Fetch status...')
|
||||
await ping.sys.probe('node.under-scape.com', (isAlive) => {
|
||||
const now = new Date();
|
||||
this.totalIte++;
|
||||
@@ -35,7 +34,7 @@ class Uptime {
|
||||
});
|
||||
}
|
||||
|
||||
console.log(`[${now.toLocaleDateString()} ${now.toLocaleTimeString()}] Total: ${this.totalIte} Up: ${this.totalUp} Down: ${this.totalDown} Uptime: ${Math.round((this.totalUp / this.totalIte) * 100)}%`)
|
||||
process.stdout.write(`[${now.toLocaleDateString()} ${now.toLocaleTimeString()}] Total: ${this.totalIte} Up: ${this.totalUp} Down: ${this.totalDown} Uptime: ${Math.round((this.totalUp / this.totalIte) * 100)}%\r`)
|
||||
}, {timeout: 10});
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user