Tuesday, March 2, 2010

Find null attribute and modify on Ldap Server


Language null search


ldapsearch -x -h localhost -p 389 -D cn=root,dc=mycompany,dc=com -w secret -b ou=subscribers,dc=mycompany,dc=com "(!(tnaLanguage=*))" dn | grep dn:

This script gives us the subscribers without having tnaLanguage attribute.
Modify entries having null language

dn: tnaId=2108840497330132510,ou=subscribers,dc=mycompany,dc=com

dn: tnaId=2806900514076119703,ou=subscribers,dc=mycompany,dc=com

dn: tnaId=3602194238187496434,ou=subscribers,dc=mycompany,dc=com

dn: tnaId=2806900514076119725,ou=subscribers,dc=mycompany,dc=com

Compose modifyLanguage.ldif like below

dn: tnaId=807889406294118443,ou=subscribers,dc=mycompany,dc=com

changetype:modify

add: tnaLanguage

tnaLanguage: english


Execute ldif file like below
ldapmodify -x -h localhost -p 389 -D cn=root,dc=mycompany,dc=com -w secret -f modifyLanguage.ldif

Note: You need use cshell for the use of " ! " sign before search operation

Monday, March 1, 2010

Auto Copy a file to destination host

[root@tas5 astelit]# cat /root/scripts/cleanupcopy.sh
#!/usr/bin/expect -f
# connect via scp
spawn scp /space/cleanupOpendsExport.ldif root@10.1.11.1:/space/
#######################
expect {
-re ".*es.*o.*" {
exp_send "yes\r"
exp_continue
}
-re ".*sword.*" {
exp_send "myPassword\r"
}
}
interact
[root@tas5 astelit]# ENJOY WITH IT :-)
NOTE: This script is copying the local file {/space/cleanupOpendsExport.ldif} to the destination host with IP {10.1.11.1} without entering password.Destination host username is {root} and its password is {myPassword}, destination folder is /space

Saturday, February 27, 2010

How To Tune Performance of OpenDS

OpenDS logo
Set the following JVM_ARGS in the file $OPENDS_INSTALL_DIR/config/java.properties for the start-ds command.

-Xms1536m -Xmx1536m -XX:NewSize=768m -XX:MaxNewSize=768m -XX:SurvivorRatio=5 -XX:TargetSurvivorRatio=90 -XX:MaxTenuringThreshold=12 -XX:+UseConcMarkSweepGC -XX:+CMSIncrementalMode -XX:+CMSIncrementalPacing -XX:+CMSParallelRemarkEnabled -XX:+UseParNewGC -XX:MaxPermSize=128m -XX:+UseTLAB -XX:+CMSClassUnloadingEnabled -XX:+CMSPermGenSweepingEnabled -XX:+DisableExplicitGC -XX:+HeapDumpOnOutOfMemoryError

Also to prevent the OPENDS HIGH CPU USAGE problem you must enable the beackendDB (berkley JE Database) cache by using the following command.Note that this command can be used while system is running up and have load.Tested enough :)

[root@ochemw bin]# ./dsconfig -h localhost --port 4444 -D "cn=Directory Manager" -w password-X -n set-backend-prop --backend-name userRoot --set db-cache-percent:50
For the details and cache percentage calculations you can refer to the opends perf. tuning page.

Friday, February 26, 2010

A few nice links

http://www.tutorialspoint.com/java/
http://www.exampledepot.com/

Dating with Date and Flirting with Calendar

import java.util.Properties;
import java.io.FileInputStream;
import java.io.IOException;
import java.util.Set;
import java.util.*;
import java.util.Collections;
import java.text.SimpleDateFormat;
import java.text.ParseException;

public class DatingWithDate {

private static final SimpleDateFormat df = new SimpleDateFormat ("yyyy-MM-dd HH:mm:ss");
protected final static long MILLSECS_PER_DAY = 24L * 60L * 60L * 1000L;

public static void main (String[] args) throws IOException, ParseException {
Calendar now = Calendar.getInstance();
printCalendar (now);
now.add(Calendar.DAY_OF_YEAR,1);
printCalendar (now);
System.exit(0);

}
private static void printCalendar(Calendar calendar)
{
String date = df.format(calendar.getTime());
System.out.println(date);
}

}