Oracle stats (Part 2)

This time we will monitor tablespace stats. I’d like to create one stats table per tablespace and use the same technique as in Part 1

Read the rest of this entry »

Oracle stats (Part 1)

Our customer runs Oracle database and my chief has given me a task to do for today.

I need to prepare prognosis of how much oracle database will grow in next 3 years. After short googling I’ve found interesting sripts [1]:

 select sum(bytes)/1024/1024 "Meg" from dba_data_files;
 select nvl(sum(bytes),0)/1024/1024 "Meg" from dba_temp_files;
 select sum(bytes)/1024/1024 "Meg" from sys.v_$log;
 select sum(BLOCK_SIZE*FILE_SIZE_BLKS/1024/1024) "MEG" from v$controlfile;

The main idea is to create oracle DBMS job which will fire each hour for let’s say 7 days (yeah, we’ve got only 7 days :() and outputs statistics about database size into some database table.

Read the rest of this entry »

Syslog itself (Part I)

Now SyslogMessageMapper is completed so lets move on and take a look on Syslog itself.

Read the rest of this entry »

SyslogMessage unit testing

Before we continue on unit testing SyslogMessageMapper we need to perform basic testing of syslog Message itself. [done]

Read the rest of this entry »

Query Object Part I

Let’s try to apply Query Object pattern to Syslog in order to allow client to retrieve syslog messages from database in natural, flexible way.

Read the rest of this entry »


Now when SyslogSessionMapper has been implemented, it time to finish SyslogMessageMapper. But before let’s remind us syslog use-case .

One thing that we will have to implement is retrieving syslog messages using different conditions. Here is preliminary list of conditions:

  1. Get messages by category name(s)
  2. Get messages by type name(s)
  3. Get messages by sender name(s)
  4. Get messages by session(s)
  5. Get messages by time interval(s)

The list can be continued…

This is the best place to use Query Object pattern. For futher reading please refer to:

I’d like to take some time about base classes implementation, since we will use query object pattern in groupchat logger plugin. This plugin will store log of xmpp groupchat (conference) and we need to provide flexible OO mechanism for retrieving chat messages from log. So it would be nice to implement base classes for SyslogMessageMapper and reuse them later :)

SyslogSessionMapper finished

I’ve implemented SyslogSessionMapper and associated unit tests. So far tests are passed and thats sweet. Not let’s time to continue

Read the rest of this entry »

More plans

I’ve created several helper methods for Database class:

  • truncateTable()
  • countRecords()

I’ve also created base class DatabaseBaseTest which uses those methods heavily.

As for unit testing, I’ve impelented SyslogSessionMapper tests for several methods, but refactoring base classes have taken too much time.

save() method internally uses insertSession() and updateSession() (for non-persistent / persistent sessions accodingly ). First method is tested, second my is my future plan. I also need to unit test save() method.

As for delete() method — there will be some difficulties. Before I delete session object I have to delete all related syslog messages (by session_id foreign key in “syslog” db table). Currently SyslogMessageMapper isn’t implemented, so I need manually insert records into syslog messages table for unit testing delete() method

Additionally we do need getLatestSession() method which will retrieved latest session object from database. SQL will looks like:

  select id,max(start_date),end_date from syslog_sessions

Testing RAS

SyslogSessionMapper unit testing