Skip to content

Commit

Permalink
fix: fixed pidusage and enabled process stats in diagnostics page
Browse files Browse the repository at this point in the history
  • Loading branch information
tabarra committed Sep 15, 2022
1 parent a32a656 commit 28385ff
Show file tree
Hide file tree
Showing 6 changed files with 51 additions and 55 deletions.
7 changes: 7 additions & 0 deletions core/extras/pidUsageTree.js
@@ -0,0 +1,7 @@
import pidtree from 'pidtree';
import pidusage from 'pidusage';

export default async (pid) => {
const pids = await pidtree(pid);
return await pidusage(pids);
};
8 changes: 4 additions & 4 deletions core/webroutes/diagnostics.js
@@ -1,13 +1,13 @@
const modulename = 'WebServer:Diagnostics';
import os from 'node:os';
import bytes from 'bytes';
import pidusageTree from 'pidusage-tree';
import humanizeDuration from 'humanize-duration';
import logger from '@core/extras/console.js';
import * as helpers from '@core/extras/helpers';
import Cache from '../extras/dataCache';
import got from '@core/extras/got.js';
import getOsDistro from '@core/extras/getOsDistro.js';
import pidUsageTree from '@core/extras/pidUsageTree.js';
import { verbose, txEnv } from '@core/globalData.js';
const { dir, log, logOk, logWarn, logError } = logger(modulename);

Expand All @@ -34,7 +34,7 @@ export default async function Diagnostics(ctx) {
getHostData(),
gettxAdminData(),
getFXServerData(),
// getProcessesData(), FIXME: pidusageTree is bugged
getProcessesData(),
]);

const timeElapsed = Date.now() - timeStart;
Expand All @@ -54,7 +54,7 @@ export default async function Diagnostics(ctx) {
async function getProcessesData() {
const procList = [];
try {
const processes = await pidusageTree(process.pid);
const processes = await pidUsageTree(process.pid);

//NOTE: Cleaning invalid proccesses that might show up in Linux
Object.keys(processes).forEach((pid) => {
Expand Down Expand Up @@ -87,7 +87,7 @@ async function getProcessesData() {
});
});
} catch (error) {
logError('Error getting processes data.');
logError('Error getting processes tree usage data.');
if (verbose) dir(error);
}

Expand Down
8 changes: 4 additions & 4 deletions docs/dev_notes.md
Expand Up @@ -3,19 +3,19 @@ v4.18.0:
- [x] fix fxserver settings save issue
- [x] clarify better the update notifications (path vs minor)
- [x] fix(core): getOsDistro powershell detection + error handling
- [x] fix: fixed pidusage and enabled process stats in diagnostics page


https://media.discordapp.net/attachments/589106731376836608/1018227573420990564/unknown.png



scheduled restart vazio = erro
events for dynamic scheduled restarts

teste:
remover meu admin do sv zap
dar join
apertar f1 e ver se aparece a mensagem de perms
remover meu admin do sv zap
dar join
apertar f1 e ver se aparece a mensagem de perms

```js
//Resource didn't finish starting (if res boot still active)
Expand Down
64 changes: 22 additions & 42 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 2 additions & 1 deletion package.json
Expand Up @@ -77,7 +77,8 @@
"notistack": "^2.0.5",
"open": "7.1.0",
"openid-client": "^5.1.9",
"pidusage-tree": "^2.0.5",
"pidtree": "^0.6.0",
"pidusage": "github:tabarra/pidusage",
"react-polyglot": "^0.7.2",
"recoil": "^0.7.5",
"rotating-file-stream": "^3.0.4",
Expand Down
16 changes: 12 additions & 4 deletions web/main/diagnostics.ejs
Expand Up @@ -95,10 +95,18 @@
<div class="card card-accent-info">
<div class="card-header font-weight-bold">Processes:</div>
<div class="card-body">
<div class="text-center">
This card has been temporarily disabled due to a bug in an underlying library. <br>
A fix is expected to be released for txAdmin v4.20.
</div>
<% if (!proccesses.length) { %>
Failed to retrieve processed data. <br>
Check the terminal for more information (if verbosity is enabled)
<% } else { %>
<% for (const process of proccesses) { %>
<strong>Process:</strong> (<%= process.pid %>) <%= process.name %> <br>
<strong>Parent:</strong> <%= process.ppid %> <br>
<strong>Memory:</strong> <%= process.memory %> <br>
<strong>CPU:</strong> <%= process.cpu %> <br>
<br>
<% } %>
<% } %>
</div>
</div>

Expand Down

0 comments on commit 28385ff

Please sign in to comment.