Manage Learn to apply best practices and optimize your operations.

Collect database statistics using database directory

Using the database directory class is a great way to collect database statistics for a given server.

Using the database directory class is a great way to collect database statistics for a given server. By using getFirstDatabase and getNextDatabase, a subset of the database information can be retrieved without actually opening the database. This information includes database title, type, path, name, size and other various properties. The java class works very quickly and can collect data for all databases on a server within seconds. You could use this class to write statistics using a JDBC connection, and/or to collect data periodically for statistical growth charts or monitoring.

  
  import lotus.domino.*;
public class JavaAgent extends AgentBase {
 public String serverName = null;
 public DbDirectory dir = null;
 public double totalsize = 0;
 public double size = 0;
 
 public void NotesMain() 
 {
  
      try 
  {
        Session session = getSession();
        AgentContext agentContext = 
session.getAgentContext();
   serverName = "DSTALPHA";
        dir = session.getDbDirectory(serverName);
        serverName = dir.getName();

       if (serverName.equals("")) 
serverName = "Local";
       System.out.println ("Database 
directory list on server " + serverName 
+ "n");
       Database db = dir.getFirstDatabase
(DbDirectory.DATABASE);
       while (db != null) 
   {
    try
    {
            String fn = db.getFileName();
            String title = db.getTitle();
        size = db.getSize();
            totalsize = totalsize + size;
            System.out.println(fn.toUpperCase() 
+ " - " + title + " is " + 
Long.toString((long) size) + " bytes");
            db = dir.getNextDatabase(); 
           }
           catch (NotesException e)
     {
      db = dir.getNextDatabase(); 
      System.out.println("Unable to open 
database.");
     }
      } //end while
  dir.recycle();
  } 
  catch (NotesException e)
  {
   e.printStackTrace();
  }
  catch(Exception e) 
  {
        e.printStackTrace();
      }
  finally 
  {
       
       System.out.println("The total size 
of all databases on "+ serverName 
+ ": " + Long.toString((long) totalsize) + " bytes");
      }
    }
}

Do you have comments on this tip? Let us know.

This tip was submitted to the SearchDomino.com tip exchange by member Darren Wright. Please let others know how useful it is via the rating scale at the end of the tip. Do you have a useful Notes/Domino tip or code to share? Submit it to our monthly tip contest and you could win a prize and a spot in our Hall of Fame.

This was last published in November 2004

Dig Deeper on Java for Lotus Notes Domino

Start the conversation

Send me notifications when other members comment.

By submitting you agree to receive email from TechTarget and its partners. If you reside outside of the United States, you consent to having your personal data transferred to and processed in the United States. Privacy

Please create a username to comment.

-ADS BY GOOGLE

SearchWindowsServer

Search400

  • iSeries tutorials

    Search400.com's tutorials provide in-depth information on the iSeries. Our iSeries tutorials address areas you need to know about...

  • V6R1 upgrade planning checklist

    When upgrading to V6R1, make sure your software will be supported, your programs will function and the correct PTFs have been ...

  • Connecting multiple iSeries systems through DDM

    Working with databases over multiple iSeries systems can be simple when remotely connecting logical partitions with distributed ...

SearchDataCenter

SearchExchange

SearchContentManagement

Close