]>
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}'...";
14 PVE
::Tools
::dir_glob_foreach
($target_dir, $regexp, sub {
16 $text .= "\n# cat $target_dir$file\n";
17 $text .= PVE
::Tools
::file_get_contents
($target_dir.$file)."\n";
22 # command -v is the posix equivalent of 'which'
23 my sub cmd_exists
{ system("command -v '$_[0]' > /dev/null 2>&1") == 0 }
25 my $init_report_cmds = sub {
28 title
=> 'general system info',
33 'pveversion --verbose',
35 'pvesubscription get',
36 'cat /etc/apt/sources.list',
37 sub { dir2text
('/etc/apt/sources.list.d/', '.*list') },
38 sub { dir2text
('/etc/apt/sources.list.d/', '.*sources') },
40 'pvesh get /cluster/resources --type node --output-format=yaml',
44 title
=> 'overall system load info',
47 'top -b -c -w512 -n 1 -o TIME | head -n 30',
48 'head /proc/pressure/*',
54 'cat /etc/pve/storage.cfg',
59 'proxmox-boot-tool status',
66 sub { dir2text
('/etc/pve/qemu-server/', '\d.*conf') },
68 sub { dir2text
('/etc/pve/lxc/', '\d.*conf') },
74 'ip -details -statistics address',
75 'ip -details -4 route show',
76 'ip -details -6 route show',
77 'cat /etc/network/interfaces',
83 sub { dir2text
('/etc/pve/firewall/', '.*fw') },
84 'cat /etc/pve/local/host.fw',
93 'cat /etc/pve/corosync.conf 2>/dev/null',
95 'cat /etc/pve/datacenter.cfg',
108 'lsblk --ascii -M -o +HOTPLUG,ROTA,PHY-SEC,FSTYPE,MODEL,TRAN',
109 'ls -l /dev/disk/by-*/',
111 'iscsiadm -m session',
124 if (cmd_exists
('zfs')) {
125 push @{$report_def->{volumes
}->{cmds
}},
133 if (-e
'/etc/ceph/ceph.conf') {
134 push @{$report_def->{volumes
}->{cmds
}},
140 'cat /etc/ceph/ceph.conf',
144 'ceph health detail',
148 if (cmd_exists
('multipath')) {
149 push @{$report_def->{disks
}->{cmds
}},
150 'cat /etc/multipath.conf',
151 'cat /etc/multipath/wwids',
160 my $def = $init_report_cmds->();
163 my $record_output = sub {
164 $report .= shift . "\n";
167 local $ENV{'PATH'} = '/sbin:/bin:/usr/sbin:/usr/bin';
168 my $cmd_timeout = 10; # generous timeout
170 my $run_cmd_params = {
171 outfunc
=> $record_output,
172 errfunc
=> $record_output,
173 timeout
=> $cmd_timeout,
174 noerr
=> 1, # avoid checking programs exit code
177 my $sorter = sub { ($def->{$_[0]}->{order
} // 1<<30) <=> ($def->{$_[1]}->{order} // 1<<30) };
179 for my $section ( sort { $sorter->($a, $b) } keys %$def) {
180 my $s = $def->{$section};
181 my $title = $s->{title
} // "info about $section";
183 $report .= "\n==== $title ====\n";
184 for my $command (@{$s->{cmds
}}) {
186 if (ref $command eq 'CODE') {
187 $report .= PVE
::Tools
::run_with_timeout
($cmd_timeout, $command);
189 print STDERR
"Process ".$command."...";
190 $report .= "\n# $command\n";
191 PVE
::Tools
::run_command
($command, %$run_cmd_params);
196 $report .= "\nERROR: $@\n" if $@;