Software: Apache/2.4.41 (Ubuntu). PHP/8.0.30 uname -a: Linux apirnd 5.4.0-204-generic #224-Ubuntu SMP Thu Dec 5 13:38:28 UTC 2024 x86_64 uid=33(www-data) gid=33(www-data) groups=33(www-data) Safe-mode: OFF (not secure) /var/www/html/proxy_server/node_modules/express-status-monitor/src/helpers/ drwxr-xr-x | |
| Viewing file: Select action/file-type: const pidusage = require('pidusage');
const os = require('os');
const v8 = require('v8');
const sendMetrics = require('./send-metrics');
const debug = require('debug')('express-status-monitor');
let eventLoopStats; // eslint-disable-line
try {
eventLoopStats = require('event-loop-stats'); // eslint-disable-line
} catch (error) {
console.warn('event-loop-stats not found, ignoring event loop metrics...');
}
module.exports = (io, span) => {
const defaultResponse = {
2: 0,
3: 0,
4: 0,
5: 0,
count: 0,
mean: 0,
timestamp: Date.now(),
};
pidusage(process.pid, (err, stat) => {
if (err) {
debug(err);
return;
}
const last = span.responses[span.responses.length - 1];
// Convert from B to MB
stat.memory = stat.memory / 1024 / 1024;
stat.load = os.loadavg();
stat.timestamp = Date.now();
stat.heap = v8.getHeapStatistics();
if (eventLoopStats) {
stat.loop = eventLoopStats.sense();
}
span.os.push(stat);
if (!span.responses[0] || (last.timestamp + span.interval) * 1000 < Date.now()) {
span.responses.push(defaultResponse);
}
// todo: I think this check should be moved somewhere else
if (span.os.length >= span.retention) span.os.shift();
if (span.responses[0] && span.responses.length > span.retention) span.responses.shift();
sendMetrics(io, span);
});
};
|
:: Command execute :: | |
--[ c99shell v. 2.5 [PHP 8 Update] [24.05.2025] | Generation time: 0.0057 ]-- |