Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
L
Log MatomNom
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
3
Issues
3
List
Boards
Labels
Service Desk
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Operations
Operations
Incidents
Environments
Packages & Registries
Packages & Registries
Package Registry
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Libre
Log MatomNom
Commits
b8ac2c80
Commit
b8ac2c80
authored
Nov 14, 2020
by
Michał Woźniak
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
WIP: ready for a live parse test
parent
2db56249
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
53 additions
and
19 deletions
+53
-19
logwatch.py
logwatch.py
+53
-19
No files found.
logwatch.py
View file @
b8ac2c80
...
...
@@ -98,8 +98,19 @@ class Configuration(import_logs.Configuration):
self
.
_sanitize_ingested_output_path
(
os
.
path
.
join
(
p
,
self
.
options
.
prefix_ingested
))
# set up configuration, parse command line args, etc
config
=
Configuration
()
# this depends on the Configuration()
matomo
=
Matomo
()
# this depends on Matomo()
config
.
init_token_auth
()
# the rest of init
resolver
=
config
.
get_resolver
()
parser
=
Parser
()
# files to process
logfiles_busy
=
[]
# this is where newly discovered logfiles are added
logfiles_free
=
[]
# logfiles which we can assume are not busy
...
...
@@ -169,25 +180,48 @@ while True:
inotify
.
rm_watch
(
wd
[
0
])
watches
=
{}
print
(
" +-- simulating log processing of free logfiles..."
)
for
f
in
logfiles_free
:
print
(
" - %s"
%
f
)
# processing the logfile (simulation right now)
time
.
sleep
(
config
.
options
.
ingestion_grace_period
/
200
)
# once the file is processed, we need to move it to the location specified by
# applying the prefix_ingested and suffix_ingested, as configured
f_dir
,
f_base
=
os
.
path
.
split
(
f
)
f_base
+=
config
.
options
.
suffix_ingested
if
os
.
path
.
isabs
(
config
.
options
.
prefix_ingested
):
new_f
=
config
.
options
.
prefix_ingested
+
f_base
else
:
new_f
=
os
.
path
.
join
(
f_dir
,
config
.
options
.
prefix_ingested
+
f_base
)
print
(
" -> %s"
%
new_f
)
shutil
.
move
(
f
,
new_f
)
logfiles_free
=
[]
# we want stats
stats
=
Statistics
()
stats
.
set_time_start
()
if
config
.
options
.
show_progress
:
stats
.
start_monitor
()
# launch recorders
recorders
=
Recorder
.
launch
(
config
.
options
.
recorders
)
print
(
" +-- ingesting logfiles..."
)
try
:
for
f
in
logfiles_free
:
print
(
" - %s"
%
f
)
# processing the logfile
parser
.
parse
(
f
)
Recorder
.
wait_empty
()
# once the file is processed, we need to move it to the location specified by
# applying the prefix_ingested and suffix_ingested, as configured
f_dir
,
f_base
=
os
.
path
.
split
(
f
)
f_base
+=
config
.
options
.
suffix_ingested
if
os
.
path
.
isabs
(
config
.
options
.
prefix_ingested
):
new_f
=
config
.
options
.
prefix_ingested
+
f_base
else
:
new_f
=
os
.
path
.
join
(
f_dir
,
config
.
options
.
prefix_ingested
+
f_base
)
print
(
" done, moving to: %s"
%
new_f
)
shutil
.
move
(
f
,
new_f
)
logfiles_free
=
[]
except
KeyboardInterrupt
:
pass
setup_watches
()
# done with stats
stats
.
set_time_stop
()
if
config
.
options
.
show_progress
:
stats
.
stop_monitor
()
stats
.
print_summary
()
del
stats
time
.
sleep
(
config
.
options
.
ingestion_grace_period
/
1000
)
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment