Nagios plugin to observe LDAP

WWW:	http://search.cpan.org/dist/Nagios-Plugin-LDAP/

PR:		ports/155145
Submitted by:	Alexander Kriventsov <avk at vl.ru>
This commit is contained in:
Martin Wilke 2011-03-18 09:37:41 +00:00
parent bb0eee0de2
commit 3820de45de
Notes: svn2git 2021-03-31 03:12:20 +00:00
svn path=/head/; revision=271239
7 changed files with 164 additions and 0 deletions

View File

@ -193,6 +193,7 @@
SUBDIR += p5-NSNMP
SUBDIR += p5-Nagios-Object
SUBDIR += p5-Nagios-Plugin
SUBDIR += p5-Nagios-Plugin-LDAP
SUBDIR += p5-Nagios-Plugins-Memcached
SUBDIR += p5-Net-ACL
SUBDIR += p5-Net-Abuse-Utils

View File

@ -0,0 +1,31 @@
# New ports collection makefile for: p5-Nagios-Plugin-LDAP
# Date created: 01 Mar 2011
# Whom: Alexander Kriventsov <avk@vl.ru>
#
# $FreeBSD$
#
PORTNAME= Nagios-Plugin-LDAP
PORTVERSION= 0.04
CATEGORIES= net-mgmt
MASTER_SITES= CPAN
PKGNAMEPREFIX= p5-
MAINTAINER= avk@vl.ru
COMMENT= Nagios plugin to observe LDAP
PERL_CONFIGURE= yes
BUILD_DEPENDS= ${SITE_PERL}/Net/LDAP.pm:${PORTSDIR}/net/p5-perl-ldap \
${SITE_PERL}/Nagios/Plugin.pm:${PORTSDIR}/net-mgmt/p5-Nagios-Plugin \
${SITE_PERL}/${PERL_ARCH}/Time/HiRes.pm:${PORTSDIR}/devel/p5-Time-HiRes \
${SITE_PERL}/${PERL_ARCH}/DateTime.pm:${PORTSDIR}/devel/p5-DateTime
RUN_DEPENDS= ${BUILD_DEPENDS}
MAN3= Nagios::Plugin::LDAP.3
post-patch:
@${FIND} ${WRKSRC} -name "*.orig" -delete
.include <bsd.port.mk>

View File

@ -0,0 +1,2 @@
SHA256 (Nagios-Plugin-LDAP-0.04.tar.gz) = 7f720b3ef24b763d9828abf96f780b110e3976de6974b40651f3da434c82f756
SIZE (Nagios-Plugin-LDAP-0.04.tar.gz) = 22131

View File

@ -0,0 +1,11 @@
--- lib/Nagios/Plugin/LDAP.pm 2009-01-14 02:29:40.000000000 +0000
+++ lib/Nagios/Plugin/LDAP.pm 2009-01-15 02:17:56.000000000 +0000
@@ -257,6 +257,7 @@
return 1 unless $warning or $critical;
my $src_ldap = $self->_ldap_connect($master) or return;
+ $self->_ldap_bind($src_ldap);
my $src_entry =
$self->_ldap_do_search($src_ldap, '(&(objectClass=*)(contextCSN=*))', 'contextCSN')

View File

