Skip to content

Commit

Permalink
Bug fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
myrotvorets-team committed Oct 14, 2023
1 parent f9fc161 commit fc23a04
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions src/processmetrics.mts
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ async function getMemoryStats(): Promise<[number, number]> {
let vmrss, vmsize;
const lines = (await readFile('/proc/self/status', 'utf-8')).split('\n');
for (const line of lines) {
const [key, value] = line.split(/[: ]+/u, 2);
const [key, value] = line.split(/[\s:]+/u, 2);
if (key === 'VmRSS') {
vmrss = +(value ?? NaN);
} else if (key === 'VmSize') {
Expand Down Expand Up @@ -95,7 +95,7 @@ export async function initProcessMetrics(): Promise<void> {
observer.observe(cpuTime, usage.systemCPUTime / 1e6, { state: 'system' });

// cpuUsage is in microseconds, hrtime is in nanoseconds
const elapsedUs = Number((observationTime - lastObservationTime) / 1000n);
const elapsedUs = Number((observationTime - lastObservationTime) * 1000n);
observer.observe(cpuUtilization, (usage.userCPUTime - lastUsage.userCPUTime) / elapsedUs / cpuCount, {
state: 'user',
});
Expand Down

0 comments on commit fc23a04

Please sign in to comment.