-
Notifications
You must be signed in to change notification settings - Fork 12
/
Copy pathcl-psgrep.pl
executable file
·71 lines (49 loc) · 1.75 KB
/
cl-psgrep.pl
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
#!/usr/bin/env perl
###########################################################################
# #
# Cluster Tools: cl-psgrep.pl #
# Copyright 2007-2011, Albert P. Tobey <[email protected]> #
# #
###########################################################################
=head1 NAME
cl-psgrep.pl - ps/grep across the cluster
=head1 SYNOPSIS
This utility, rather than doing the work on its own, simply calls run.pl. Not all of the options are passed through
and some (like -t) are implied. Most of the time, the very simplest usage is best.
cl-psgrep.pl snmpd
cl-psgrep.pl [-d] [-a] [-b] [-n] [-x]
-h: print this message
=cut
use Pod::Usage;
use Getopt::Long;
use FindBin qw($Bin);
use lib $Bin;
use DshPerlHostLoop;
our $help;
GetOptions( "h" => \$help );
if ( $help ) {
pod2usage();
}
pod2usage() if ( @ARGV == 0 );
my $proc = pop(@ARGV);
$proc =~ s/^(.)/[$1]/;
func_loop( \&runit );
sub runit {
my $host = shift;
my @out = ssh( $remote_user.'@'.$host, "ps -ewwwo pid,args" );
my $fh;
for my $line ( @out ) {
next unless ( $line =~ /$proc/ );
print "$host: $line\n";
}
exit 0;
}
# vim: et ts=4 sw=4 ai smarttab
__END__
=head1 COPYRIGHT AND LICENSE
This software is copyright (c) 2007-2011 by Al Tobey.
This is free software; you can redistribute it and/or modify it under the terms
of the Artistic License 2.0. (Note that, unlike the Artistic License 1.0,
version 2.0 is GPL compatible by itself, hence there is no benefit to having an
Artistic 2.0 / GPL disjunction.) See the file LICENSE for details.
=cut