Add cql jar to graphadmin
[aai/graphadmin.git] / src / main / scripts / migration_verification.sh
1 #!/bin/ksh
2
3 ###
4 # ============LICENSE_START=======================================================
5 # org.onap.aai
6 # ================================================================================
7 # Copyright (C) 2018 AT&T Intellectual Property. All rights reserved.
8 # ================================================================================
9 # Licensed under the Apache License, Version 2.0 (the "License");
10 # you may not use this file except in compliance with the License.
11 # You may obtain a copy of the License at
12
13 #      http://www.apache.org/licenses/LICENSE-2.0
14
15 # Unless required by applicable law or agreed to in writing, software
16 # distributed under the License is distributed on an "AS IS" BASIS,
17 # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
18 # See the License for the specific language governing permissions and
19 # limitations under the License.
20 # ============LICENSE_END=========================================================
21 ###
22
23 #
24 # migration_verification.sh  -- This tool is used to provide a summary of migration logs
25 # This searches for pre-defined strings "Migration Error" and "Migration Summary Count" in log files and outputs those lines.
26 #
27
28 display_usage() {
29   cat << EOF
30   Usage: $0 [options]
31   
32   1. Usage: migration_verification.sh <last_modified> <logs_path>
33   2. The <logs_path> should be a directory containing all of the logs. If empty, default path is /opt/app/aai-graphadmin/logs/migration.
34   3. The <last_modified> parameter should be an integer for up to how many minutes ago a log file should be parsed.
35   4. Example: migration_verification.sh 60 /opt/app/aai-graphadmin/logs/migration
36 EOF
37 }
38
39 if [ $# -eq 0 ]; then
40   display_usage
41   exit 1
42 fi
43
44 LOGS_DIRECTORY=${2:-/opt/app/aai-graphadmin/logs/migration/}
45 MTIME=$1
46
47 echo
48 echo 'Running migration summary:'
49 print "Logs directory: $LOGS_DIRECTORY"
50 print "Searching log files modified within last $MTIME minutes: \n"
51 echo
52
53 for i in $(find -L $LOGS_DIRECTORY -mtime -$MTIME -name '*.log' );
54 do
55   echo "Checking Log File: $i"
56   grep "Migration Error:" $i
57   grep "Migration Summary Count:" $i
58   echo
59 done
60
61 echo 'Done'