#!@@PERL@@ -w # -*- perl -*- # # Plugin copyright Bjørn Ruberg 2005-2009 # # Licensed under GPLv2. Be nice. # # Environment variables: # # - dbstat The full path to a db_stat binary able to # communicate with the LDAP backend BDB # database files. RHEL and friends use # slapd_db_stat, while Debian and such use # e.g. db4.6_stat. # - dbdir The full path to the directory where # the LDAP backend BDB database files are. # - title (Optional) The plugin's title. Useful if you # have more than one DIT installed. # - warning (Optional) A threshold integer value. Triggers # plugin to send warnings if cache percentage # drops below the given value. # # Limitations: # # - The plugin only checks _one_ database directory. To work # around that, i.e. if you have more than one DIT in your # OpenLDAP, create symlinked files and corresponding entries # in the Munin environment file(s). Note that this will # break autoconf, i.e. autoconf will probably still suggest # a default set of symlinks. # # Sample config for multiple database directories: # [slapd_bdb_cache_*] # env.dbstat /usr/bin/db4.6_stat # # [slapd_bdb_cache_database1_*] # env.dbdir /var/lib/ldap/database1 # # [slapd_bdb_cache_database2_*] # env.dbdir /var/lib/ldap/database2 # # Magic markers #%# family=auto #%# capabilities=autoconf suggest use strict; use vars qw ( $measure $config $dbdir $dbstat $warning); my $arg = shift (@ARGV); # Finding db_stat should be done here $dbstat = ($ENV{'dbstat'} || "/usr/bin/db4.6_stat"); # Also the LDAP database files $dbdir = ($ENV{'dbdir'} || "/var/lib/ldap"); # And the graph title my $title = ($ENV{'title'} || ''); # Die if no valid file ending, unless suggest/autoconf. if ($0 !~ /_(pages|percent)$/) { unless ($arg && $arg =~ /^(suggest|autoconf)$/) { die ("Plugin must be suffixed with 'percent' or 'pages'. Try running 'munin-node-configure suggest'"); } } # Check file name if ($0 =~ /_pages$/) { $measure = "pages"; } elsif ($0 =~ /_percent$/) { $measure = "percent"; } # Parse command line arguments if ($arg && $arg eq "config") { $config = 1; } elsif ($arg && $arg eq "autoconf") { if (! -x $dbstat) { print "no (Can't execute db_stat file '$dbstat')\n"; } elsif (! -d $dbdir || ! -r $dbdir) { print "no (Can't open database directory '$dbdir')"; } else { print "yes\n"; } exit 0; } elsif ($arg && $arg eq "suggest") { print "pages\n"; print "percent\n"; exit 0; } if ($config) { print <