/[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 293 - (show annotations)
Sun May 27 19:58:55 2012 UTC (11 years, 11 months ago) by dpavlin
File size: 1284 byte(s)
monitor gearman using munin

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 $name =~ s/\W+/_/g;
47 print "$name.label $name\n";
48 }
49 }
50 } else {
51 foreach my $multigraph ( keys %$stats ) {
52 print "multigraph $multigraph\n";
53 while ( my ($name,$value) = each %{ $stats->{$multigraph} } ) {
54 $name =~ s/\W+/_/g;
55 print "$name.value $value\n";
56 }
57 }
58 }
59

  ViewVC Help
Powered by ViewVC 1.1.26