From 95ab5ad3ac694201cf1d60b52cbbae4636561fc6 Mon Sep 17 00:00:00 2001 From: Tom Laermans Date: Fri, 22 Apr 2011 20:45:39 +0000 Subject: [PATCH] optimize libvirt ssh connections a bit git-svn-id: http://www.observium.org/svn/observer/trunk@2141 61d68cd4-352d-0410-923a-c4978735b2b8 --- includes/discovery/libvirt-vminfo.inc.php | 14 +++++--------- 1 file changed, 5 insertions(+), 9 deletions(-) diff --git a/includes/discovery/libvirt-vminfo.inc.php b/includes/discovery/libvirt-vminfo.inc.php index 8c74c1672..dac57b90c 100755 --- a/includes/discovery/libvirt-vminfo.inc.php +++ b/includes/discovery/libvirt-vminfo.inc.php @@ -10,6 +10,8 @@ if ($config['enable_libvirt'] == '1' && $device['os'] == "linux" ) echo("Libvirt VM: "); + $ssh_ok = 0; + foreach ($config['libvirt_protocols'] as $method) { if (strstr($method,'qemu')) @@ -21,21 +23,15 @@ if ($config['enable_libvirt'] == '1' && $device['os'] == "linux" ) $uri = $method.'://' . $device['hostname']; } - $ok = 0; - - if (strstr($method,'ssh')) + if (strstr($method,'ssh') && !$ssh_ok) { # Check if we are using SSH if we can log in without password - without blocking the discovery # Also automatically add the host key so discovery doesn't block on the yes/no question, and run echo so we don't get stuck in a remote shell ;-) exec('ssh -o "StrictHostKeyChecking no" -o "PreferredAuthentications publickey" -o "IdentitiesOnly yes" ' . $device['hostname'] . ' echo', $out, $ret); - if ($ret != 255) { $ok = 1; } - } - else - { - $ok = 1; + if ($ret != 255) { $ssh_ok = 1; } } - if ($ok) + if ($ssh_ok || !strstr($method,'ssh')) { # Fetch virtual machine list unset($domlist);