]>
git.proxmox.com Git - pve-manager.git/blob - PVE/Report.pm
228fbb29b8a2cd1e74b30e9ee51fb71af5bf42d0
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',
24 'pvesh get /cluster/resources --type node --output-format=yaml',
28 'cat /etc/pve/storage.cfg',
36 sub { dir2text
('/etc/pve/qemu-server/', '\d.*conf') },
38 sub { dir2text
('/etc/pve/lxc/', '\d.*conf') },
41 'ip -details -statistics address',
42 'ip -details -4 route show',
43 'ip -details -6 route show',
44 'cat /etc/network/interfaces',
47 sub { dir2text
('/etc/pve/firewall/', '.*fw') },
48 'cat /etc/pve/local/host.fw',
54 'cat /etc/pve/corosync.conf 2>/dev/null',
65 'ls -l /dev/disk/by-*/',
67 'iscsiadm -m session',
76 push @{$report_def->{volumes
}}, 'zpool status', 'zpool list -v', 'zfs list'
79 if (-e
'/etc/ceph/ceph.conf') {
80 # TODO: add (now working) rdb ls over all pools? really needed?
81 push @{$report_def->{volumes
}}, 'pveceph status', 'ceph osd status',
82 'ceph df', 'ceph osd df tree', 'cat /etc/ceph/ceph.conf',
83 'ceph config dump', 'pveceph pool ls', 'ceph versions';
86 push @{$report_def->{disks
}}, 'multipath -ll', 'multipath -v3'
87 if cmd_exists
('multipath');
93 # output the content of all the files of a directory
95 my ($target_dir, $regexp) = @_;
97 PVE
::Tools
::dir_glob_foreach
($target_dir, $regexp, sub {
99 $report .= "\n# cat $target_dir$file\n";
100 $report .= PVE
::Tools
::file_get_contents
($target_dir.$file)."\n";
104 # command -v is the posix equivalent of 'which'
105 sub cmd_exists
{ system("command -v '$_[0]' > /dev/null 2>&1") == 0 }
109 my $report_def = $init_report_cmds->();
111 my @report_order = ('general', 'storage', 'virtual guests', 'network',
112 'firewall', 'cluster', 'bios', 'pci', 'disks', 'volumes');
115 my $record_output = sub {
116 $report .= shift . "\n";
119 my $run_cmd_params = {
120 outfunc
=> $record_output,
121 errfunc
=> $record_output,
122 timeout
=> $cmd_timeout,
123 noerr
=> 1, # avoid checking programs exit code
126 foreach my $section (@report_order) {
127 my $s = $report_def->{$section};
129 my $title = "info about $section";
132 if (ref($s) eq 'HASH') {
133 $commands = $s->{cmds
};
134 $title = $s->{title
} if defined($s->{title
});
135 } elsif (ref($s) ne 'ARRAY') {
136 die "unknown report definition in section '$section'!";
139 $report .= "\n==== $title ====\n";
140 foreach my $command (@$commands) {
142 if (ref $command eq 'CODE') {
143 PVE
::Tools
::run_with_timeout
($cmd_timeout, $command);
145 print STDERR
"Process ".$command."...";
146 $report .= "\n# $command\n";
147 PVE
::Tools
::run_command
($command, %$run_cmd_params);
152 $report .= "\nERROR: $@\n" if $@;