Hello Mike, On Thu, 13 Dec 2018 at 21:51, Mike Keehan <m...@keehan.net> wrote:
> On Thu, 13 Dec 2018 20:31:29 +0100 > 799 <one7tw...@gmail.com> wrote: > > > [...] > > But when I bring both peaces together I only get one result back, not > > the result for all AppVMs > > [...] > > I can't figure out why the code above only returns the first VM's > result, but the following code works for me :- > for i in `qvm-ls --running -O name --raw-data|grep -v dom0`; > do > echo $i = `qvm-run --pass-io $i "free"| tail -n +3 | gawk '{print > $3 }'`; > done > with the help from you I was able to write a small script which will generate a notification pop up if swap usage in an appvm reaches a threshold (maxswap). This script could then be run via cron or maybe watch. --- 8< --- --- --- #!/bin/bash # name : qvm-show-swap.sh # version: 0.1 # date : 15.12.2018 # author : one7two99 + help of Qubes OS mailinglist ;-) # define allowed maximum swap usage in Kb # if more swap space is used in an AppVM a warning notification will pop-up maxswap=1024 # get a list of all running AppVms (except dom0) for i in `qvm-ls --running -O name --raw-data | grep -v dom0`; do # get swap usage in the AppVM freeswap=`qvm-run --pass-io $i "free" | tail -n+3 | gawk '{print $3}'`; # convert swap usage from Kb to Mb swapsize=$(expr $freeswap / 1024); # Check if swap usage is > than maxswap if [ "$freeswap" -gt "$maxswap" ]; then # create a PopUp-notification notify-send --urgency normal --icon dialog-warning --expire-time=5000 "$i" ".. is using $swapsize Mb swap"; fi; done --- 8< --- --- --- For a simple test you could run this script every 5 min in dom0 via: watch -n 300 ./qvm-show-swap.sh or you setup something like cron in dom0 etc. Let me know if you think there is a better approach. - O -- You received this message because you are subscribed to the Google Groups "qubes-users" group. To unsubscribe from this group and stop receiving emails from it, send an email to qubes-users+unsubscr...@googlegroups.com. To post to this group, send email to qubes-users@googlegroups.com. To view this discussion on the web visit https://groups.google.com/d/msgid/qubes-users/CAJ3yz2tNKE5nKPFkSNLK2EV-vZaASZNuabByvYGwyUYwDm%2Bh1Q%40mail.gmail.com. For more options, visit https://groups.google.com/d/optout.