]>
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'
71 my @report_order = ('general', 'storage', 'virtual guests', 'network',
72 'firewall', 'cluster', 'bios', 'pci', 'disks', 'volumes');
74 push @{$report_def->{volumes
}}, 'zpool status', 'zfs list' if cmd_exists
('zfs');
76 push @{$report_def->{disk
}}, 'multipath -ll', 'multipath -v3' if cmd_exists
('multipath');
80 # output the content of all the files of a directory
82 my ($target_dir, $regexp) = @_;
84 PVE
::Tools
::dir_glob_foreach
($target_dir, $regexp, sub {
86 $report .= "\n# cat $target_dir$file\n";
87 $report .= PVE
::Tools
::file_get_contents
($target_dir.$file)."\n";
91 # command -v is the posix equivalent of 'which'
92 sub cmd_exists
{ system("command -v '$_[0]' > /dev/null 2>&1") == 0 }
96 my $record_output = sub {
97 $report .= shift . "\n";
100 my $run_cmd_params = {
101 outfunc
=> $record_output,
102 errfunc
=> $record_output,
103 timeout
=> $cmd_timeout,
104 noerr
=> 1, # avoid checking programs exit code
107 foreach my $section (@report_order) {
108 my $s = $report_def->{$section};
110 my $title = "info about $section";
113 if (ref($s) eq 'HASH') {
114 $commands = $s->{cmds
};
115 $title = $s->{title
} if defined($s->{title
});
116 } elsif (ref($s) ne 'ARRAY') {
117 die "unknown report definition in section '$section'!";
120 $report .= "\n==== $title ====\n";
121 foreach my $command (@$commands) {
123 if (ref $command eq 'CODE') {
124 PVE
::Tools
::run_with_timeout
($cmd_timeout, $command);
126 $report .= "\n# $command\n";
127 PVE
::Tools
::run_command
($command, %$run_cmd_params);
130 $report .= "\nERROR: $@\n" if $@;