diff --git a/AUTHORS.md b/AUTHORS.md index 0945ba8ec5..83929477a9 100644 --- a/AUTHORS.md +++ b/AUTHORS.md @@ -78,6 +78,7 @@ LibreNMS contributors: - D. Britz (flatterlight) - Tobias Herrmann (Mightea) - Nicolas Guillaumin (nguillaumin) +- Jurrian van Iersel (jviersel) [1]: http://observium.org/ "Observium web site" Observium was written by: diff --git a/doc/Support/Configuration.md b/doc/Support/Configuration.md index 45891da81c..15be9ed6c3 100644 --- a/doc/Support/Configuration.md +++ b/doc/Support/Configuration.md @@ -488,6 +488,7 @@ This array can be used to filter out syslog messages that you don't want to be s ```php $config['enable_libvirt'] = 1; $config['libvirt_protocols'] = array("qemu+ssh","xen+ssh"); +$config['libvirt_username'] = 'root'; ``` Enable this to switch on support for libvirt along with `libvirt_protocols` to indicate how you connect to libvirt. You also need to: diff --git a/includes/discovery/libvirt-vminfo.inc.php b/includes/discovery/libvirt-vminfo.inc.php index 8825bf7b46..aced6467c3 100644 --- a/includes/discovery/libvirt-vminfo.inc.php +++ b/includes/discovery/libvirt-vminfo.inc.php @@ -9,18 +9,23 @@ if ($config['enable_libvirt'] == '1' && $device['os'] == 'linux') { $ssh_ok = 0; + $userHostname = $device['hostname']; + if (isset($config['libvirt_username'])) { + $userHostname = $config['libvirt_username'].'@'.$userHostname; + } + foreach ($config['libvirt_protocols'] as $method) { if (strstr($method, 'qemu')) { - $uri = $method.'://'.$device['hostname'].'/system'; + $uri = $method.'://'.$userHostname.'/system'; } else { - $uri = $method.'://'.$device['hostname']; + $uri = $method.'://'.$userHostname; } 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 -e', $out, $ret); + exec('ssh -o "StrictHostKeyChecking no" -o "PreferredAuthentications publickey" -o "IdentitiesOnly yes" '.$userHostname.' echo -e', $out, $ret); if ($ret != 255) { $ssh_ok = 1; }