]>
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) = @_;
12 print STDERR
"dir2text '${target_dir}${regexp}'...";
13 my $text = "# output '${target_dir}${regexp}' file(s)\n";
14 PVE
::Tools
::dir_glob_foreach
($target_dir, $regexp, sub {
16 return if $file eq '.' || $file eq '..';
17 $text .= "\n# cat $target_dir$file\n";
18 $text .= PVE
::Tools
::file_get_contents
($target_dir.$file)."\n";
23 # command -v is the posix equivalent of 'which'
24 my sub cmd_exists
{ system("command -v '$_[0]' > /dev/null 2>&1") == 0 }
26 my $init_report_cmds = sub {
29 title
=> 'general system info',
34 'pveversion --verbose',
36 'pvesubscription get',
37 'cat /etc/apt/sources.list',
38 sub { dir2text
('/etc/apt/sources.list.d/', '.*list') },
39 sub { dir2text
('/etc/apt/sources.list.d/', '.*sources') },
41 'pvesh get /cluster/resources --type node --output-format=yaml',
45 title
=> 'overall system load info',
48 'top -b -c -w512 -n 1 -o TIME | head -n 30',
49 'head /proc/pressure/*',
55 'cat /etc/pve/storage.cfg',
60 'proxmox-boot-tool status',
67 sub { dir2text
('/etc/pve/qemu-server/', '\d.*conf') },
69 sub { dir2text
('/etc/pve/lxc/', '\d.*conf') },
75 'ip -details -statistics address',
76 'ip -details -4 route show',
77 'ip -details -6 route show',
78 'cat /etc/network/interfaces',
79 sub { dir2text
('/etc/network/interfaces.d/', '.*') },
80 sub { dir2text
('/etc/pve/sdn/', '.*') },
86 sub { dir2text
('/etc/pve/firewall/', '.*fw') },
87 'cat /etc/pve/local/host.fw',
88 'iptables-save -c | column -t -l4 -o" "',
96 'cat /etc/pve/corosync.conf 2>/dev/null',
98 'cat /etc/pve/datacenter.cfg',
111 'lsblk --ascii -M -o +HOTPLUG,ROTA,PHY-SEC,FSTYPE,MODEL,TRAN',
112 'ls -l /dev/disk/by-*/',
114 'iscsiadm -m session',
127 if (cmd_exists
('zfs')) {
128 push @{$report_def->{volumes
}->{cmds
}},
136 if (-e
'/etc/ceph/ceph.conf') {
137 push @{$report_def->{volumes
}->{cmds
}},
143 'cat /etc/ceph/ceph.conf',
147 'ceph health detail',
151 if (cmd_exists
('multipath')) {
152 push @{$report_def->{disks
}->{cmds
}},
153 'cat /etc/multipath.conf',
154 'cat /etc/multipath/wwids',
163 my $def = $init_report_cmds->();
166 my $record_output = sub {
167 $report .= shift . "\n";
170 local $ENV{'PATH'} = '/sbin:/bin:/usr/sbin:/usr/bin';
171 my $cmd_timeout = 10; # generous timeout
173 my $run_cmd_params = {
174 outfunc
=> $record_output,
175 errfunc
=> $record_output,
176 timeout
=> $cmd_timeout,
177 noerr
=> 1, # avoid checking programs exit code
180 my $sorter = sub { ($def->{$_[0]}->{order
} // 1<<30) <=> ($def->{$_[1]}->{order} // 1<<30) };
182 for my $section ( sort { $sorter->($a, $b) } keys %$def) {
183 my $s = $def->{$section};
184 my $title = $s->{title
} // "info about $section";
186 $report .= "\n==== $title ====\n";
187 for my $command (@{$s->{cmds
}}) {
189 if (ref $command eq 'CODE') {
190 $report .= PVE
::Tools
::run_with_timeout
($cmd_timeout, $command);
192 print STDERR
"Process ".$command."...";
193 $report .= "\n# $command\n";
194 PVE
::Tools
::run_command
($command, %$run_cmd_params);
199 $report .= "\nERROR: $@\n" if $@;