diff --git a/api/tacticalrmm/agents/views.py b/api/tacticalrmm/agents/views.py index e0e2946e..362472c7 100644 --- a/api/tacticalrmm/agents/views.py +++ b/api/tacticalrmm/agents/views.py @@ -159,12 +159,12 @@ def agent_detail(request, pk): @api_view() def get_processes(request, pk): agent = get_object_or_404(Agent, pk=pk) - if not agent.has_nats: - return notify_error("Requires agent version 1.1.0 or greater") + if pyver.parse(agent.version) < pyver.parse("1.2.0"): + return notify_error("Requires agent version 1.2.0 or greater") + r = asyncio.run(agent.nats_cmd(data={"func": "procs"}, timeout=5)) if r == "timeout": return notify_error("Unable to contact the agent") - return Response(r) diff --git a/web/src/components/ProcessManager.vue b/web/src/components/ProcessManager.vue index 04a0b2dd..7721aebb 100644 --- a/web/src/components/ProcessManager.vue +++ b/web/src/components/ProcessManager.vue @@ -54,10 +54,8 @@ {{ props.row.name }} - {{ props.row.cpu_percent }}% - {{ props.row.memory_percent }} + {{ bytes2Human(props.row.membytes) }} {{ props.row.username }} {{ props.row.pid }} {{ props.row.status }} @@ -104,16 +102,11 @@ export default { sort: (a, b, rowA, rowB) => parseInt(b) < parseInt(a), }, { - name: "memory_percent", + name: "membytes", label: "Memory", - field: "memory_percent", + field: "membytes", align: "left", sortable: true, - sort: (a, b, rowA, rowB) => { - const newA = parseFloat(a.replace(/[a-z]+/i, "")); - const newB = parseFloat(b.replace(/[a-z]+/i, "")); - return newB < newA; - }, }, { name: "username", @@ -205,6 +198,13 @@ export default { const mb = this.mem * 1024; return Math.ceil((percent * mb) / 100).toLocaleString(); }, + bytes2Human(bytes) { + if (bytes == 0) return "0B"; + const k = 1024; + const sizes = ["B", "KB", "MB", "GB", "TB", "PB", "EB", "ZB", "YB"]; + const i = Math.floor(Math.log(bytes) / Math.log(k)); + return parseFloat((bytes / Math.pow(k, i)).toFixed(2)) + " " + sizes[i]; + }, }, beforeDestroy() { clearInterval(this.polling);