]> git.proxmox.com Git - pve-manager.git/blobdiff - PVE/Report.pm
pvereport: fix multipath inclusion
[pve-manager.git] / PVE / Report.pm
index 375c5aa37b75ac5ed6353de2cb0a4846042191be..5ee3453df5b98d8ed6ac7bfd41d944ed601b9d5b 100644 (file)
@@ -2,76 +2,90 @@ package PVE::Report;
 
 use strict;
 use warnings;
-use PVE::pvecfg;
+
 use PVE::Tools;
 
 $ENV{'PATH'} = '/sbin:/bin:/usr/sbin:/usr/bin';
 
 my $cmd_timeout = 10; # generous timeout
 
-# NOTE: always add new sections to the report_order array!
-my $report_def = {
-    general => {
-       title => 'general system info',
-       cmds => [
-           'hostname',
-           'pveversion --verbose',
-           'cat /etc/hosts',
-           'top -b -n 1  | head -n 15',
-           'pvesubscription get',
-           'lscpu',
+my $init_report_cmds = sub {
+    # NOTE: always add new sections to the report_order array!
+    my $report_def = {
+       general => {
+           title => 'general system info',
+           cmds => [
+               'hostname',
+               'pveversion --verbose',
+               'cat /etc/hosts',
+               'top -b -n 1  | head -n 15',
+               'pvesubscription get',
+               'lscpu',
+               'pvesh get /cluster/resources --type node --output-format=yaml',
+           ],
+       },
+       storage => [
+           'cat /etc/pve/storage.cfg',
+           'pvesm status',
+           'cat /etc/fstab',
+           'findmnt --ascii',
+           'df --human',
        ],
-    },
-    storage => [
-       'cat /etc/pve/storage.cfg',
-       'pvesm status',
-       'cat /etc/fstab',
-       'findmnt --ascii',
-       'df --human',
-    ],
-    'virtual guests' => [
-       'qm list',
-       sub { dir2text('/etc/pve/qemu-server/', '\d.*conf') },
-       'pct list',
-       sub { dir2text('/etc/pve/lxc/', '\d.*conf') },
-    ],
-    network => [
-       'ip -details -statistics address',
-       'cat /etc/network/interfaces',
-    ],
-    firewall => [
-       sub { dir2text('/etc/pve/firewall/', '.*fw') },
-       'iptables-save',
-    ],
-    cluster => [
-       'pvecm nodes',
-       'pvecm status',
-       'cat /etc/pve/corosync.conf 2>/dev/null'
-    ],
-    bios => [
-       'dmidecode -t bios',
-    ],
-    pci => [
-       'lspci -nnk',
-    ],
-    disks => [
-       'lsblk --ascii',
-    ],
-    volumes => [
-       'lvs',
-       'vgs',
-    ],
-};
+       'virtual guests' => [
+          'qm list',
+          sub { dir2text('/etc/pve/qemu-server/', '\d.*conf') },
+          'pct list',
+          sub { dir2text('/etc/pve/lxc/', '\d.*conf') },
+       ],
+       network => [
+           'ip -details -statistics address',
+           'ip -details -4 route show',
+           'ip -details -6 route show',
+           'cat /etc/network/interfaces',
+       ],
+       firewall => [
+           sub { dir2text('/etc/pve/firewall/', '.*fw') },
+           'cat /etc/pve/local/host.fw',
+           'iptables-save',
+       ],
+       cluster => [
+           'pvecm nodes',
+           'pvecm status',
+           'cat /etc/pve/corosync.conf 2>/dev/null'
+       ],
+       bios => [
+           'dmidecode -t bios',
+       ],
+       pci => [
+           'lspci -nnk',
+       ],
+       disks => [
+           'lsblk --ascii',
+           'ls -l /dev/disk/by-*/',
+           'iscsiadm -m node',
+           'iscsiadm -m session',
+       ],
+       volumes => [
+           'pvs',
+           'lvs',
+           'vgs',
+       ],
+    };
 
-my @report_order = ('general', 'storage', 'virtual guests', 'network',
-'firewall', 'cluster', 'bios', 'pci', 'disks', 'volumes');
+    push @{$report_def->{volumes}}, 'zpool status', 'zpool list -v', 'zfs list' if cmd_exists('zfs');
 
-push @{$report_def->{volumes}}, 'zpool status', 'zfs list' if cmd_exists('zfs');
+    if (-e '/etc/ceph/ceph.conf') {
+       # TODO: add (now working) rdb ls over all pools? really needed?
+       push @{$report_def->{volumes}}, 'ceph status', 'ceph osd status', 'ceph df', 'pveceph status', 'pveceph pool ls';
+    }
 
-push @{$report_def->{disk}}, 'multipath -ll', 'multipath -v3' if cmd_exists('multipath');
+    push @{$report_def->{disks}}, 'multipath -ll', 'multipath -v3'
+       if cmd_exists('multipath');
 
-my $report = '';
+    return $report_def;
+};
 
+my $report;
 # output the content of all the files of a directory
 sub dir2text {
     my ($target_dir, $regexp) = @_;
@@ -88,6 +102,12 @@ sub cmd_exists { system("command -v '$_[0]' > /dev/null 2>&1") == 0 }
 
 sub generate {
 
+    my $report_def = $init_report_cmds->();
+
+    my @report_order = ('general', 'storage', 'virtual guests', 'network',
+    'firewall', 'cluster', 'bios', 'pci', 'disks', 'volumes');
+
+    $report = '';
     my $record_output = sub {
        $report .= shift . "\n";
     };
@@ -118,10 +138,13 @@ sub generate {
                if (ref $command eq 'CODE') {
                    PVE::Tools::run_with_timeout($cmd_timeout, $command);
                } else {
+                   print STDERR "Process ".$command."...";
                    $report .= "\n# $command\n";
                    PVE::Tools::run_command($command, %$run_cmd_params);
                }
+               print STDERR "OK";
            };
+           print STDERR "\n";
            $report .= "\nERROR: $@\n" if $@;
        }
     }