]>
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 my $init_report_cmds = sub {
13 # NOTE: always add new sections to the report_order array!
16 title
=> 'general system info',
19 'pveversion --verbose',
21 'top -b -n 1 | head -n 15',
22 'pvesubscription get',
23 'cat /etc/apt/sources.list',
24 sub { dir2text
('/etc/apt/sources.list.d/', '.*list') },
25 sub { dir2text
('/etc/apt/sources.list.d/', '.*sources') },
27 'pvesh get /cluster/resources --type node --output-format=yaml',
31 'cat /etc/pve/storage.cfg',
39 sub { dir2text
('/etc/pve/qemu-server/', '\d.*conf') },
41 sub { dir2text
('/etc/pve/lxc/', '\d.*conf') },
44 'ip -details -statistics address',
45 'ip -details -4 route show',
46 'ip -details -6 route show',
47 'cat /etc/network/interfaces',
50 sub { dir2text
('/etc/pve/firewall/', '.*fw') },
51 'cat /etc/pve/local/host.fw',
57 'cat /etc/pve/corosync.conf 2>/dev/null',
68 'ls -l /dev/disk/by-*/',
70 'iscsiadm -m session',
79 push @{$report_def->{volumes
}}, 'zpool status', 'zpool list -v', 'zfs list'
82 if (-e
'/etc/ceph/ceph.conf') {
83 push @{$report_def->{volumes
}},
88 'cat /etc/ceph/ceph.conf',
95 push @{$report_def->{disks
}}, 'multipath -ll', 'multipath -v3'
96 if cmd_exists
('multipath');
102 # output the content of all the files of a directory
104 my ($target_dir, $regexp) = @_;
106 PVE
::Tools
::dir_glob_foreach
($target_dir, $regexp, sub {
108 $report .= "\n# cat $target_dir$file\n";
109 $report .= PVE
::Tools
::file_get_contents
($target_dir.$file)."\n";
113 # command -v is the posix equivalent of 'which'
114 sub cmd_exists
{ system("command -v '$_[0]' > /dev/null 2>&1") == 0 }
118 my $report_def = $init_report_cmds->();
120 my @report_order = ('general', 'storage', 'virtual guests', 'network',
121 'firewall', 'cluster', 'bios', 'pci', 'disks', 'volumes');
124 my $record_output = sub {
125 $report .= shift . "\n";
128 my $run_cmd_params = {
129 outfunc
=> $record_output,
130 errfunc
=> $record_output,
131 timeout
=> $cmd_timeout,
132 noerr
=> 1, # avoid checking programs exit code
135 foreach my $section (@report_order) {
136 my $s = $report_def->{$section};
138 my $title = "info about $section";
141 if (ref($s) eq 'HASH') {
142 $commands = $s->{cmds
};
143 $title = $s->{title
} if defined($s->{title
});
144 } elsif (ref($s) ne 'ARRAY') {
145 die "unknown report definition in section '$section'!";
148 $report .= "\n==== $title ====\n";
149 foreach my $command (@$commands) {
151 if (ref $command eq 'CODE') {
152 PVE
::Tools
::run_with_timeout
($cmd_timeout, $command);
154 print STDERR
"Process ".$command."...";
155 $report .= "\n# $command\n";
156 PVE
::Tools
::run_command
($command, %$run_cmd_params);
161 $report .= "\nERROR: $@\n" if $@;