Refactor Process Stats and Bugfixes (#6344)

* test refactor process stats

* Update util.py

* bugfix

* black formatting

* add missing processes field to StatsTrackingTypes class

* fix python checks and tests...

* use psutil for calcilate cpu utilization on get_cpu_stats

* black...black...black...

* add cpu average

* calculate statiscts for logger process

* add P-ID for other processes in System.jsx

* Apply suggestions from code review

Co-authored-by: Nicolas Mowen <nickmowen213@gmail.com>

* make page beautiful again :)

---------

Co-authored-by: Nicolas Mowen <nickmowen213@gmail.com>
This commit is contained in:
Sergey Krashevich
2023-05-05 01:58:59 +03:00
committed by GitHub
parent b38c9e82e2
commit 2add675d42
5 changed files with 67 additions and 31 deletions

View File

@@ -29,12 +29,14 @@ export default function System() {
detectors,
service = {},
detection_fps: _,
processes,
...cameras
} = stats || initialStats || emptyObject;
const detectorNames = Object.keys(detectors || emptyObject);
const gpuNames = Object.keys(gpu_usages || emptyObject);
const cameraNames = Object.keys(cameras || emptyObject);
const processesNames = Object.keys(processes || emptyObject);
const onHandleFfprobe = async (camera, e) => {
if (e) {
@@ -347,7 +349,7 @@ export default function System() {
<Heading size="lg">Other Processes</Heading>
<div data-testid="cameras" className="grid grid-cols-1 3xl:grid-cols-3 md:grid-cols-2 gap-4">
{['go2rtc', 'recording'].map((process) => (
{processesNames.map((process) => (
<div key={process} className="dark:bg-gray-800 shadow-md hover:shadow-lg rounded-lg transition-shadow">
<div className="capitalize text-lg flex justify-between p-4">
<div className="text-lg flex justify-between">{process}</div>
@@ -356,14 +358,18 @@ export default function System() {
<Table className="w-full">
<Thead>
<Tr>
<Th>P-ID</Th>
<Th>CPU %</Th>
<Th>Avg CPU %</Th>
<Th>Memory %</Th>
</Tr>
</Thead>
<Tbody>
<Tr key="ffmpeg" index="0">
<Td>{cpu_usages[process]?.['cpu'] || '- '}%</Td>
<Td>{cpu_usages[process]?.['mem'] || '- '}%</Td>
<Tr key="other" index="0">
<Td>{processes[process]['pid'] || '- '}</Td>
<Td>{cpu_usages[processes[process]['pid']]?.['cpu'] || '- '}%</Td>
<Td>{cpu_usages[processes[process]['pid']]?.['cpu_average'] || '- '}%</Td>
<Td>{cpu_usages[processes[process]['pid']]?.['mem'] || '- '}%</Td>
</Tr>
</Tbody>
</Table>