/[sysadmin-cookbook]/recepies/munin/plugins/gearman
This is repository of my old source code which isn't updated any more. Go to git.rot13.org for current projects!
ViewVC logotype

Contents of /recepies/munin/plugins/gearman

Parent Directory Parent Directory | Revision Log Revision Log


Revision 294 - (show annotations)
Sun May 27 20:06:24 2012 UTC (12 years ago) by dpavlin
File size: 1307 byte(s)
preserve original function name for label
1 #!/usr/bin/perl
2 use warnings;
3 use strict;
4
5 # 2012-05-27 Dobrica Pavlinusic <dpavlin@rot13.org>
6
7 use IO::Socket::INET;
8 use Data::Dump qw(dump);
9
10 my $arg = shift @ARGV;
11 $arg ||= '';
12
13 my $sock = IO::Socket::INET->new(
14 PeerAddr => '127.0.0.1',
15 PeerPort => 4730,
16 Proto => 'tcp'
17 ) || die $1;
18
19 if ( $arg eq 'autoconf' ) {
20 print $sock ? "yes\n" : "no\n";
21 exit 0;
22 }
23
24 print $sock "STATUS\n";
25
26 my $stats;
27
28 while ( my $line = <$sock> ) {
29 chomp $line;
30 # warn "# [$line]\n";
31 last if $line eq '.';
32 next if $line =~ m/\t0$/; # ignore functions which don't have active workers
33 my ( $name, $queued, $running, $workers ) = split(/\t/,$line,4);
34 $stats->{queued}->{$name} = $queued;
35 $stats->{running}->{$name} = $running;
36 $stats->{workers}->{$name} = $workers;
37 }
38
39 if ( $arg eq 'config' ) {
40 foreach my $multigraph ( keys %$stats ) {
41 print "multigraph $multigraph\n";
42 print "graph_category gearman\n";
43 print "graph_title Gearman $multigraph\n";
44
45 foreach my $name ( keys %{ $stats->{$multigraph} } ) {
46 my $label = $name;
47 $name =~ s/\W+/_/g;
48 print "$name.label $label\n";
49 }
50 }
51 } else {
52 foreach my $multigraph ( keys %$stats ) {
53 print "multigraph $multigraph\n";
54 while ( my ($name,$value) = each %{ $stats->{$multigraph} } ) {
55 $name =~ s/\W+/_/g;
56 print "$name.value $value\n";
57 }
58 }
59 }
60

  ViewVC Help
Powered by ViewVC 1.1.26