Page Menu
Home
Phabricator
Search
Configure Global Search
Log In
Files
F34649566
parse_fsck.py
Public
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Award Token
Flag For Later
Authored By
dcaro
Sep 21 2021, 9:21 AM
2021-09-21 09:21:17 (UTC+0)
Size
1 KB
Referenced Files
None
Subscribers
None
parse_fsck.py
View Options
#!/usr/bin/env python3
from
pprint
import
pprint
import
click
from
datetime
import
date
,
datetime
@click.command
()
@click.argument
(
'infile'
,
type
=
click
.
File
(
'r'
))
def
main
(
infile
):
minute_to_hosts
=
{}
host
=
None
for
line
in
infile
:
if
line
.
startswith
(
'('
):
host
=
line
.
split
(
")"
,
1
)[
-
1
]
.
strip
()
continue
elif
line
.
startswith
(
'['
)
and
host
is
not
None
:
datestamp_str
=
line
.
split
(
']'
,
1
)[
0
][
1
:]
datestamp
=
datetime
.
strptime
(
datestamp_str
,
"
%c
"
)
minute_bucket
=
datetime
(
year
=
datestamp
.
year
,
month
=
datestamp
.
month
,
day
=
datestamp
.
day
,
hour
=
datestamp
.
hour
,
minute
=
datestamp
.
minute
,
)
if
minute_bucket
in
minute_to_hosts
:
minute_to_hosts
[
minute_bucket
]
.
append
(
host
)
else
:
minute_to_hosts
[
minute_bucket
]
=
[
host
]
for
minute
,
hosts
in
sorted
(
minute_to_hosts
.
items
()):
print
(
"{minute} - count: {len_hosts}
\n
hosts:"
.
format
(
minute
=
minute
,
len_hosts
=
len
(
hosts
)))
print
(
" "
+
"
\n
"
.
join
(
hosts
))
if
__name__
==
"__main__"
:
main
()
File Metadata
Details
Attached
Mime Type
text/x-python
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
9185900
Default Alt Text
parse_fsck.py (1 KB)
Attached To
Mode
T290970: File System corruption on cloud-vps instances
Attached
Detach File
Event Timeline
Log In to Comment