@drocketxx/pm2me 1.1.14 → 1.1.15

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -97,29 +97,32 @@ export const getSystemStats = async () => {
97
97
  const promises = [];
98
98
 
99
99
  // 1. Network Stats (Every time) - read from /proc/net/dev
100
- const netPromise = execPromise("cat /proc/net/dev | awk 'NR>2 {rx+=$2; tx+=$10} END {print rx\" \"tx}'")
100
+ const netPromise = execPromise("cat /proc/net/dev | tail -n +3 | awk '{rx+=$2; tx+=$10} END {print rx, tx}'")
101
101
  .then(({ stdout }) => {
102
- const [rxStr, txStr] = stdout.trim().split(' ');
103
- const totalRx = parseInt(rxStr) || 0;
104
- const totalTx = parseInt(txStr) || 0;
102
+ const parts = stdout.trim().split(/\s+/);
103
+ const totalRx = parseInt(parts[0]) || 0;
104
+ const totalTx = parseInt(parts[1]) || 0;
105
105
  const timeDiff = (now - lastNetworkStats.time) / 1000;
106
- if (timeDiff > 0 && lastNetworkStats.rx > 0) {
106
+ if (timeDiff > 0 && lastNetworkStats.rx > 0 && totalRx > 0) {
107
107
  networkUsage.down = Math.max(0, (totalRx - lastNetworkStats.rx) / timeDiff);
108
108
  networkUsage.up = Math.max(0, (totalTx - lastNetworkStats.tx) / timeDiff);
109
109
  }
110
110
  lastNetworkStats = { rx: totalRx, tx: totalTx, time: now };
111
111
  })
112
- .catch(e => console.error('Network fetch failed:', e));
112
+ .catch(e => {
113
+ console.error('Network fetch failed:', e);
114
+ // Keep previous values on error
115
+ });
113
116
  promises.push(netPromise);
114
117
 
115
118
  // 2. Disk Stats (Cached) - use df for root filesystem
116
119
  if (now - cachedDiskStats.lastFetch > DISK_CACHE_TTL) {
117
- const diskPromise = execPromise("df -B1 / | awk 'NR==2 {print $2\" \"$3\" \"$4}'")
120
+ const diskPromise = execPromise("df -B1 / | tail -n 1 | awk '{print $2, $3, $4}'")
118
121
  .then(({ stdout }) => {
119
- const [totalStr, usedStr, freeStr] = stdout.trim().split(' ');
120
- const total = parseInt(totalStr) || 0;
121
- const used = parseInt(usedStr) || 0;
122
- const free = parseInt(freeStr) || 0;
122
+ const parts = stdout.trim().split(/\s+/);
123
+ const total = parseInt(parts[0]) || 0;
124
+ const used = parseInt(parts[1]) || 0;
125
+ const free = parseInt(parts[2]) || 0;
123
126
  if (total > 0) {
124
127
  cachedDiskStats = {
125
128
  total,
@@ -130,7 +133,10 @@ export const getSystemStats = async () => {
130
133
  };
131
134
  }
132
135
  })
133
- .catch(e => console.error('Disk fetch failed:', e));
136
+ .catch(e => {
137
+ console.error('Disk fetch failed:', e);
138
+ // Keep cached values on error
139
+ });
134
140
  promises.push(diskPromise);
135
141
  }
136
142
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@drocketxx/pm2me",
3
- "version": "1.1.14",
3
+ "version": "1.1.15",
4
4
  "description": "PM2 Deployment and Management System — Web UI for PM2 process management",
5
5
  "type": "module",
6
6
  "main": "backend/app.js",