diff options
-rwxr-xr-x | files/plugins/apache_activity | 99 | ||||
-rw-r--r-- | manifests/plugin/deploy.pp | 41 | ||||
-rw-r--r-- | manifests/plugins/apache.pp | 4 |
3 files changed, 21 insertions, 123 deletions
diff --git a/files/plugins/apache_activity b/files/plugins/apache_activity deleted file mode 100755 index 65fc072..0000000 --- a/files/plugins/apache_activity +++ /dev/null @@ -1,99 +0,0 @@ -#!/usr/bin/perl -# -# Parameters supported: -# -# config -# autoconf -# -# Configurable variables -# -# url - Override default status-url -# -# Magic markers: -#%# family=auto -#%# capabilities=autoconf - -my $ret = undef; -if (!eval "require LWP::UserAgent;") { - $ret = "LWP::UserAgent not found"; -} - -my $URL = exists $ENV{'url'} ? $ENV{'url'} : "http://127.0.0.1:%d/server-status?auto"; -my @PORTS = exists $ENV{'ports'} ? split(' ', $ENV{'ports'}) : (80); -my %chars = ( - # '\_' => 'Waiting', - # 'S' => 'Starting up', - 'R' => 'Reading request', - 'W' => 'Sending reply', - 'K' => 'Keepalive', - 'D' => 'DNS lookup', - 'C' => 'Closing', - # 'L' => 'Logging', - # 'G' => 'Gracefully finishing', - # 'I' => 'Idle cleanup', - # '\.' => 'Open slot', - ); - -# "_" Waiting for Connection, "S" Starting up, "R" Reading Request, -# "W" Sending Reply, "K" Keepalive (read), "D" DNS Lookup, -# "C" Closing connection, "L" Logging, "G" Gracefully finishing, -# "I" Idle cleanup of worker, "." Open slot with no current process - -if (exists $ARGV[0] and $ARGV[0] eq "autoconf") { - if ($ret) { - print "no ($ret)\n"; - exit 1; - } - my $ua = LWP::UserAgent->new(timeout => 30); - my @badports; - - foreach my $port (@PORTS) { - my $url = sprintf $URL, $port; - my $response = $ua->request(HTTP::Request->new('GET',$url)); - push @badports, $port unless $response->is_success and $response->content =~ /Scoreboard/im; - } - - if (@badports) { - print "no (no apache server-status on ports @badports)\n"; - exit 1; - } else { - print "yes\n"; - exit 0; - } -} - -if (exists $ARGV[0] and $ARGV[0] eq "config") { - print "graph_title Apache activity\n"; - print "graph_args --base 1000 -l 0\n"; - print "graph_category apache\n"; - print "graph_vlabel processes\n"; - foreach my $port (@PORTS) { - while (my ($char, $val) = each (%chars)) { - $char =~ s/\\\./dot/; - $char =~ s/\\\_/underline/; - print "activity_${port}_${char}.label "; - print $val, "\n"; - print "activity_${port}_${char}.type GAUGE\n"; - } - } - exit 0; -} - -foreach my $port (@PORTS) { - my $ua = LWP::UserAgent->new (timeout => 30); - my $url = sprintf $URL, $port; - my $response = $ua->request (HTTP::Request->new('GET',$url)); - if ($response->content =~ /^Scoreboard\:\s?(.*)$/sm) { - my $string = $1; - chomp $string; - my @act = split (//, $string); - foreach my $char (keys (%chars)) { - my $num = scalar (grep (/$char/, @act)); - $char =~ s/\\\./dot/; - $char =~ s/\\\_/underline/; - print "activity_${port}_${char}.value $num\n"; - } - } -} - - diff --git a/manifests/plugin/deploy.pp b/manifests/plugin/deploy.pp index 9e74afb..cbf64fb 100644 --- a/manifests/plugin/deploy.pp +++ b/manifests/plugin/deploy.pp @@ -1,23 +1,31 @@ -define munin::plugin::deploy($source = '', $ensure = 'present', $config = '') { +# deploy and register a munin plugin +define munin::plugin::deploy( + $ensure = 'present', + $source = '', + $config = '', + $seltype = 'munin_exec_t' +) { $plugin_src = $ensure ? { 'present' => $name, - 'absent' => $name, - default => $ensure + 'absent' => $name, + default => $ensure } $real_source = $source ? { - '' => "munin/plugins/$plugin_src", + '' => "munin/plugins/${plugin_src}", default => $source } include munin::plugin::scriptpaths file { "munin_plugin_${name}": - path => "${munin::plugin::scriptpaths::script_path}/${name}", - source => "puppet:///modules/${real_source}", - mode => 0755, owner => root, group => 0; + path => "${munin::plugin::scriptpaths::script_path}/${name}", + source => "puppet:///modules/${real_source}", + owner => root, + group => 0, + mode => '0755'; } if ($::selinux == 'true') and (($::operatingsystem != 'CentOS') or ($::operatingsystem == 'CentOS' and $::lsbmajdistrelease != '5')){ File["munin_plugin_${name}"]{ - seltype => 'munin_exec_t', + seltype => $seltype, } } @@ -25,19 +33,12 @@ define munin::plugin::deploy($source = '', $ensure = 'present', $config = '') { openbsd: { $basic_require = File['/var/run/munin'] } default: { $basic_require = Package['munin-node'] } } - if $require { - File["munin_plugin_${name}"]{ - require => [ $basic_require, $require ], - } - } else { - File["munin_plugin_${name}"]{ - require => $basic_require, - } + File["munin_plugin_${name}"]{ + require => $basic_require, } # register the plugin - if $require { - munin::plugin{$name: ensure => $ensure, config => $config, require => $require } - } else { - munin::plugin{$name: ensure => $ensure, config => $config } + munin::plugin{$name: + ensure => $ensure, + config => $config } } diff --git a/manifests/plugins/apache.pp b/manifests/plugins/apache.pp deleted file mode 100644 index dca3cea..0000000 --- a/manifests/plugins/apache.pp +++ /dev/null @@ -1,4 +0,0 @@ -class munin::plugins::apache { - munin::plugin{ [ 'apache_accesses', 'apache_processes', 'apache_volume' ]: } - munin::plugin::deploy { 'apache_activity': } -} |