blob: 2cd60d52b325bca1f3c0535196031d036d19923e [file] [log] [blame]
Jayanth Othayoth9e95f4b2017-07-24 06:42:24 -05001#! /bin/bash
2
3help=$"
4 dreport creates an archive(xz compressed) consisting of the following:
5 * Configuration information
6 * Debug information
7 * A summary report
8 The type parameter controls the content of the data. The generated
9 archive is stored in the user specified location.
10
11usage: dreport [OPTION]
12
13Options:
14 -n, —-name <name> Name to be used for the archive.
15 Default name format obmcdump_<id>_<epochtime>
16 -d, —-dir <directory> Archive directory to copy the compressed report.
17 Default output directory is /tmp/dreport
18 -i, —-id <id> Dump identifier to associate with the archive.
19 Identifiers include numeric characters.
20 Default dump identifier is 0
21 -t, —-type <type> Data collection type. Valid types are
22 "user", "core".
23 Default type is "user" initiated.
24 -f, —-file <file> Optional file to be included in the archive.
25 Absolute path of the file must be passed as
26 parameter. This is useful to include application
27 core in the dump.
28 -s, --size <size> Maximum allowed size(in KB) of the archive.
29 Report will be truncated in case size exceeds
30 this limit. Default size is 500KB.
31 -v, —-verbose Increase logging verbosity.
32 -V, --version Output version information.
33 -q, —-quiet Only log fatal errors to stderr
34 -h, —-help Display this help and exit.
35"
36
Jayanth Othayoth7b774872017-07-26 05:02:53 -050037#CONSTANTS
38declare -r TRUE=1
39declare -r FALSE=0
40declare -r USERINITIATED_TYPE=0
41declare -r APPLICATIONCORED_TYPE=1
42declare -r DUMP_MAX_SIZE=500 #in KB
43
44#VARIABLES
45declare -x name=$"obmcdump_00000000_$(date +"%s")"
46declare -x dump_dir=$TMP_DIR
47declare -x dump_id=1
48declare -x dump_type=$USERINITIATED_TYPE
49declare -x verbose=$FALSE
50declare -x quiet=$FALSE
51declare -x dump_size=$DUMP_MAX_SIZE
52
53# PACKAGE VERSION
54PACKAGE_VERSION="0.0.1"
55
56# @brief Main function
57function main()
58{
59 echo "Initial Version of dreport tool"
60}
61
62TEMP=`getopt -o n:d:i:t:s:f:vVqh \
63 --long name:,dir:,dumpid:,type:,size:,file:,verbose,version,quiet,help \
64 -- "$@"`
65eval set -- "$TEMP"
66
67while [[ $# -gt 1 ]]; do
68 key="$1"
69 case $key in
70 -n|--name)
71 name=$2
72 shift 2;;
73 -d|--dir)
74 dir=$2
75 shift 2;;
76 -i|--dumpid)
77 dump_id=$2
78 shift 2;;
79 -t|--type)
80 dump_type=$2
81 shift 2;;
82 -s|--size)
83 dump_size=$2
84 shift 2;;
85 -f|--file)
86 dump_file=$2
87 shift 2;;
88 -v|—-verbose)
89 verbose=$TRUE
90 shift;;
91 -V|--version)
92 shift;;
93 -q|—-quiet)
94 quiet=$TRUE
95 shift;;
96 -h|--help)
97 echo "$help"
98 exit;;
99 *) # unknown option
100 echo "Unknown argument: $1"
101 echo "$help"
102 exit 1;;
103 esac
Jayanth Othayoth9e95f4b2017-07-24 06:42:24 -0500104done
Jayanth Othayoth7b774872017-07-26 05:02:53 -0500105
106main #main program
107exit $?