mirror of
https://git.proxmox.com/git/pve-manager
synced 2025-04-29 06:27:20 +00:00
pvereport: only comput report def if we generate a report.
it's really not a good idea to start doing exec, file exist checks, ... on every module load of this, this may even hang completely differen parts if something pull us in, and confuse one completely... Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com> Reported-by: Wolfgang Link <w.link@proxmox.com>
This commit is contained in:
parent
4711d99862
commit
01c8f6fe7d
156
PVE/Report.pm
156
PVE/Report.pm
@ -9,84 +9,82 @@ $ENV{'PATH'} = '/sbin:/bin:/usr/sbin:/usr/bin';
|
|||||||
|
|
||||||
my $cmd_timeout = 10; # generous timeout
|
my $cmd_timeout = 10; # generous timeout
|
||||||
|
|
||||||
# NOTE: always add new sections to the report_order array!
|
my $init_report_cmds = sub {
|
||||||
my $report_def = {
|
# NOTE: always add new sections to the report_order array!
|
||||||
general => {
|
my $report_def = {
|
||||||
title => 'general system info',
|
general => {
|
||||||
cmds => [
|
title => 'general system info',
|
||||||
'hostname',
|
cmds => [
|
||||||
'pveversion --verbose',
|
'hostname',
|
||||||
'cat /etc/hosts',
|
'pveversion --verbose',
|
||||||
'top -b -n 1 | head -n 15',
|
'cat /etc/hosts',
|
||||||
'pvesubscription get',
|
'top -b -n 1 | head -n 15',
|
||||||
'lscpu',
|
'pvesubscription get',
|
||||||
'pvesh get /cluster/resources --type node --output-format=yaml',
|
'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',
|
||||||
],
|
],
|
||||||
},
|
'virtual guests' => [
|
||||||
storage => [
|
'qm list',
|
||||||
'cat /etc/pve/storage.cfg',
|
sub { dir2text('/etc/pve/qemu-server/', '\d.*conf') },
|
||||||
'pvesm status',
|
'pct list',
|
||||||
'cat /etc/fstab',
|
sub { dir2text('/etc/pve/lxc/', '\d.*conf') },
|
||||||
'findmnt --ascii',
|
],
|
||||||
'df --human',
|
network => [
|
||||||
],
|
'ip -details -statistics address',
|
||||||
'virtual guests' => [
|
'ip -details -4 route show',
|
||||||
'qm list',
|
'ip -details -6 route show',
|
||||||
sub { dir2text('/etc/pve/qemu-server/', '\d.*conf') },
|
'cat /etc/network/interfaces',
|
||||||
'pct list',
|
],
|
||||||
sub { dir2text('/etc/pve/lxc/', '\d.*conf') },
|
firewall => [
|
||||||
],
|
sub { dir2text('/etc/pve/firewall/', '.*fw') },
|
||||||
network => [
|
'cat /etc/pve/local/host.fw',
|
||||||
'ip -details -statistics address',
|
'iptables-save',
|
||||||
'ip -details -4 route show',
|
],
|
||||||
'ip -details -6 route show',
|
cluster => [
|
||||||
'cat /etc/network/interfaces',
|
'pvecm nodes',
|
||||||
],
|
'pvecm status',
|
||||||
firewall => [
|
'cat /etc/pve/corosync.conf 2>/dev/null'
|
||||||
sub { dir2text('/etc/pve/firewall/', '.*fw') },
|
],
|
||||||
'cat /etc/pve/local/host.fw',
|
bios => [
|
||||||
'iptables-save',
|
'dmidecode -t bios',
|
||||||
],
|
],
|
||||||
cluster => [
|
pci => [
|
||||||
'pvecm nodes',
|
'lspci -nnk',
|
||||||
'pvecm status',
|
],
|
||||||
'cat /etc/pve/corosync.conf 2>/dev/null'
|
disks => [
|
||||||
],
|
'lsblk --ascii',
|
||||||
bios => [
|
'ls -l /dev/disk/by-*/',
|
||||||
'dmidecode -t bios',
|
'iscsiadm -m node',
|
||||||
],
|
'iscsiadm -m session',
|
||||||
pci => [
|
],
|
||||||
'lspci -nnk',
|
volumes => [
|
||||||
],
|
'pvs',
|
||||||
disks => [
|
'lvs',
|
||||||
'lsblk --ascii',
|
'vgs',
|
||||||
'ls -l /dev/disk/by-*/',
|
],
|
||||||
'iscsiadm -m node',
|
};
|
||||||
'iscsiadm -m session',
|
|
||||||
],
|
push @{$report_def->{volumes}}, 'zpool status', 'zpool list -v', 'zfs list' if cmd_exists('zfs');
|
||||||
volumes => [
|
|
||||||
'pvs',
|
if (-e '/etc/ceph/ceph.conf') {
|
||||||
'lvs',
|
my $crbd = eval "`ceph osd pool ls | sed -e 's/^/echo /' | sed 'p;s/echo/rbd ls/g'`";
|
||||||
'vgs',
|
push @{$report_def->{volumes}}, 'ceph status', 'ceph osd status', 'ceph df', 'pveceph status', 'pveceph lspools', $crbd;
|
||||||
],
|
}
|
||||||
|
|
||||||
|
push @{$report_def->{disk}}, 'multipath -ll', 'multipath -v3' if cmd_exists('multipath');
|
||||||
|
|
||||||
|
return $report_def;
|
||||||
};
|
};
|
||||||
|
|
||||||
my @report_order = ('general', 'storage', 'virtual guests', 'network',
|
my $report;
|
||||||
'firewall', 'cluster', 'bios', 'pci', 'disks', 'volumes');
|
|
||||||
|
|
||||||
push @{$report_def->{volumes}}, 'zpool status', 'zpool list -v', 'zfs list' if cmd_exists('zfs');
|
|
||||||
|
|
||||||
|
|
||||||
if (-e '/etc/ceph/ceph.conf') {
|
|
||||||
my $crbd = eval "`ceph osd pool ls | sed -e 's/^/echo /' | sed 'p;s/echo/rbd ls/g'`";
|
|
||||||
|
|
||||||
push @{$report_def->{volumes}}, 'ceph status', 'ceph osd status', 'ceph df', 'pveceph status', 'pveceph lspools', $crbd;
|
|
||||||
}
|
|
||||||
|
|
||||||
push @{$report_def->{disk}}, 'multipath -ll', 'multipath -v3' if cmd_exists('multipath');
|
|
||||||
|
|
||||||
my $report = '';
|
|
||||||
|
|
||||||
# output the content of all the files of a directory
|
# output the content of all the files of a directory
|
||||||
sub dir2text {
|
sub dir2text {
|
||||||
my ($target_dir, $regexp) = @_;
|
my ($target_dir, $regexp) = @_;
|
||||||
@ -103,6 +101,12 @@ sub cmd_exists { system("command -v '$_[0]' > /dev/null 2>&1") == 0 }
|
|||||||
|
|
||||||
sub generate {
|
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 {
|
my $record_output = sub {
|
||||||
$report .= shift . "\n";
|
$report .= shift . "\n";
|
||||||
};
|
};
|
||||||
@ -129,11 +133,11 @@ sub generate {
|
|||||||
|
|
||||||
$report .= "\n==== $title ====\n";
|
$report .= "\n==== $title ====\n";
|
||||||
foreach my $command (@$commands) {
|
foreach my $command (@$commands) {
|
||||||
print STDERR "Process ".$command."...";
|
|
||||||
eval {
|
eval {
|
||||||
if (ref $command eq 'CODE') {
|
if (ref $command eq 'CODE') {
|
||||||
PVE::Tools::run_with_timeout($cmd_timeout, $command);
|
PVE::Tools::run_with_timeout($cmd_timeout, $command);
|
||||||
} else {
|
} else {
|
||||||
|
print STDERR "Process ".$command."...";
|
||||||
$report .= "\n# $command\n";
|
$report .= "\n# $command\n";
|
||||||
PVE::Tools::run_command($command, %$run_cmd_params);
|
PVE::Tools::run_command($command, %$run_cmd_params);
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user