-
Notifications
You must be signed in to change notification settings - Fork 0
/
readloga.py
executable file
·33 lines (31 loc) · 1.07 KB
/
readloga.py
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
#!/usr/bin/python3
import os
from datetime import datetime
apath = os.path.expanduser("~/a.log")
print("chemin etendu en", apath)
with open(apath) as fd:
for line in fd:
# print(line)
# print(line.split())
# print(line.split(None, 11))
ip, login, passws, date, zone, reqtype, \
url, httptype, status, size, referer, \
uagenttrash = line.split(None, 11)
print(ip)
# print(date[1:])
datetime_object = datetime.strptime(date[1:],
'%d/%b/%Y:%H:%M:%S')
print(datetime_object)
# print(uagenttrash)
# print(uagenttrash.split('"'))
uagent = uagenttrash.split('"')[1]
timing = uagenttrash.split('"')[2]
print(uagent)
# print(timing.split())
reqtime= timing.split()[0]
print(reqtime)
break
# 63.143.42.252 - - [29/Oct/2019:06:25:25 +0100] "HEAD /login HTTP/1.1" 200
# 0 "https://riskstarter.arengibox.com/login"
# "Mozilla/5.0+(compatible; UptimeRobot/2.0; http://www.uptimerobot.com/)"
# 0.422 0.424 .