3 # Copyright (c) 2005-2007 MySQL AB
5 # This program is free software; you can redistribute it and/or modify
6 # it under the terms of the GNU General Public License as published by
7 # the Free Software Foundation; version 2 of the License.
9 # This program is distributed in the hope that it will be useful,
10 # but WITHOUT ANY WARRANTY; without even the implied warranty of
11 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 # GNU General Public License for more details.
14 # You should have received a copy of the GNU General Public License
15 # along with this program; if not, write to the Free Software
16 # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
22 print STDERR
"Usage:\n";
23 print STDERR
"\tndb_error_reporter config.ini [username] [--fs]\n\n";
24 print STDERR
"\tusername is a user that you can use to ssh into\n";
25 print STDERR
"\t all of your nodes with.\n\n";
26 print STDERR
"\t--fs means include the filesystems in the report\n";
27 print STDERR
"\t WARNING: This may require a lot of disk space.\n";
28 print STDERR
"\t Only use this option when asked to.\n\n";
32 my $config_file= $ARGV[0];
34 my $config_username= '';
37 $config_get_fs= 1 if $ARGV[1] eq '--fs';
38 $config_username= $ARGV[1].'@' if $ARGV[1] ne '--fs';
39 $config_get_fs= (defined $ARGV[2] && $ARGV[2] eq '--fs')?
1:$config_get_fs;
42 if(!stat($config_file))
44 print STDERR
"Cannot open configuration file.\n\n";
48 my @nodes= split ' ',`ndb_config --config-file=$ARGV[0] --nodes --query=id --type=ndbd`;
50 push @nodes, split ' ',`ndb_config --config-file=$ARGV[0] --nodes --query=id --type=ndb_mgmd`;
55 my $res= `ndb_config --config-file=$ARGV[0] --id=$nodeid --query=$query`;
61 my $reportdir= sprintf('ndb_error_report_%u%02u%02u%02u%02u%02u',
62 ($t[5]+1900),($t[4]+1),$t[3],$t[2],$t[1],$t[0]);
64 if(stat($reportdir) || stat($reportdir.'tar.bz2'))
66 print STDERR
"It looks like another ndb_error_report process is running.\n";
67 print STDERR
"If that is not the case, remove the ndb_error_report directory";
68 print STDERR
" and run ndb_error_report again.\n\n";
74 foreach my $node (@nodes)
76 print "\n\n Copying data from node $node".
77 (($config_get_fs)?
" with filesystem":"").
79 my $recurse= ($config_get_fs)?
'-r ':'';
80 system 'scp -p '.$recurse.$config_username.config
($node,'host').
81 ':'.config
($node,'datadir')."/ndb_".$node."* ".
85 print "\n\n Copying configuration file...\n\n\t$config_file\n\n";
86 system "cp -p $config_file $reportdir/";
88 my $r = system 'bzip2 2>&1 > /dev/null < /dev/null';
92 $outfile= "$reportdir.tar.bz2";
93 system "tar c $reportdir|bzip2 > $outfile";
97 $outfile= "$reportdir.tar.gz";
98 system "tar c $reportdir|gzip > $outfile";
101 system "rm -rf $reportdir";
103 print "\n\nPlease attach $outfile to your error report\n\n";