Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 4 additions & 3 deletions glances/outputs/glances_curses.py
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@ class _GlancesCurses:
'5': {'handler': '_handle_top_menu'},
'6': {'switch': 'meangpu'},
'7': {'switch': 'disable_npu'},
'8': {'switch': 'disable_mpp'},
'/': {'switch': 'process_short_name'},
'a': {'sort_key': 'auto'},
'A': {'switch': 'disable_amps'},
Expand Down Expand Up @@ -106,7 +107,7 @@ class _GlancesCurses:
_sort_loop = sort_processes_stats_list

# Define top menu
_top = ['quicklook', 'cpu', 'percpu', 'npu', 'gpu', 'mem', 'memswap', 'load']
_top = ['quicklook', 'cpu', 'percpu', 'npu', 'mpp', 'gpu', 'mem', 'memswap', 'load']
_quicklook_max_width = 58

# Define left sidebar
Expand Down Expand Up @@ -445,13 +446,13 @@ def enable_top(self):

def disable_fullquicklook(self):
"""Disable the full quicklook mode"""
for p in ['quicklook', 'cpu', 'npu', 'gpu', 'mem', 'memswap']:
for p in ['quicklook', 'cpu', 'npu', 'mpp', 'gpu', 'mem', 'memswap']:
setattr(self.args, 'disable_' + p, False)

def enable_fullquicklook(self):
"""Disable the full quicklook mode"""
self.args.disable_quicklook = False
for p in ['cpu', 'npu', 'gpu', 'mem', 'memswap']:
for p in ['cpu', 'npu', 'mpp', 'gpu', 'mem', 'memswap']:
setattr(self.args, 'disable_' + p, True)

def end(self):
Expand Down
7 changes: 7 additions & 0 deletions glances/outputs/static/css/style.scss
Original file line number Diff line number Diff line change
Expand Up @@ -277,6 +277,13 @@ body {
}
}

#mpp {
* > td span {
display: inline-block;
width: 4em;
}
}

