CPU monitor per VMs

Original forum link
https://forum.qubes-os.org/t/22829
Original poster
garchi
Created at
2023-12-14 20:58:54
Posts count
2
Likes count
7
Tags
configuration, dom0, xfce

I'm used to always seeing the CPU utilization monitor. It's easy to see who's doing illegal activities 😎 Not finding a standard Qubes solution, I wrote a little script for xfce panel item "Generic Monitor". Maybe someone will find it useful or say that I invented a crooked bicycle and there is a much better one.

It looks like this in a dark theme:

Screenshot_1|219x63

Screenshot_2|217x61

The script to be copied to the Dom0:

#!/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;
for example, in ~/bin/cpu_monitor_dot.pl Make it executable and write the path to it in Command "Generic Monitor". Period (s) for me 4.5 And the VM generating the highest load will always be in front of your eyes 😎