Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
E
ece459-w23-a2
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package Registry
Container Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Patrick Lam
ece459-w23-a2
Commits
e807a4b7
Commit
e807a4b7
authored
2 years ago
by
Patrick Lam
Browse files
Options
Downloads
Patches
Plain Diff
frontend support for openstack logs
parent
eb137d52
No related branches found
Branches containing commit
No related tags found
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
src/main.rs
+16
-5
16 additions, 5 deletions
src/main.rs
src/packages/parser.rs
+1
-1
1 addition, 1 deletion
src/packages/parser.rs
with
17 additions
and
6 deletions
src/main.rs
+
16
−
5
View file @
e807a4b7
...
...
@@ -7,8 +7,11 @@ mod packages;
#[command(author,
version,
about,
long_about
=
None)]
struct
Args
{
/// Name of the raw logfile to convert to a CSV
#[arg(short,
long)]
raw
:
String
,
#[arg(long)]
raw_linux
:
Option
<
String
>
,
#[arg(long)]
raw_openstack
:
Option
<
String
>
,
}
#[test]
...
...
@@ -28,15 +31,23 @@ fn derive_2grams(trigram:&str) -> Vec<String> {
fn
main
()
{
let
args
=
Args
::
parse
();
let
(
double_dict
,
triple_dict
,
all_token_list
)
=
packages
::
parser
::
parse_raw_linux
(
args
.raw
);
packages
::
parser
::
print_dict
(
&
triple_dict
);
let
(
mut
double_dict
,
mut
triple_dict
,
mut
all_token_list
)
:
(
Option
<
HashMap
<
String
,
i32
>>
,
Option
<
HashMap
<
String
,
i32
>>
,
Option
<
String
>
)
=
(
None
,
None
,
None
);
if
let
Some
(
raw_linux
)
=
args
.raw_linux
{
let
(
dd
,
td
,
atl
)
=
packages
::
parser
::
parse_raw_linux
(
raw_linux
);
packages
::
parser
::
print_dict
(
&
td
);
triple_dict
=
Some
(
td
);
}
else
if
let
Some
(
raw_openstack
)
=
args
.raw_openstack
{
let
(
dd
,
td
,
atl
)
=
packages
::
parser
::
parse_raw_openstack
(
raw_openstack
);
packages
::
parser
::
print_dict
(
&
td
);
triple_dict
=
Some
(
td
);
}
const
CUTOFF
:
i32
=
72
;
// let's say that the cutoff is 72 for Linux2k.log.
// check all of the 2-grams from the less-frequent 3-grams
let
mut
two_grams
=
HashMap
::
new
();
let
(
val_set
,
reverse_d
)
=
packages
::
parser
::
reverse_dict
(
&
triple_dict
);
let
(
val_set
,
reverse_d
)
=
packages
::
parser
::
reverse_dict
(
&
triple_dict
.unwrap
()
);
for
val
in
val_set
.iter
()
.filter
(|
x
|
**
x
<
CUTOFF
)
{
for
key
in
reverse_d
.get
(
val
)
.unwrap
()
{
let
val_2grams
=
derive_2grams
(
key
);
...
...
This diff is collapsed.
Click to expand it.
src/packages/parser.rs
+
1
−
1
View file @
e807a4b7
...
...
@@ -16,7 +16,7 @@ fn linux_regexps() -> Vec<Regex> {
}
fn
openstack_format
()
->
String
{
return
r"
(?P
<Logrecord>
.*?)\s+(?P<Date>.*?)\s+(?P<Time>.*?)\s+(?P<Pid>.*?)\s+(?P<Level>.*?)\s+(?P<Component>.*?)\s+(\[(?P<ADDR>.*?)\])?\s+(?P
<Content>
.*)
"
.to_string
();
return
r"
'
<Logrecord>
<Date> <Time> <Pid> <Level> <Component> \[<ADDR>\]
<Content>
'
"
.to_string
();
}
fn
openstack_regexps
()
->
Vec
<
Regex
>
{
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment