]>
git.proxmox.com Git - pve-manager.git/blob - PVE/Report.pm
8 # output the content of all the files of a directory
10 my ($target_dir, $regexp) = @_;
13 PVE
::Tools
::dir_glob_foreach
($target_dir, $regexp, sub {
15 $text .= "\n# cat $target_dir$file\n";
16 $text .= PVE
::Tools
::file_get_contents
($target_dir.$file)."\n";
21 # command -v is the posix equivalent of 'which'
22 my sub cmd_exists
{ system("command -v '$_[0]' > /dev/null 2>&1") == 0 }
24 my $init_report_cmds = sub {
27 title
=> 'general system info',
31 'pveversion --verbose',
33 'top -b -n 1 | head -n 15',
34 'pvesubscription get',
35 'cat /etc/apt/sources.list',
36 sub { dir2text
('/etc/apt/sources.list.d/', '.*list') },
37 sub { dir2text
('/etc/apt/sources.list.d/', '.*sources') },
39 'head /proc/pressure/*',
40 'pvesh get /cluster/resources --type node --output-format=yaml',
46 'cat /etc/pve/storage.cfg',
57 sub { dir2text
('/etc/pve/qemu-server/', '\d.*conf') },
59 sub { dir2text
('/etc/pve/lxc/', '\d.*conf') },
65 'ip -details -statistics address',
66 'ip -details -4 route show',
67 'ip -details -6 route show',
68 'cat /etc/network/interfaces',
74 sub { dir2text
('/etc/pve/firewall/', '.*fw') },
75 'cat /etc/pve/local/host.fw',
84 'cat /etc/pve/corosync.conf 2>/dev/null',
104 'ls -l /dev/disk/by-*/',
106 'iscsiadm -m session',
119 if (cmd_exists
('zfs')) {
120 push @{$report_def->{volumes
}->{cmds
}},
127 if (-e
'/etc/ceph/ceph.conf') {
128 push @{$report_def->{volumes
}->{cmds
}},
133 'cat /etc/ceph/ceph.conf',
140 if (cmd_exists
('multipath')) {
141 push @{$report_def->{disks
}->{cmds
}},
142 'cat /etc/multipath.conf',
143 'cat /etc/multipath/wwids',
152 my $def = $init_report_cmds->();
155 my $record_output = sub {
156 $report .= shift . "\n";
159 local $ENV{'PATH'} = '/sbin:/bin:/usr/sbin:/usr/bin';
160 my $cmd_timeout = 10; # generous timeout
162 my $run_cmd_params = {
163 outfunc
=> $record_output,
164 errfunc
=> $record_output,
165 timeout
=> $cmd_timeout,
166 noerr
=> 1, # avoid checking programs exit code
169 my $sorter = sub { ($def->{$_[0]}->{order
} // 1<<30) <=> ($def->{$_[1]}->{order} // 1<<30) };
171 for my $section ( sort { $sorter->($a, $b) } keys %$def) {
172 my $s = $def->{$section};
173 my $title = $s->{title
} // "info about $section";
175 $report .= "\n==== $title ====\n";
176 for my $command (@{$s->{cmds
}}) {
178 if (ref $command eq 'CODE') {
179 $report .= PVE
::Tools
::run_with_timeout
($cmd_timeout, $command);
181 print STDERR
"Process ".$command."...";
182 $report .= "\n# $command\n";
183 PVE
::Tools
::run_command
($command, %$run_cmd_params);
188 $report .= "\nERROR: $@\n" if $@;