#234 sort proc mem using bytes wh1te909/rmmagent@04470dd4ce
This commit is contained in:
parent
e26fbf0328
commit
e64c72cc89
|
@ -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)
|
||||
|
||||
|
||||
|
|
|
@ -54,10 +54,8 @@
|
|||
</q-list>
|
||||
</q-menu>
|
||||
<q-td>{{ props.row.name }}</q-td>
|
||||
<!-- <q-td>{{ Math.ceil(props.row.cpu_percent) }}%</q-td>
|
||||
<q-td>{{ convert(props.row.memory_percent) }} MB</q-td> -->
|
||||
<q-td>{{ props.row.cpu_percent }}%</q-td>
|
||||
<q-td>{{ props.row.memory_percent }}</q-td>
|
||||
<q-td>{{ bytes2Human(props.row.membytes) }}</q-td>
|
||||
<q-td>{{ props.row.username }}</q-td>
|
||||
<q-td>{{ props.row.pid }}</q-td>
|
||||
<q-td>{{ props.row.status }}</q-td>
|
||||
|
@ -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);
|
||||
|
|
Loading…
Reference in New Issue