Bird-view of resources (memory and disk)

This maybe of course ignorance on my part, but I :smiley: just want to be sure. I don’t know how to get a total (% or GB) of memory currently in use, and I don’t know how to get a total (again % or GB) of disk currently in use.

Is xl info | grep memory the only way to get memory usage?
And is there a way to get disk usage?

You can use, xl info | awk '/total_memory/ {print $3}' and xl info | awk '/total_memory/ {print $3}' to see those values.

Below is the code I use for a widget in Dom0 that gives me a bar percentage of the RAM used.
ram_widget

#!/bin/bash
# /usr/local/bin/RAM_widget.sh

# Get memory stats
total=$(xl info | awk '/total_memory/ {print $3}')
free=$(xl info | awk '/free_memory/ {print $3}')
used=$((total - free))
percent=$((100 * used / total))
percent=$((percent + 1))

# Create bar
bar_length=6 # Number of blocks in the bar
filled=$((percent * bar_length / 100))
empty=$((bar_length - filled))

# Unicode block characters for smoother appearance
filled_char="█"
empty_char="░"

# Build the bar
bar="${filled_char}"   # Start with one block
for ((i=1; i<filled; i++)); do bar+="${filled_char}"; done
for ((i=0; i<empty; i++)); do bar+="${empty_char}"; done

# Final output
echo "$bar"
echo "     ($percent%)"

2 Likes

I prefer xentop.

With disks it depends on what do you mean by “disk” and what do you want to know. Obvious choice is qui-disk-space tray applet. Other options here can be unsafe. With your question in mind you probably want the applet or some combination of lvm tools and low-level partitioning tools.

Drive tools:

  • df -h <path> for filesystems (run inside the domain)
    There is also lsblk -f, but can get quite unwieldy with the amount of volumes you have in qubes. Not really made for displaying filesystem allocation.
  • qvm-pool and qvm-volume for qubes pools and domain volumes
  • lvm tools for logical volumes by default, zfs or btrfs otherwise
    lvs, vgs, pvs, etc., see SEE ALSO section of lvm manual for all tools
  • stuff like fdisk and parted for drive partitioning

p.s. you also can use qvm-ls to check memory use (memory field), but I think it only shows correct memory for dom0, and memory at startup for all other qubes.

If your using the default xfce desktop, theres a disk icon left of your dom0 username on the upper right. Shows you total disk usage.

Thank you.

I am trying it out. A bit of trouble adding the launcher, but should work soon. Thank you very much.

Well, I have tried a couple ways to configure the launcher, but it just won’t show nothing. If I set Terminal=True, the terminal appears briefly but shows nothing either. Any tip or hint will be greatly appreciated.

Thank you! I have used it some time ago, but has foolishly forgotten. Using it again.

It is “qui-disk-space tray applet”.

I’ve created a secondary Panel in dom0 that I keep all my widgets in.

There is an option to add a Generic Monitor item and point it to your .sh file, give it a name and select the polling rate.
If you have trouble seeing it, maybe increase the Panel width.

1 Like

Hey, really thank you very much! It works like a breeze. It would make a great addition to Qubes OS next release @soleneISTHEGOAT

For a resource “bird-view”, another widget I find really helpful is one that gives me the highest CPU usage of my qubes (average core util.%).

#!/usr/bin/perl

# indicator length
my $il = 25;

my $name_max = '';
my $cpu_max = -1;

open(my $top, '-|', 'xentop -bi2 -d1') || die $!;

while (<$top>) {
        next if /^\s*NAME/ ... /^\s*NAME/;
        s/^\s+//;
        my @s = split /\s+/;
        my $cpu = eval{$s[3]/$s[8]} || 0;
        if ($cpu > $cpu_max) {
                $name_max = $s[0];
                $cpu_max = $cpu;
        }
}

my $v = 1 + int($cpu_max * $il / 100); 

print '|' x $v, '.' x ($il-$v), "\n", $name_max, "  ", int $cpu_max, "%";
1 Like

Thank you very much.

When it comes to CPU and RAM usage, I’ll shamelessly plug my own script as well:

3 Likes