pub fn exit_message(&self, access_errors: &LogFileAccessErrorList) -> NagiosError {
        let current_pid = std::process::id();

        // calculate the summation of all pattern counts for all logfiles
        let pattern_sum = self
            .snapshot
            .values() // Vec<LogFile>
            .map(|x| x.sum_counters(current_pid)) // Vec<PatternCounters>
            .fold(PatternCounters::default(), |acc, x| acc + x); // PatternCounters

        // build the nagios exit counters
        let mut global_exit = NagiosExit::default();
        global_exit.critical_count = pattern_sum.critical_count;
        global_exit.warning_count = pattern_sum.warning_count;

        // add critical, warning or unknown error count with access errors
        for (_, access_error) in access_errors.iter() {
            match access_error.nagios_error {
                NagiosError::CRITICAL => global_exit.critical_count += 1,
                NagiosError::WARNING => global_exit.warning_count += 1,
                NagiosError::UNKNOWN => global_exit.unknown_count += 1,
                NagiosError::OK => (),
            }
        }

        // unknown is a special case: we sum the number of cases where an error occurred in RunData structures
        for logfile in self.snapshot.values() {
            global_exit.unknown_count += logfile
                .run_data
                .values()
                .filter(|x| x.last_error.is_some())
                .count() as u64;
        }

        let nagios_error = NagiosError::from(&global_exit);
        println!("{}", global_exit);

        // loop through all run data
        for (path, logfile) in &self.snapshot {
            for (tag_name, run_data) in &logfile.run_data {
                if run_data.pid == current_pid {
                    let nagios_exit = NagiosExit::from(run_data);
                    println!("{}(tag={}) - {}", path.display(), tag_name, nagios_exit);
                }
            }
        }

        // then list access errors
        for (path, access_error) in access_errors.iter() {
            println!(
                "{} - {}: {}",
                path.display(),
                String::from(&access_error.nagios_error),
                access_error.error
            );
        }

        nagios_error
    }
/// Builds the final output message displayed by the plugin
Builds the final output message displayed by the plugin
Builds the final output message displayed by the plugin
pub fn exit_message(&self, access_errors: &LogFileAccessErrorList) -> NagiosError {
        let current_pid = std::process::id();
        // calculate the summation of all pattern counts for all logfiles
        let pattern_sum = self
            .snapshot
            .values() // Vec<LogFile>
            .map(|x| x.sum_counters(current_pid)) // Vec<PatternCounters>
            .fold(PatternCounters::default(), |acc, x| acc + x); // PatternCounters
        // build the nagios exit counters
        let mut global_exit = NagiosExit::default();
        global_exit.critical_count = pattern_sum.critical_count;
        global_exit.warning_count = pattern_sum.warning_count;
        // add critical, warning or unknown error count with access errors
        for (_, access_error) in access_errors.iter() {
            match access_error.nagios_error {
                NagiosError::CRITICAL => global_exit.critical_count += 1,
                NagiosError::WARNING => global_exit.warning_count += 1,
                NagiosError::UNKNOWN => global_exit.unknown_count += 1,
                NagiosError::OK => (),
            }
        }
        // unknown is a special case: we sum the number of cases where an error occurred in RunData structures
        for logfile in self.snapshot.values() {
            global_exit.unknown_count += logfile
                .run_data
                .values()
                .filter(|x| x.last_error.is_some())
                .count() as u64;
        }
        let nagios_error = NagiosError::from(&global_exit);
        println!("{}", global_exit);
        // loop through all run data
        for (path, logfile) in &self.snapshot {
            for (tag_name, run_data) in &logfile.run_data {
                if run_data.pid == current_pid {
                    let nagios_exit = NagiosExit::from(run_data);
                    println!("{}(tag={}) - {}", path.display(), tag_name, nagios_exit);
                }
            }
        }
        // then list access errors
        for (path, access_error) in access_errors.iter() {
            println!(
                "{} - {}: {}",
                path.display(),
                String::from(&access_error.nagios_error),
                access_error.error
            );
        }
        nagios_error
    }
pub fn exit_message ( & self , access_errors : & LogFileAccessErrorList ) -> NagiosError { let current_pid = std :: process :: id ( ) ; // calculate the summation of all pattern counts for all logfiles let pattern_sum = self . snapshot . values ( ) // Vec<LogFile> . map ( | x | x . sum_counters ( current_pid ) ) // Vec<PatternCounters> . fold ( PatternCounters :: default ( ) , | acc , x | acc + x ) ; // PatternCounters // build the nagios exit counters let mut global_exit = NagiosExit :: default ( ) ; global_exit . critical_count = pattern_sum . critical_count ; global_exit . warning_count = pattern_sum . warning_count ; // add critical, warning or unknown error count with access errors for ( _ , access_error ) in access_errors . iter ( ) { match access_error . nagios_error { NagiosError :: CRITICAL => global_exit . critical_count += 1 , NagiosError :: WARNING => global_exit . warning_count += 1 , NagiosError :: UNKNOWN => global_exit . unknown_count += 1 , NagiosError :: OK => ( ) , } } // unknown is a special case: we sum the number of cases where an error occurred in RunData structures for logfile in self . snapshot . values ( ) { global_exit . unknown_count += logfile . run_data . values ( ) . filter ( | x | x . last_error . is_some ( ) ) . count ( ) as u64 ; } let nagios_error = NagiosError :: from ( & global_exit ) ; println ! ( " " global_exit ) ; // loop through all run data for ( path , logfile ) in & self . snapshot { for ( tag_name , run_data ) in & logfile . run_data { if run_data . pid == current_pid { let nagios_exit = NagiosExit :: from ( run_data ) ; println ! ( " " path display ( ) tag_name nagios_exit ) ; } } } // then list access errors for ( path , access_error ) in access_errors . iter ( ) { println ! ( " " path display ( ) String from ( access_error nagios_error ) access_error error ) ; } nagios_error }
Builds the final output message displayed by the plugin
Builds the final output message displayed by the plugin
&self
access_errors
&LogFileAccessErrorList
&self
access_errors
&LogFileAccessErrorList