source: gs2-extensions/parallel-building/trunk/src/bin/script/stop-runaway-hadoop.pl@ 30354

Last change on this file since 30354 was 27005, checked in by jmt12, 11 years ago

Similar to stop-impt.pl, this script uses kill to stop runaway Hadoop processes and can be run via rocks hosts run. This can happen, for instance, if tmpwatch wipes out the temporary files containing vital pids on the headnode. In related news Hadoop pid files now moved somewhere non-volatile on Medusa

  • Property svn:executable set to *
  • Property svn:mime-type set to application/x-perl
File size: 846 bytes
Line 
1#!/usr/bin/perl
2
3use strict;
4use warnings;
5
6my $debug = 0;
7
8print "===== Stop Runaway Hadoop Nodes =====\n";
9
10print " * Searching running processes...\n";
11open(FIN, 'ps ax -o pid,command |') or die($!);
12my $line = '';
13my $found_process = 0;
14while (($line = <FIN>))
15{
16 # Kill import processes
17 if ($line =~ /^\s*(\d+)\s+(.*)java -Dproc_(datanode|jobtracker|namenode|secondarynamenode|tasktracker)/)
18 {
19 my $pid = $1;
20 my $prefix = $2;
21 my $type = $3;
22 print " - Found " . $type . " process: [" . $pid . "]... ";
23 my $cmd = 'kill -KILL ' . $pid;
24 if ($debug)
25 {
26 print "[DEBUG] " . $cmd . "\n";
27 }
28 else
29 {
30 `$cmd`;
31 print "Process killed!\n";
32 }
33 $found_process = 1;
34 }
35}
36close(FIN);
37
38if (!$found_process)
39{
40 print " * No running Hadoop processes found!\n";
41}
42
43print "Complete!\n\n";
44
45exit;
Note: See TracBrowser for help on using the repository browser.