Jayanth Othayoth | 9e95f4b | 2017-07-24 06:42:24 -0500 | [diff] [blame] | 1 | #! /bin/bash |
| 2 | |
| 3 | help=$" |
| 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 | |
| 11 | usage: dreport [OPTION] |
| 12 | |
| 13 | Options: |
| 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 Othayoth | 7b77487 | 2017-07-26 05:02:53 -0500 | [diff] [blame^] | 37 | #CONSTANTS |
| 38 | declare -r TRUE=1 |
| 39 | declare -r FALSE=0 |
| 40 | declare -r USERINITIATED_TYPE=0 |
| 41 | declare -r APPLICATIONCORED_TYPE=1 |
| 42 | declare -r DUMP_MAX_SIZE=500 #in KB |
| 43 | |
| 44 | #VARIABLES |
| 45 | declare -x name=$"obmcdump_00000000_$(date +"%s")" |
| 46 | declare -x dump_dir=$TMP_DIR |
| 47 | declare -x dump_id=1 |
| 48 | declare -x dump_type=$USERINITIATED_TYPE |
| 49 | declare -x verbose=$FALSE |
| 50 | declare -x quiet=$FALSE |
| 51 | declare -x dump_size=$DUMP_MAX_SIZE |
| 52 | |
| 53 | # PACKAGE VERSION |
| 54 | PACKAGE_VERSION="0.0.1" |
| 55 | |
| 56 | # @brief Main function |
| 57 | function main() |
| 58 | { |
| 59 | echo "Initial Version of dreport tool" |
| 60 | } |
| 61 | |
| 62 | TEMP=`getopt -o n:d:i:t:s:f:vVqh \ |
| 63 | --long name:,dir:,dumpid:,type:,size:,file:,verbose,version,quiet,help \ |
| 64 | -- "$@"` |
| 65 | eval set -- "$TEMP" |
| 66 | |
| 67 | while [[ $# -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 Othayoth | 9e95f4b | 2017-07-24 06:42:24 -0500 | [diff] [blame] | 104 | done |
Jayanth Othayoth | 7b77487 | 2017-07-26 05:02:53 -0500 | [diff] [blame^] | 105 | |
| 106 | main #main program |
| 107 | exit $? |