September 26, 2011

Recreate NNM Database

Before you start it is recommended that you have a complete backup so that
should there be any problems you can return to the status quo ante.

The steps are the following:
(1)Delete unnecessary data from the database.
(2)Unload the data from the database into a flat file.
(3)Edit the solid.ini file in order to limit the size to which the database
will grow.
(4)Delete the database.
(5)Recreate the database.
(6)Reload the data into it.


1) To delete unnecessary data from the database use the command

#ovdwevent -trim.

You can test to see what data you are about to delete using

#ovdwevent -trimnodelete

before you do it for real. For a full explanation of the options see the
ovdwevent (1) man page. However deleting data will not reduce the size of the
database file, it will simply free up space inside it. (Once you have got your
database under control you might consider setting up a cron job to delete
superfluous data on a regular basis, and thus prevent any problems caused by
the database filling up.)

2) Now unload the data from the database into a flat file with ovdwunloader.
Check the man page for a full explanation of the options. You will need to
export both the trend and event data, so you will need to run the command twice:

#ovdwunloader -file trend_output_file -trend -v
#ovdwunloader -file event_output_file -event -v

Stop OpenView
#ovstop -v

3) The default size of the database is a single two gigabytes file. You can
control the size by editing $OV_DB/analysis/default/solid.ini and setting the
FileSpec parameter in the Index File section. The FileSpec parameter describes
the location and the maximum size of the database file and accepts the
following three arguments:
database file name
max filesize
device number (optional)
You can also use the FileSpec parameter to divide the index file into multiple
files and onto multiple disks. To do this, specify another FileSpec parameter
identified by the number 2. The index file will be written to the second file
if it grows over the maximum value of the first FileSpec parameter. For example
the default value for this parameter is solid.db, 2147483647 (which equals 2 GB
expressed in bytes).
FileSpec_1=SOLID.DB 2147483647
In the following example, the parameters divide the index file on the disks C:,
D: and E: to be split after growing larger than 1 GB (=1073741824 bytes).
FileSpec_1=c:\soldb\solid.1 1073741824 1
FileSpec_2=D:\soldb\solid.2 1073741824 2
FileSpec_3=G:\soldb\solid.3 1073741824 3
NOTE. The index file locations entered must be valid path names in the server’s
operating system. For example, if the server runs on a UNIX operating system,
path separators must be slashes instead of backslashes. Although the database
files reside in different directories, the file names must be unique. In the
above example, it is assumed that C:, D: and E: partitions reside on separate
physical disks. Splitting the index file on multiple disks will increase the
performance of the server because multiple disk heads will access the data in
your index file. There is no limit to the number of index files you may use.

4) Now delete the database:

#cd $OV_DB/analysis/default

#rm solid.db
#rm solmsg.*
#rm ./log/sol*.log

5) Now recreate an empty database

#cd $OV_DB/analysis/default
#ovdbrun -x exit -u ovdb -p ovdb

#cd $OV_CONF/analysis/sqlScripts
#ovdbcheck -start
#ovdwquery -file tables_common.solid
#ovdwquery -file tables_event.solid
#ovdwquery -file tables_trend.solid
#ovdwquery -file tables_topo.solid

#ovdbcheck -stop
#ovstart -v

6) Now that OpenView is running again we need to reload the data from the flat
files into the database.
#ovdwloader -file trend_output_file -v
#ovdwloader -file event_output_file -v

July 19, 2011

Check free memory on unix server

Commands to check free memory on unix servers -

(1) vmstat 1 2 | tail -1 | awk '{printf "%d%s\n", ($5*4)/1024, "MB" }'

(2) top -h -d 1

June 19, 2011

Script to monitor files (with a file name prefix) are updating in a directory

#!/bin/sh
OPCMON="/opt/OV/bin/opcmon"
MON_NAME=$1

line1=`eval date +'%Y%m%d/MSC'`

##### Count_M10C1.txt file keeps the count of total number of files in the input directory #########

FILE_M10C1="/tmp/count_M10C1.txt"
if [ ! -f $FILE_M10C1 ]; then
echo "File Does Not Exist"
`ls $line1 | grep M10C1 | wc -l >> /tmp/count_M10C1.txt`
exit 1
fi

var=`cat $FILE_M10C1`
for i in $var;
do
line=$i
done


##### Filecount is the variable which stores the current number of files in input directory ##########

Filecount=`ls "$line1" | grep M10C1* | wc -l`

##### Comparison is being done whether the current number of files in input directory is equal to the previous count #######

if [ $Filecount = $line ];
then
echo "Count Equal"
/opt/OV/bin/opcmon "${MON_NAME}=1"
else
echo "Count Unequal"
/opt/OV/bin/opcmon "${MON_NAME}=0"
fi


###### Store the current number of files in input directory to temporary file count_M10C1.txt ########
`ls $line1 | grep M10C1* | wc -l > /tmp/count_M10C1.txt`