blob: dfa8dc3fe0491a37ba6fb79e654161b34faba03a (
plain)
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
|
# cobbler mod_python handler for observing kickstart activity
#
# Copyright 2007, Red Hat, Inc
# Michael DeHaan <mdehaan@redhat.com>
#
# This software may be freely redistributed under the terms of the GNU
# general public license.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
import time
from mod_python import apache
def outputfilter(filter):
# extract important info
request = filter.req
connection = request.connection
(address,port) = connection.remote_addr
# open the logfile (directory be set writeable by installer)
logfile = open("/var/log/cobbler/kicklog/%s" % address,"a+")
log_it = True
if request.the_request.find("cobbler_track") == -1 and request.the_request.find("cblr/") == -1:
log_it = False
if log_it:
# write the timestamp
t = time.localtime()
seconds = str(time.mktime(t))
logfile.write(seconds)
logfile.write("\t")
timestr = str(time.asctime(t))
logfile.write(timestr)
logfile.write("\t")
# write the IP address of the client
logfile.write(address)
logfile.write("\t")
# write the filename being requested
logfile.write(request.the_request)
# logfile.write(request.filename)
logfile.write("\n")
# if requesting this file, don't return it
if request.the_request.find("watcher.py") != -1:
filter.close()
return
# pass-through filter
s = filter.read()
while s:
filter.write(s)
s = filter.read()
if s is None:
filter.close()
logfile.close()
|