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...');
|
||||||
console.log(`Starting at ${this.startTime.toLocaleDateString()} ${this.startTime.toLocaleTimeString()}`);
|
console.log(`Starting at ${this.startTime.toLocaleDateString()} ${this.startTime.toLocaleTimeString()}`);
|
||||||
this.handle();
|
this.handle();
|
||||||
setInterval(() => this.handle(), 1000 * 30);
|
setInterval(() => this.handle(), 1000 * 10);
|
||||||
}
|
}
|
||||||
|
|
||||||
async handle() {
|
async handle() {
|
||||||
console.log('Fetch status...')
|
|
||||||
await ping.sys.probe('node.under-scape.com', (isAlive) => {
|
await ping.sys.probe('node.under-scape.com', (isAlive) => {
|
||||||
const now = new Date();
|
const now = new Date();
|
||||||
this.totalIte++;
|
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});
|
}, {timeout: 10});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user