#gpu {
* > td span {
display: inline-block;
Expand Down
9 changes: 9 additions & 0 deletions glances/outputs/static/js/App.vue
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,10 @@
<div v-if="!args.disable_npu && hasNpu" class="d-none d-xl-block">
<glances-plugin-npu :data="data"></glances-plugin-npu>
</div>
<!-- MPP -->
<div v-if="!args.disable_mpp && hasMpp" class="d-none d-xl-block">
<glances-plugin-mpp :data="data"></glances-plugin-mpp>
</div>
<!-- GPU -->
<div v-if="!args.disable_gpu && hasGpu" class="d-none d-xl-block">
<glances-plugin-gpu :data="data"></glances-plugin-gpu>
Expand Down Expand Up @@ -104,6 +108,7 @@ import GlancesPluginCpu from "./components/plugin-cpu.vue";
import GlancesPluginDiskio from "./components/plugin-diskio.vue";
import GlancesPluginFolders from "./components/plugin-folders.vue";
import GlancesPluginFs from "./components/plugin-fs.vue";
import GlancesPluginMpp from "./components/plugin-mpp.vue";
import GlancesPluginNpu from "./components/plugin-npu.vue";
import GlancesPluginGpu from "./components/plugin-gpu.vue";
import GlancesPluginHostname from "./components/plugin-hostname.vue";
Expand Down Expand Up @@ -141,6 +146,7 @@ export default {
GlancesPluginContainers,
GlancesPluginFolders,
GlancesPluginFs,
GlancesPluginMpp,
GlancesPluginNpu,
GlancesPluginGpu,
GlancesPluginHostname,
Expand Down Expand Up @@ -181,6 +187,9 @@ export default {
dataLoaded() {
return this.store.data !== undefined;
},
hasMpp() {
return this.store.data.stats.mpp && this.store.data.stats.mpp.length > 0;
},
hasNpu() {
return this.store.data.stats.npu.length > 0;
},
Expand Down
65 changes: 65 additions & 0 deletions glances/outputs/static/js/components/plugin-mpp.vue
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
<template>
<section v-if="engines != undefined && engines.length > 0" id="mpp" class="plugin">
<div class="table-responsive">
<div class="title">MPP</div>
<table class="table table-sm table-borderless">
<tbody>
<tr v-for="(engine, idx) in engines" :key="idx">
<td class="col">
<span>{{ engine.name }}</span>
</td>
<td class="col" :class="getDecoration(engine.engine_id, 'load')">
<span v-if="engine.load != null">{{ $filters.number(engine.load, 1) }}%</span>
<span v-else>N/A</span>
</td>
<td class="col text-end">
<span v-if="engine.sessions > 0">{{ engine.sessions }} sess</span>
</td>
</tr>
</tbody>
</table>
</div>
</section>
</template>

<script>
import { store } from "../store.js";

export default {
props: {
data: {
type: Object,
},
},
data() {
return {
store,
};
},
computed: {
args() {
return this.store.args || {};
},
stats() {
return this.data.stats["mpp"];
},
view() {
return this.data.views["mpp"];
},
engines() {
return this.stats;
},
},
methods: {
getDecoration(engineId, value) {
if (
this.view[engineId] === undefined ||
this.view[engineId][value] === undefined
) {
return;
}
return this.view[engineId][value].decoration.toLowerCase();
},
},
};
</script>
1 change: 1 addition & 0 deletions glances/outputs/static/js/uiconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
"cpu",
"percpu",
"npu",
"mpp",
"gpu",
"mem",
"memswap",
Expand Down
10 changes: 5 additions & 5 deletions glances/outputs/static/public/browser.js

Large diffs are not rendered by default.

16 changes: 8 additions & 8 deletions glances/outputs/static/public/glances.js

Large diffs are not rendered by default.

157 changes: 157 additions & 0 deletions glances/plugins/mpp/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,157 @@
#
# This file is part of Glances.
#
# SPDX-FileCopyrightText: 2026 Nicolas Hennion <nicolas@nicolargo.com>
#
# SPDX-License-Identifier: LGPL-3.0-only
#

"""MPP (Media Process Platform) plugin for Glances.

Currently supported:
- Rockchip MPP (RKVENC, RKVDEC, RKJPEGD)
"""

from glances.logger import logger
from glances.plugins.mpp.cards.rockchip_mpp import RockchipMPP
from glances.plugins.plugin.model import GlancesPluginModel

# Fields description
fields_description = {
'engine_id': {
'description': 'Engine identification',
},
'name': {
'description': 'Engine name',
},
'type': {
'description': 'Engine type (encoder/decoder/jpeg)',
},
'load': {
'description': 'Engine load',
'unit': 'percent',
},
'utilization': {
'description': 'Engine utilization',
'unit': 'percent',
},
'sessions': {
'description': 'Number of active sessions',
},
}

# Define the history items list
items_history_list = [
{'name': 'load', 'description': 'MPP engine load', 'y_unit': '%'},
]


class MppPlugin(GlancesPluginModel):
"""Glances MPP plugin.

stats is a list of dictionaries with one entry per MPP engine.
"""

def __init__(
self,
args=None,
config=None,
rockchip_mpp_root_folder: str = '/',
):
"""Init the plugin."""
super().__init__(
args=args,
config=config,
items_history_list=items_history_list,
stats_init_value=[],
fields_description=fields_description,
)

self.rockchip = RockchipMPP(mpp_root_folder=rockchip_mpp_root_folder)

# We want to display the stat in the curse interface
self.display_curse = True

def exit(self):
"""Overwrite the exit method."""
self.rockchip.exit()
super().exit()

def get_key(self):
"""Return the key of the list."""
return 'engine_id'

@GlancesPluginModel._check_decorator
@GlancesPluginModel._log_result_decorator
def update(self):
"""Update the MPP stats."""
stats = self.get_init_value()

if self.rockchip.is_available():
try:
engine_stats = self.rockchip.get_stats()
stats.extend(engine_stats)
except Exception as e:
logger.debug(f"Error getting Rockchip MPP stats, disabling: {e}")
self.rockchip.disable()

self.stats = stats

return self.stats

def update_views(self):
"""Update stats views."""
super().update_views()

for i in self.stats:
self.views[i[self.get_key()]] = {'load': {}}
if 'load' in i and i['load'] is not None:
alert = self.get_alert(i['load'], header='load')
self.views[i[self.get_key()]]['load']['decoration'] = alert

return True

def msg_curse(self, args=None, max_width=None):
"""Return the dict to display in the curse interface."""
ret = []

if not self.stats or self.is_disabled():
return ret

# Header
ret.append(self.curse_add_line('MPP', 'TITLE'))

# One line per engine
for engine in self.stats:
ret.append(self.curse_new_line())

# Engine name and type (e.g. "RKVENC enc")
name = engine.get('name', 'unknown')
etype = engine.get('type', '')
label = f'{name:<8}{etype:>5}'
ret.append(self.curse_add_line(label))

# Load percentage
load = engine.get('load')
if load is not None:
msg = f'{load:>6.1f}%'
ret.append(
self.curse_add_line(
msg,
self.get_views(
key='load',
item=engine[self.get_key()],
option='decoration',
),
)
)
else:
ret.append(self.curse_add_line('{:>7}'.format('N/A')))

# Session count
sessions = engine.get('sessions', 0)
if sessions:
msg = f' {sessions} sess'
ret.append(self.curse_add_line(msg))

return ret
23 changes: 23 additions & 0 deletions glances/plugins/mpp/cards/mpp.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
#
# This file is part of Glances.
#
# SPDX-FileCopyrightText: 2026 Nicolas Hennion <nicolas@nicolargo.com>
#
# SPDX-License-Identifier: LGPL-3.0-only
#


from dataclasses import dataclass


@dataclass
class MPPStats:
"""Container for a single MPP engine's statistics."""

def __init__(self):
self.engine_id: str = "unknown"
self.name: str = "unknown"
self.type: str = "unknown"
self.load: float | None = None
self.utilization: float | None = None
self.sessions: int = 0
Loading
Loading