-
Notifications
You must be signed in to change notification settings - Fork 3
/
watchdn
executable file
·102 lines (71 loc) · 1.7 KB
/
watchdn
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
#!/usr/bin/perl -w
# Find all operations relating to a particular DN
use strict;
use warnings;
$::VERSION = 0.1;
sub version()
{
print STDERR "$0 version $::VERSION\n";
exit 0;
}
sub usage()
{
print STDERR "Usage: $0 [-v] [-h] dn\n";
exit 1;
}
my %opt = (
'h' => 0, # Help
'v' => 0, # Version
);
my $dn = "cn=Directory Manager";
while (@ARGV) {
my $arg = shift @ARGV;
if ($arg =~ m{^-h$|^--help$}) {
$opt{h} = 1;
} elsif ($arg =~ m{^-v$|^--version$}) {
$opt{v} = 1;
} else {
$dn = $arg;
last;
}
}
version if $opt{v};
usage if $opt{h};
my %tuple;
while(<>) {
chomp;
if (my ($t) = m{ REQ (conn=[-0-9]+ op=[0-9]+ msgID=[0-9]+).*(base|dn|authDN)="$dn"}i) {
print "$_\n";
$tuple{$t} = 1;
next;
}
if (my ($t) = m{ RES (conn=[-0-9]+ op=[0-9]+ msgID=[0-9]+) }) {
print "$_\n" if exists $tuple{$t};
delete $tuple{$t};
next;
}
}
1;
__END__
=head1 NAME
watchdn - analyze operations for a particular DN in OpenDJ log files
=head1 SYNOPSIS
watchdn dn
watchdn -h
watchdn -v
=head1 DESCRIPTION
OpenDJ access log files record the requests and result for LDAP operations on
separate log lines by default. With a busy server, this can make following the
operations on a particular DN somewhat challenging.
This tool reports all operations and results affecting a given DN.
=head1 OPTIONS
=over
=item B<-h> display help text.
=item B<-v> report the tool version.
=item B<dn> the LDAP DN that needs to be monitored.
=back
=head1 AUTHOR
Chris Ridd E<lt>[email protected]<gt>
=head1 COPYRIGHT
Copyright (c) 2014 Chris Ridd. All rights reserved. This tool is free software;
you can redistribute it and/or modify it under the same terms as Perl itself.