-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcattail
More file actions
executable file
·141 lines (109 loc) · 3.05 KB
/
cattail
File metadata and controls
executable file
·141 lines (109 loc) · 3.05 KB
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
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
#!/bin/bash
#
# $Id: cattail 1294 2009-09-27 04:14:08Z mheiges $
# $URL: https://mango.ctegd.uga.edu/svn/ApiCommonSystem/trunk/WDK/bin/cattail $
#
########################################################################
set_loglist(){
if [[ -z $do_apache && -z $do_tomcat && -z $do_catalina ]]; then
do_apache=1
do_tomcat=1
fi
local apache_list
local tomcat_list
local catalina_list
[ $do_apache ] && apache_list=(
"/var/log/httpd/$HOST/access_log"
"/var/log/httpd/$HOST/error_log"
)
[ $do_tomcat ] && tomcat_list=(
"/usr/local/tomcat_instances/$PRODUCT/logs/$WEBAPP/"
)
[ $do_catalina ] && catalina_list=(
"/usr/local/tomcat_instances/$PRODUCT/logs/catalina.out"
)
LOG_LIST=( ${apache_list[@]} ${tomcat_list[@]} ${catalina_list[@]} )
}
########################################################################
usage() {
this="$(basename "$0")"
cat <<EOF
Place a tail on standard log files used by a WDK-based website that has been
installed using ApiDB file naming and location conventions.
Usage:
$this [options] <hostname> [tomcat instance]
options are
-a tail the Apache webserver access and error logs
-t tail the Tomcat webapp log directory (may be more than one log)
-c tail catalina.out
-a and -t are the defaults if no options are given.
The default tomcat instance is the name match for the product directory in
which the webapp is installed. If your webapp is deployed in a different
instance you may specify it.
Examples:
$this dev.toxodb.org
$this dev.toxodb.org Test
$this -a dev.toxodb.org
EOF
exit 1
}
########################################################################
wstatus() {
local instance=$1
local webapp=$2
instance_manager manage $instance list | egrep "^/$webapp:" | awk -F: "{print \$2}"
}
########################################################################
# MAIN
########################################################################
test -z $1 && usage;
while getopts 'atc' OPTION
do
# sync changes wth tab completion function in apidb-tab-completion.sh
case $OPTION in
a) do_apache=1
;;
t) do_tomcat=1
;;
c) do_catalina=1
;;
esac
done
shift $(($OPTIND - 1))
TAIL=/usr/local/bin/xtail
TAIL_CMD="$TAIL --ansi"
test -x "$TAIL" || { echo "$TAIL" not found.; exit 1; }
HOST=$1
SITE_SYMLINK="/var/www/$HOST"
if [ ! -d $SITE_SYMLINK ]; then
echo
echo "Directory for '$HOST' not found. I was looking for"
echo "'$SITE_SYMLINK'"
echo "Better luck next time."
echo
exit 1
fi
WEBAPP="$(basename "$(readlink -n "$SITE_SYMLINK")")"
PRODUCT="$2"
if [ -z $PRODUCT ]; then
CONTAINER="$(dirname $(readlink -n $SITE_SYMLINK))"
PRODUCT=${CONTAINER##*/}
fi
set_loglist
for log in ${LOG_LIST[@]}; do
if [ -e $log ]; then
logs="$logs $log"
else
logs_not_found="$logs_not_found $log"
fi
done
echo
[ ! -z "${logs_not_found[@]}" ] && {
echo "Not found"
for l in $logs_not_found; do echo " $l"; done;
echo
}
echo "Tailing"
for l in $logs; do echo " $l"; done;
echo
$TAIL_CMD $logs