@ -0,0 +1,107 @@
--- lib/Nagios/Plugin/LDAP.pm 2010-12-10 15:57:47.000000000 +0000
+++ lib/Nagios/Plugin/LDAP.pm 2010-12-10 15:58:13.000000000 +0000
@@ -266,44 +266,67 @@
$self->_ldap_do_search($dst_ldap, '(&(objectClass=*)(contextCSN=*))', 'contextCSN')
or return;
- my $src_csn = $src_entry->get_value('contextCSN');
- my $dst_csn = $dst_entry->get_value('contextCSN');
+ foreach my $src_current_csn (@{$src_entry->{'asn'}->{'attributes'}->[0]->{'vals'}}) {
+ my @csn=split('#',$src_current_csn);
+ my $src_server_id=$csn[2];
+
+ my $dst_current_csn;
+ my $dst_server_id;
+ foreach my $dst_temp_csn (@{$dst_entry->{'asn'}->{'attributes'}->[0]->{'vals'}}) {
+ my @temp_csn=split('#',$dst_temp_csn);
+ $dst_server_id=$temp_csn[2];
+ if ($dst_server_id eq $src_server_id){
+ $dst_current_csn=$dst_temp_csn;
+ last;
+ }
+ }
+
+ print "Host csn id: $src_server_id \n" if $verbose;
+ print "Master csn id: $dst_server_id \n" if $verbose;
+ print "Host csn: $src_current_csn \n" if $verbose;
+ print "Master csn: $dst_current_csn \n" if $verbose;
+
+ my $src_csn = $src_current_csn;
+ my $dst_csn = $dst_current_csn;
+
+ print "Master CSN = $src_csn\n" if $verbose;
+ print "Slave CSN = $dst_csn\n" if $verbose;
+
+ my ($YYYY, $MM, $DD, $hh, $mm, $ss);
+ ($YYYY, $MM, $DD, $hh, $mm, $ss) = $src_csn =~ /^(\d{4})(\d\d)(\d\d)(\d\d)(\d\d)(\d\d)/;
+ my $src_dt = DateTime->new(
+ year => $YYYY,
+ month => $MM,
+ day => $DD,
+ hour => $hh,
+ minute => $mm,
+ second => $ss
+ );
+ ($YYYY, $MM, $DD, $hh, $mm, $ss) = $dst_csn =~ /^(\d{4})(\d\d)(\d\d)(\d\d)(\d\d)(\d\d)/;
+ my $dst_dt = DateTime->new(
+ year => $YYYY,
+ month => $MM,
+ day => $DD,
+ hour => $hh,
+ minute => $mm,
+ second => $ss
+ );
+
+ my $delta = abs($src_dt->epoch - $dst_dt->epoch);
+
+ $self->add_message(
+ $self->check_threshold(check => $delta, warning => $warning, critical => $critical),
+ sprintf("csn id %s: %d seconds replication delta", $src_server_id,$delta));
+
+ $self->add_perfdata(
+ label => "repl$src_server_id",
+ value => $delta,
+ uom => 's',
+ threshold => $self->threshold
+ );
- print "Master CSN = $src_csn\n" if $verbose;
- print "Slave CSN = $dst_csn\n" if $verbose;
-
- my ($YYYY, $MM, $DD, $hh, $mm, $ss);
- ($YYYY, $MM, $DD, $hh, $mm, $ss) = $src_csn =~ /^(\d{4})(\d\d)(\d\d)(\d\d)(\d\d)(\d\d)/;
- my $src_dt = DateTime->new(
- year => $YYYY,
- month => $MM,
- day => $DD,
- hour => $hh,
- minute => $mm,
- second => $ss
- );
- ($YYYY, $MM, $DD, $hh, $mm, $ss) = $dst_csn =~ /^(\d{4})(\d\d)(\d\d)(\d\d)(\d\d)(\d\d)/;
- my $dst_dt = DateTime->new(
- year => $YYYY,
- month => $MM,
- day => $DD,
- hour => $hh,
- minute => $mm,
- second => $ss
- );
-
- my $delta = abs($src_dt->epoch - $dst_dt->epoch);
-
- $self->add_message(
- $self->check_threshold(check => $delta, warning => $warning, critical => $critical),
- sprintf("%d seconds replication delta", $delta));
-
- $self->add_perfdata(
- label => 'repl',
- value => $delta,
- uom => 's',
- threshold => $self->threshold
- );
+ print "\n" if $verbose;
+ }
}

View File

@ -0,0 +1,4 @@
Nagios plugin to observe LDAP
WWW: http://search.cpan.org/dist/Nagios-Plugin-LDAP/

View File

@ -0,0 +1,8 @@
%%SITE_PERL%%/%%PERL_ARCH%%/auto/Nagios/Plugin/LDAP/.packlist
bin/check_ldap_repl
%%SITE_PERL%%/Nagios/Plugin/LDAP.pm
@dirrmtry %%SITE_PERL%%/Nagios/Plugin
@dirrmtry %%SITE_PERL%%/Nagios
@dirrmtry %%SITE_PERL%%/%%PERL_ARCH%%/auto/Nagios/Plugin/LDAP
@dirrmtry %%SITE_PERL%%/%%PERL_ARCH%%/auto/Nagios/Plugin
@dirrmtry %%SITE_PERL%%/%%PERL_ARCH%%/auto/Nagios