[BlueOnyx:19313] CODB Index Checker - Useful Tool

Greg Kuhnert gkuhnert at compassnetworks.com.au
Sun Mar 13 01:15:51 -05 2016


Hi team.

Below is a useful tool that I have been working on for a bit. This is a universal CODB database index checker tool. The code is not pretty, but it is effective. There are two basic parts to the script. The first bit checks the class indexes. After the recent memcache issues, there were a number of systems that had corrupt class indexes. This part of the script will test and validate your class indexes, and report any problems. The last part of the script is a modified version of an older script with a few tweaks to check the codb.oids list of used OID numbers. 

Paste all of the content below into a file called indexcheck.sh on your server. The script should be owned by root and have execute permissions. For each of the checks it performs, you will have a simple pass or fail result. When you first execute the script, it will be a little slow on the first line of output - after that, it will fly along.

Enjoy.

Greg Kuhnert

============

#!/bin/bash


#
# First check the class indexes
#

CCE=/usr/sausalito/bin/cceclient
for CLASS in `echo classes | $CCE  | grep ^110 | cut -d " " -f 3-`
do
        echo -n Checking $CLASS
        echo find $CLASS | $CCE | grep ^104 | cut -d " " -f 3- | sort -n > /tmp/$CLASS.index
        grep "^$CLASS$" /usr/sausalito/codb/objects/*/.CLASS | cut -d "/" -f 6 | sort -n > /tmp/$CLASS.oid
        diff /tmp/$CLASS.index /tmp/$CLASS.oid > /tmp/$CLASS.diff
        if [ $? -eq 0 ]; then
                rm /tmp/$CLASS.index /tmp/$CLASS.oid /tmp/$CLASS.diff
                echo " - Pass"
        else
                echo " - ***Fail***"
        fi
done

#
# Now check the codb.oids index
#

LAST=-1
MIN=-1
MYOID=/tmp/myoid
rm $MYOID
for X in `ls /usr/sausalito/codb/objects/ | sort -n`
do
        MYNEXT=$(( $LAST + 1 ))
        if [ $MYNEXT -eq $X ]
        then
                LAST=$X
        else
                if [ $LAST -ge 1 ]
                then
                        if [ $MIN -eq $LAST ]
                        then
                                echo -n $LAST, >> $MYOID
                        else
                                echo -n $MIN-$LAST, >> $MYOID
                        fi
                fi
                LAST=$X
                MIN=$X
        fi
done
if [ $MYNEXT -lt $X ]
then
        echo -n $LAST >> $MYOID
else
        echo -n $MIN-$LAST >> $MYOID
fi

diff -q $MYOID /usr/sausalito/codb/codb.oids

echo -n Checking codb.oids
if [ $? -eq 0 ]; then
  echo " - Pass"
else
  echo " - ***Fail***"
fi

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.blueonyx.it/pipermail/blueonyx/attachments/20160313/2adfffd2/attachment.html>


More information about the Blueonyx mailing list