fixed uptime calculation
This commit is contained in:
parent
f43a46b20a
commit
3ca2226494
|
@ -66,15 +66,18 @@ async function checkPM2Services() {
|
||||||
|
|
||||||
// Update PM2 services status
|
// Update PM2 services status
|
||||||
list.forEach(process => {
|
list.forEach(process => {
|
||||||
|
// Calculate uptime correctly - pm_uptime is a timestamp, not a duration
|
||||||
|
const uptimeMs = process.pm2_env.pm_uptime ?
|
||||||
|
Date.now() - process.pm2_env.pm_uptime :
|
||||||
|
null;
|
||||||
|
|
||||||
pm2ServicesStatus[process.name] = {
|
pm2ServicesStatus[process.name] = {
|
||||||
name: process.name,
|
name: process.name,
|
||||||
id: process.pm_id,
|
id: process.pm_id,
|
||||||
status: process.pm2_env.status,
|
status: process.pm2_env.status,
|
||||||
cpu: process.monit ? process.monit.cpu : null,
|
cpu: process.monit ? process.monit.cpu : null,
|
||||||
memory: process.monit ? process.monit.memory : null,
|
memory: process.monit ? process.monit.memory : null,
|
||||||
uptime: process.pm2_env.pm_uptime ?
|
uptime: uptimeMs, // Store the uptime in milliseconds
|
||||||
Date.now() - process.pm2_env.pm_uptime :
|
|
||||||
null,
|
|
||||||
restarts: process.pm2_env.restart_time,
|
restarts: process.pm2_env.restart_time,
|
||||||
lastChecked: new Date().toISOString()
|
lastChecked: new Date().toISOString()
|
||||||
};
|
};
|
||||||
|
|
Loading…
Reference in a new issue