Skip to content
Snippets Groups Projects
Commit cc2a90d0 authored by Sebastien Boutelier's avatar Sebastien Boutelier
Browse files

Hostname et typo

parent 6fe07e00
No related branches found
No related tags found
No related merge requests found
......@@ -5,10 +5,12 @@ use std::env;
use regex::Regex;
use syslog::{Facility, Formatter3164};
use std::sync::OnceLock;
use gethostname::gethostname;
mod hashmap;
static LOGHOST: OnceLock<String> = OnceLock::new();
static HOSTNAME: OnceLock<Option<String>> = OnceLock::new();
static REGEXP_CLOSE: OnceLock<Regex> = OnceLock::new();
static REGEXP_CMD: OnceLock<Regex> = OnceLock::new();
static REGEXP_CONNECT: OnceLock<Regex> = OnceLock::new();
......@@ -156,8 +158,8 @@ fn com_default(line: String){
fn sendlog(line: String){
let formatter = Formatter3164 {
facility: Facility::LOG_USER,
hostname: None,
process: "sldapd".into(),
hostname: HOSTNAME.get().unwrap().clone(),
process: "slapd".into(),
pid: 6666,
};
......@@ -222,6 +224,8 @@ fn main() {
let loghost = getloghost().unwrap();
let _ = LOGHOST.set(loghost);
let port = getport().unwrap();
let hostname = Some(gethostname().into_string().unwrap());
let _ = HOSTNAME.set(hostname);
let _ = REGEXP_LAUNCH.set(Regex::new(r"^\S+ \S+ \S+ \S+ \S+ (?<con>\S+) (?<op>\S+) (?<command>\S+)").unwrap());
let _ = REGEXP_OTHERLOG.set(Regex::new(r"^\S+ \S+ \S+ \S+ \S+ (?<log>.+)").unwrap());
let _ = REGEXP_RESULT.set(Regex::new(r"^\S+ \S+ \S+ \S+ \S+ conn=(?<con>[0-9]+) op=(?<op>[0-9]+)( SEARCH)? RESULT \S+ (?<err>\S+)( nentries=(?<nentries>[0-9]+))?").unwrap());
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment