-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathkadc
executable file
·67 lines (61 loc) · 984 Bytes
/
kadc
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
#!/bin/sh
#
# SPDX-License-Identifier: CDDL-1.0
#
# kar - kstat activity reporter
#
# This is the kar data collector wrapper, kadc
#
usage() {
echo "Usage: $0 [dir [file] ]"
exit 2
}
#
# define output locations, either from defaults or supplied arguments
#
KDATE=$(/bin/date +'%F')
case $# in
0)
ODIR="/var/adm/ka"
OFILE="ka-${KDATE}"
;;
1)
ODIR="$1"
OFILE="ka-${KDATE}"
;;
2)
ODIR="$1"
OFILE="$2"
;;
*)
usage
;;
esac
#
# check destination directory is valid
#
if [ ! -d "$ODIR" ]; then
/bin/mkdir -p "$ODIR"
fi
if [ ! -d "$ODIR" ]; then
echo "ERROR: missing output directory $ODIR"
usage
fi
#
# check destination file, it should be a bare name without slashes
#
case $OFILE in
*/*)
echo "ERROR: output file must be a plain filename"
usage
;;
esac
DSTFILE="${ODIR}/${OFILE}"
TDIR="/tmp/kar-$$"
/bin/mkdir -p "$TDIR"
cd "$TDIR" || exit 1
TFILE=$(/bin/date '+%F-%T')
/usr/lib/ka/kar_collector > "$TFILE"
/bin/zip -q "$DSTFILE" "$TFILE"
cd /
/bin/rm -fr "$TDIR"