]>
git.proxmox.com Git - pve-manager.git/blob - PVE/Report.pm
457bba6e44597e2b67c4386b9512a4dcf2e36628
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',
32 'pveversion --verbose',
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 'pvesh get /cluster/resources --type node --output-format=yaml',
43 title
=> 'overall system load info',
46 'top -b -c -w512 -n 1 -o TIME | head -n 30',
47 'head /proc/pressure/*',
53 'cat /etc/pve/storage.cfg',
58 'proxmox-boot-tool status',
65 sub { dir2text
('/etc/pve/qemu-server/', '\d.*conf') },
67 sub { dir2text
('/etc/pve/lxc/', '\d.*conf') },
73 'ip -details -statistics address',
74 'ip -details -4 route show',
75 'ip -details -6 route show',
76 'cat /etc/network/interfaces',
82 sub { dir2text
('/etc/pve/firewall/', '.*fw') },
83 'cat /etc/pve/local/host.fw',
92 'cat /etc/pve/corosync.conf 2>/dev/null',
94 'cat /etc/pve/datacenter.cfg',
107 'lsblk --ascii -M -o +HOTPLUG,ROTA,PHY-SEC,FSTYPE,MODEL,TRAN',
108 'ls -l /dev/disk/by-*/',
110 'iscsiadm -m session',
123 if (cmd_exists
('zfs')) {
124 push @{$report_def->{volumes
}->{cmds
}},
132 if (-e
'/etc/ceph/ceph.conf') {
133 push @{$report_def->{volumes
}->{cmds
}},
139 'cat /etc/ceph/ceph.conf',
146 if (cmd_exists
('multipath')) {
147 push @{$report_def->{disks
}->{cmds
}},
148 'cat /etc/multipath.conf',
149 'cat /etc/multipath/wwids',
158 my $def = $init_report_cmds->();
161 my $record_output = sub {
162 $report .= shift . "\n";
165 local $ENV{'PATH'} = '/sbin:/bin:/usr/sbin:/usr/bin';
166 my $cmd_timeout = 10; # generous timeout
168 my $run_cmd_params = {
169 outfunc
=> $record_output,
170 errfunc
=> $record_output,
171 timeout
=> $cmd_timeout,
172 noerr
=> 1, # avoid checking programs exit code
175 my $sorter = sub { ($def->{$_[0]}->{order
} // 1<<30) <=> ($def->{$_[1]}->{order} // 1<<30) };
177 for my $section ( sort { $sorter->($a, $b) } keys %$def) {
178 my $s = $def->{$section};
179 my $title = $s->{title
} // "info about $section";
181 $report .= "\n==== $title ====\n";
182 for my $command (@{$s->{cmds
}}) {
184 if (ref $command eq 'CODE') {
185 $report .= PVE
::Tools
::run_with_timeout
($cmd_timeout, $command);
187 print STDERR
"Process ".$command."...";
188 $report .= "\n# $command\n";
189 PVE
::Tools
::run_command
($command, %$run_cmd_params);
194 $report .= "\nERROR: $@\n" if $@;