-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathlogwatcher.init-sample
More file actions
executable file
·136 lines (120 loc) · 3.82 KB
/
logwatcher.init-sample
File metadata and controls
executable file
·136 lines (120 loc) · 3.82 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
#!/bin/sh
#
# Copyright 2015 CityGrid Media, LLC
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#
#
# init script for logwatcher.py
# Looks in the defined config_dir and starts an intstance for any files
# matching the name logwatcher_*.ini
#
# chkconfig: 3 99 00
# description: logwatcher.py - report on access logs on the fly
# Configure these in /etc/sysconfig/logwatcher to override.
daemon_args=""
pkg_dir="/usr/local/lib/python2.7/site-packages/logwatcher"
py_bin="/usr/local/bin/python2.7"
config_dir="/app/logwatcher/conf"
lw_user=root
if [ -f /etc/sysconfig/logwatcher ] ; then
. /etc/sysconfig/logwatcher
fi
lw="${py_bin} ${pkg_dir}/run.py ${daemon_args}"
echo "Starting : ${lw}"
# GMOND Style
# lw="python2.7 ${pkg_dir}/run.py"
# Basic graphite
# lw="python2.7 ${pkg_dir}/run.py -g graphite"
#lw="/usr/local/bin/python2.7 ${pkg_dir}/run.py -g graphite -P 3003 -R 'LW.' -m trp"
# initialize other variables
class=`hostname | sed 's/^.......\([a-z]*\)[0-9]*$/\1/'`
errors=0
if [ -d $config_dir ]; then
config_files=`ls $config_dir/logwatcher_*.ini`
else
echo 'Logwatcher Configuration directory ($config_dir) does not exist.'
exit 1;
fi
if [ ! "$config_files" ]; then
echo 'There do not appear to be any valid Logwatcher Configuration Files deployed.'
exit 1;
fi
# start, restart, status, stop
case $1 in
start)
for cf in $config_files; do
pid=`ps auxww | egrep py[t]hon.*$cf | awk '{ print $2 }'`
if [ "x$pid" != "x" ]; then
echo 'logwatcher is running!'
exit 1
fi
done
for cf in $config_files; do
echo "$lw -d -c $cf"
su -c "$lw -d -c $cf" $lw_user
done
;;
restart)
$0 stop
$0 start
;;
# FIXME: Will need to do a better of status when checking multiple logwatcher configuration files
status)
for cf in $config_files; do
pid=`ps auxww | egrep py[t]hon.*logwatcher.*.ini | awk '{ print $2 }'`
if [ "x$pid" != "x" ]; then
echo 'logwatcher is running!'
exit 0;
fi
done
echo 'logwatcher is not running!'
exit 1;
;;
stop)
pids=`ps auxww | egrep py[t]hon.*logwatcher.*.ini | awk '{ print $2 }'`
for p in $pids; do
if [ "x$p" != "x" ]; then
echo stopping $p
su -c "kill $p" $lw_user
echo stopped $p
if [ $? = 0 ]; then
echo looking for pid file
for cf in $config_files; do
pidfile=`egrep "^pidfile: " $cf | awk '{ print $2 }'`
if [ -f "$pidfile" ]; then
echo found pid file
su -c "rm $pidfile" $lw_user
if [ $? != 0 ]; then
echo "ERROR: $0: couldn't remove $pidfile"
errors=`expr $errors + 1`
fi
fi
done
fi
fi
done
;;
*)
echo "Usage: $0 (start|stop|restart|status)"
;;
esac
exit $errors
# CONFIGS:
#
#Chostname ini_name [ini_name ...]
#
#Cesh esh_events esh_roundup
#Cssa ss_data ss_query
#Cssb ss_data ss_query
#Cssc ss_data ss_query