]>
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',
26 'cat /etc/pve/storage.cfg',
34 sub { dir2text
('/etc/pve/qemu-server/', '\d.*conf') },
36 sub { dir2text
('/etc/pve/lxc/', '\d.*conf') },
39 'ip -details -statistics address',
40 'cat /etc/network/interfaces',
43 sub { dir2text
('/etc/pve/firewall/', '.*fw') },
49 'cat /etc/pve/corosync.conf 2>/dev/null'
66 my @report_order = ('general', 'storage', 'virtual guests', 'network',
67 'firewall', 'cluster', 'bios', 'pci', 'disks', 'volumes');
69 push @{$report_def->{volumes
}}, 'zpool status', 'zfs list' if cmd_exists
('zfs');
71 push @{$report_def->{disk
}}, 'multipath -ll', 'multipath -v3' if cmd_exists
('multipath');
75 # output the content of all the files of a directory
77 my ($target_dir, $regexp) = @_;
79 PVE
::Tools
::dir_glob_foreach
($target_dir, $regexp, sub {
81 $report .= "\n# cat $target_dir$file\n";
82 $report .= PVE
::Tools
::file_get_contents
($target_dir.$file)."\n";
86 # command -v is the posix equivalent of 'which'
87 sub cmd_exists
{ system("command -v '$_[0]' > /dev/null 2>&1") == 0 }
91 my $record_output = sub {
92 $report .= shift . "\n";
95 my $run_cmd_params = {
96 outfunc
=> $record_output,
97 errfunc
=> $record_output,
98 timeout
=> $cmd_timeout,
99 noerr
=> 1, # avoid checking programs exit code
102 foreach my $section (@report_order) {
103 my $s = $report_def->{$section};
105 my $title = "info about $section";
108 if (ref($s) eq 'HASH') {
109 $commands = $s->{cmds
};
110 $title = $s->{title
} if defined($s->{title
});
111 } elsif (ref($s) ne 'ARRAY') {
112 die "unknown report definition in section '$section'!";
115 $report .= "\n==== $title ====\n";
116 foreach my $command (@$commands) {
118 if (ref $command eq 'CODE') {
119 PVE
::Tools
::run_with_timeout
($cmd_timeout, $command);
121 $report .= "\n# $command\n";
122 PVE
::Tools
::run_command
($command, %$run_cmd_params);
125 $report .= "\nERROR: $@\n" if $@;