#!/usr/bin/perl # # use Getopt::Std; getopts("vae:w:", \%option); if ($option{v} ) { print "Verbose mode enabled\n"; if ($option{a} ) { print "Entire cluster mode enabled\n"; } if ($option{e} ) { print "some nodes are being excluded\n"; } if ($option{w} ) { print "specific nodes are being included\n"; } print "\n"; } $node_ctr=-1; if ($option{e} ) { @exclude_nodes=split(/\,/, $option{e} ); foreach $t (@exclude_nodes) { $excluded_nodes{$t} = "yes"; if ($option{v} ) { print "Excluding $t\n"; } } } if (! ( $option{a} || $option{w}) ) { if ( -r "/all.nodes" ) { open (NODELIST, "< /all.nodes"); while ( ) { chomp; if ( index($_,"#") != 0 ) { if ( ! defined $excluded_nodes{$_} ) { $node_ctr++; $node_name[$node_ctr] = $_; } } } close (NODELIST); } else { print "The node list file /all.nodes was not found. Exiting.\n"; exit(1); } } elsif ($option{w} ) { # option w @include_nodes=split(/\,/, $option{w} ); foreach $node (@include_nodes) { $node_ctr++; $node_name[$node_ctr] = $node; } } else { # option a is only one left open (NODELIST, "/usr/sbin/cluster/utilities/clhandle -a |"); while ( ) { chomp; @f=split; if ( ! defined $excluded_nodes{$f[1]} ) { $node_ctr++; $node_name[$node_ctr] = $f[1]; } } close (NODELIST); } if ($option{v} ) { print "Current working collective:\n"; foreach $node (@node_name) { print "$node\n"; } $i=$#ARGV +1; print "Number parms is: $i \n"; } if ( $#ARGV >=0 ) { $i=0; while ( $i <= $#ARGV ) { $parm_string = $parm_string . " " . $ARGV[$i] ; $i++; } if ($option{v} ) { print "The complete parm string is: $parm_string\n"; } } else { print "Usage: gdsh -ave node1,node2 cmds \n"; print " where:\n"; print " -a -> all nodes in hacmp cluster (as reported by clhandle -a)\n"; print " -v -> verbose mode\n"; print " -e -> nodes to exclude in comma seperated list\n"; print " -w -> nodes to include in comma seperated list\n"; print " Command will use /all.nodes as working collective\n"; exit(1); } foreach $node (@node_name) { $t = `rsh $node $parm_string 2>&1`; if ($t ne "") { @f = split (/$\//, $t); foreach $line (@f) { print "$node: $line\n"; } } }