From f024accba110bc4725fcb1cca1ea529c7dd36d41 Mon Sep 17 00:00:00 2001 From: Sergey Ivanov <seriv@cs.umd.edu> Date: Thu, 30 Jul 2020 14:47:04 -0400 Subject: [PATCH] work for ovirt --- lib/Site/Vms.pm | 19 +++++++++++++------ 1 file changed, 13 insertions(+), 6 deletions(-) diff --git a/lib/Site/Vms.pm b/lib/Site/Vms.pm index 83392d4..70b6bd4 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; -- GitLab