]>
git.proxmox.com Git - pve-manager.git/blob - PVE/Report.pm
8 $ENV{'PATH'} = '/sbin:/bin:/usr/sbin:/usr/bin';
10 my $cmd_timeout = 10; # generous timeout
12 # NOTE: always add new sections to the report_order array!
15 title
=> 'general system info',
18 'pveversion --verbose',
20 'top -b -n 1 | head -n 15',
21 'pvesubscription get',
23 'pvesh get /cluster/resources --type node --output-format=yaml',
27 'cat /etc/pve/storage.cfg',
35 sub { dir2text
('/etc/pve/qemu-server/', '\d.*conf') },
37 sub { dir2text
('/etc/pve/lxc/', '\d.*conf') },
40 'ip -details -statistics address',
41 'ip -details -4 route show',
42 'ip -details -6 route show',
43 'cat /etc/network/interfaces',
46 sub { dir2text
('/etc/pve/firewall/', '.*fw') },
47 'cat /etc/pve/local/host.fw',
53 'cat /etc/pve/corosync.conf 2>/dev/null'
70 my @report_order = ('general', 'storage', 'virtual guests', 'network',
71 'firewall', 'cluster', 'bios', 'pci', 'disks', 'volumes');
73 push @{$report_def->{volumes
}}, 'zpool status', 'zfs list' if cmd_exists
('zfs');
75 push @{$report_def->{disk
}}, 'multipath -ll', 'multipath -v3' if cmd_exists
('multipath');
79 # output the content of all the files of a directory
81 my ($target_dir, $regexp) = @_;
83 PVE
::Tools
::dir_glob_foreach
($target_dir, $regexp, sub {
85 $report .= "\n# cat $target_dir$file\n";
86 $report .= PVE
::Tools
::file_get_contents
($target_dir.$file)."\n";
90 # command -v is the posix equivalent of 'which'
91 sub cmd_exists
{ system("command -v '$_[0]' > /dev/null 2>&1") == 0 }
95 my $record_output = sub {
96 $report .= shift . "\n";
99 my $run_cmd_params = {
100 outfunc
=> $record_output,
101 errfunc
=> $record_output,
102 timeout
=> $cmd_timeout,
103 noerr
=> 1, # avoid checking programs exit code
106 foreach my $section (@report_order) {
107 my $s = $report_def->{$section};
109 my $title = "info about $section";
112 if (ref($s) eq 'HASH') {
113 $commands = $s->{cmds
};
114 $title = $s->{title
} if defined($s->{title
});
115 } elsif (ref($s) ne 'ARRAY') {
116 die "unknown report definition in section '$section'!";
119 $report .= "\n==== $title ====\n";
120 foreach my $command (@$commands) {
122 if (ref $command eq 'CODE') {
123 PVE
::Tools
::run_with_timeout
($cmd_timeout, $command);
125 $report .= "\n# $command\n";
126 PVE
::Tools
::run_command
($command, %$run_cmd_params);
129 $report .= "\nERROR: $@\n" if $@;