diff --git a/lib/Site/Vms.pm b/lib/Site/Vms.pm index 83392d4df6fe2165fde38977fba0cd2f831eaf4e..70b6bd4fe79e447bfc6fddfa1738650492ba33a6 100644 --- a/lib/Site/Vms.pm +++ b/lib/Site/Vms.pm @@ -55,13 +55,20 @@ sub handler { my $self = shift; my $config = $self->{'config'}; my $virsh_path = $config->{'virsh_path'} || 'virsh'; - my $output_active = run_command("$virsh_path list --name"); - my $output_autostart = run_command("$virsh_path list --autostart --name"); - my $output_inactive = run_command("$virsh_path list --name --inactive"); + my ($output_active,$output_autostart,$output_inactive)=('','',''); + $output_active = run_command("$virsh_path list --name"); + if ($output_active =~ m/please enter your authentication name/i){ + $output_active = run_command("ps --no-headers -C qemu-kvm -o args"); + $output_active =~ s|^/usr/libexec/qemu-kvm -name guest=([^,]*),debug-threads=on.*$|$1|gm; + } + else { + $output_autostart = run_command("$virsh_path list --autostart --name"); + $output_inactive = run_command("$virsh_path list --name --inactive"); + } my %metrics = ( - "active" => $output_active, - "inactive" => $output_inactive, - "autostart" => $output_autostart, + "active" => $output_active, + "inactive" => $output_inactive, + "autostart" => $output_autostart, ); return \%metrics;