Skip to content
Snippets Groups Projects
Commit e807a4b7 authored by Patrick Lam's avatar Patrick Lam
Browse files

frontend support for openstack logs

parent eb137d52
No related branches found
No related tags found
No related merge requests found
......@@ -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);
......
......@@ -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> {
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment