blob: 4d3bf8a4bd3cbb23071889ec92c4e017af5794c3 (
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
|
# cobbler daemon for logging remote syslog traffic during kickstart
#
# 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 socket
import time
import api as cobbler_api
def main():
bootapi = cobbler_api.BootAPI()
settings = bootapi.settings()
port = settings.syslog_port
s = socket.socket(socket.AF_INET, socket.SOCK_DGRAM)
s.bind((socket.gethostname(), port))
buf = 1024
while 1:
data, addr = s.recvfrom(buf)
(ip, port) = addr
if not data:
break
else:
logfile = open("/var/log/cobbler/syslog/%s" % ip, "a+")
t = time.localtime()
# write numeric time
seconds = str(time.mktime(t))
logfile.write(seconds)
logfile.write("\t")
# write string time
timestr = str(time.asctime(t))
logfile.write(timestr)
logfile.write("\t")
# write the IP address of the client
logfile.write(ip)
logfile.write("\t")
# write the data
logfile.write(data)
logfile.write("\n")
logfile.close()
|