Tuesday May 19, 2009

Directory Server Log Analyzer 0.0.3.1 released

Version 0.0.3.1 of Directory Server Log Analyzer has been released. This version has a re-worked presentation of the data from an uploaded file. There is also some additional language on the upload page to describe how to use cURL to upload files directly to the application, which is repeated here:


 curl -F 'uploadedFile=@access' \\
    --form-string hostname=example.com \\
    --form-string description="a description of the file" 
    --form-string instance="the name of the instance" \\
    http://www.example.com:8080/dsla/FileUploaded.action > /dev/null

The command line above uploads a file named "access", provides a hostname, description, and the name of the instance where the access file was generated. Hostname, description and instance name could be omitted, in which case suitable defaults are provided. Use the correct application server hostname and port, obviously. The field named "uploadFile" is required, and must be named "uploadFile". Download the application WAR file from the download area at http://kenai.com and deploy into GlassFish or Tomcat under contextroot "dsla".

Friday May 02, 2008

cache.pl

The following is a perl script that I use to have a quick look at some values in the ldbm database tree. Example usage and output is:
 # ./cache.pl --root /var/opt/sun/ds6 --pwdFile ~/ds6pwd  --bindDN 'cn=dmanager'
localhost 22:23:29 hitratio:99 pagein:560 pageout:561 roevict:0 rwevict:0
localhost 22:23:30 hitratio:99 pagein:560 pageout:561 roevict:0 rwevict:0
localhost 22:23:31 hitratio:99 pagein:560 pageout:561 roevict:0 rwevict:0
localhost 22:23:32 hitratio:99 pagein:560 pageout:561 roevict:0 rwevict:0
The script is very basic and easily extendable.
=== snip ===
#! /usr/bin/perl -w

#
# terry.gardner@sun.com
#
# 08-FEB-2008
#

# Parameter and variables

my ( $lines, $linesPerPage, $loadPerConnection );

#
# set up some default values
#
$port      = 389;
$root      = "/ldap/";
$instance  = "slapd-native";
$delay     = 1;
$hostname  = "localhost";
$pidFile   = $root . "/logs/pid";
$bindDN    = "cn=directory manager";
$pwdFile   = "ds6pwd";
$ldapsearch = "/opt/sun/dsrk6/bin/ldapsearch";
#
# parameters that cannot be modified by
# command line options
#
$dbCacheDN="cn=monitor,cn=ldbm database,cn=plugins,cn=config";

sub displayUsageHints() {
  print "cache.pl prints a tabular display of some directory server\\n";
  print "        operational information.\\n";
  print "\\n";
  print "Usage:\\n";
  print "cache.pl [OPTIONS]\\n";
  print "\\n";
  print "[--hostname hostname]           LDAP server hostname, default: $hostname\\n";
  print "[--port port]                   LDAP server port, default: $port\\n";
  print "[--instance instance]           LDAP server instance, default: $instance\\n";
  print "[--delay delay]                 delay in seconds between samples, default: $delay\\n";
  print "[--pwdFile filename]            file containing the root DN password, default: $pwdFile";
  print "[--bindDN bindDN]               root DN, default $bindDN";
  print "[--ldapsearch ldapsearchBinary] ldapsearch binary, default $ldapsearch";
  print "[--help]                        display ds_monitor.pl command invocation hints\\n";
}

#
# process command line options
#
$sn = 0;
for (@ARGV) {
  if (/--port/) {
    $port = $ARGV[++$sn];
    ++$sn;
  } elsif (/--hostname/) {
    $hostname = $ARGV[++$sn];
    ++$sn;
  } elsif (/--root/) {
    $root = $ARGV[++$sn];
    ++$sn;
  } elsif (/--instance/) {
    $instance = $ARGV[++$sn];
    ++$sn;
  } elsif (/--delay/) {
    $delay = $ARGV[++$sn];
    ++$sn;
  } elsif (/--pidFile/) {
    $pidFile = $ARGV[++$sn];
    ++$sn;
  } elsif (/--pwdFile/) {
    $pwdFile = $ARGV[++$sn];
    ++$sn;
  } elsif (/--bindDN/) {
    $bindDN = $ARGV[++$sn];
    ++$sn;
  } elsif (/--ldapsearch/) {
    $ldapsearch = $ARGV[++$sn];
    ++$sn;
  } elsif (/--help/) {
    &displayUsageHints;
    exit;
  }
}

$scratchFile = "/tmp/" . "cache-" . `date +%H%m%S`;

$lines = 0;
$linesPerPage = 30;

for (;;) {
  # database cache
  $searchBase = $dbCacheDN;
  $cmd = "$ldapsearch -D '$bindDN' -j '$pwdFile' -s base -h $hostname -p $port -b '$searchBase' '(objectClass=\*)'  > $scratchFile";
  `$cmd`;

  open(scratchFile,$scratchFile) || die "Failed to open $scratchFile: $!";

  while ()
  {
    chomp();

    s/://;

    ($attribute,$value) = split(" ",$_,2);

    if (/dbcachehitratio/) {
      $dbcachehitratio = $value;
    } elsif (/dbcachepagein/) {
      $dbcachepagein = $value;
    } elsif (/dbcachepageout/) {
      $dbcachepageout = $value;
    } elsif (/dbcacheroevict/) {
      $dbcacheroevict = $value;
    } elsif (/dbcacherwevict/) {
      $dbcacherwevict = $value;
    }

    $attribute = "";
  }


  close(scratchFile);
  
  # Get the current time
  ($sec,$min,$hour,$junk,$junk,$junk,$junk,$junk,$junk) = localtime(time);

  printf "%9.9s %2.2d:%2.2d:%2.2d hitratio:%d pagein:%d pageout:%d roevict:%d rwevict:%d\\n",
       $hostname,
       $hour,
       $min,
       $sec,
       $dbcachehitratio,
       $dbcachepagein,
       $dbcachepageout,
       $dbcacheroevict,
       $dbcacherwevict;

  sleep $delay;

}
=== snip ===
About

Sun, LDAP, SLAMD, DSLA, java, Struts, networking, chess, books, cooking, wine, and many other things.

Search

Archives
« April 2014
SunMonTueWedThuFriSat
  
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
   
       
Today