[pve-devel] [PATCH manager] Fix #1186: do not run non installed commands

Emmanuel Kasper e.kasper at proxmox.com
Fri Oct 28 10:56:40 CEST 2016


Conditionnally add commands which are not:
*  Debian packages whith priority Essential or Important,
* a dependency of pve-manager
---
 PVE/Report.pm | 13 +++++++++++--
 1 file changed, 11 insertions(+), 2 deletions(-)

diff --git a/PVE/Report.pm b/PVE/Report.pm
index 89714b8..0d0eaa8 100644
--- a/PVE/Report.pm
+++ b/PVE/Report.pm
@@ -5,6 +5,8 @@ use warnings;
 use PVE::pvecfg;
 use PVE::Tools;
 
+$ENV{'PATH'} = '/sbin:/bin:/usr/sbin:/usr/bin';
+
 my $report;
 
 my @general = ('hostname', 'pveversion --verbose', 'cat /etc/hosts', 'top -b -n 1  | head -n 15',
@@ -12,9 +14,16 @@ my @general = ('hostname', 'pveversion --verbose', 'cat /etc/hosts', 'top -b -n
 
 my @storage = ('cat /etc/pve/storage.cfg', 'pvesm status', 'cat /etc/fstab', 'mount', 'df --human');
 
-my @volumes = ('lvs', 'vgs', 'zpool status', 'zfs list');
+my @volumes = ('lvs', 'vgs');
+# command -v is the posix equivalent of 'which'
+if (system('command -v zfs > /dev/null 2>&1') == 0) {
+    push @volumes, 'zpool status', 'zfs list'
+}
 
-my @disks = ('lsblk', 'multipath -ll', 'multipath -v3');
+my @disks = ('lsblk');
+if (system('command -v multipath > /dev/null 2>&1') == 0) {
+    push @disks, 'multipath -ll', 'multipath -v3'
+}
 
 my @machines = ('qm list', sub { dir2text('/etc/pve/qemu-server/', '\d.*conf') });
 
-- 
2.1.4





More information about the pve-devel mailing list