Log Scan Macro

The log_scan_alarms_macros.cfg is a script macro to scan log file output for noteworthy entries.

log_scan(f, BYPASS1, LOGONLY, FLAGS, BYPASS2)
 
	init
		status =piktstatus
		level =piktlevel
		task "Scan the (f) for noteworthy entries"
		// if the error log reports something like "variable
		// mismatch in line , this probably signifies
		// that the last line in the log file doesn't end with
		// linefeed; the solution here is to hand edit out that
		// last offending line
#ifndef debug
		input logfile "(f)"
#elsedef
		input file "(f)"
#endifdef
	begin
		if $level() !~~ "emerg|alert"
			=checkpoint(=lalim)
		fi

	rule	// automatic bypasses
		if    $inlin eq ""
		   || $inlin =~~ "=nonesuch"
			next
		endif

	rule	// special alarm-specific bypasses, first bypass
		if $inlin =~~ "(BYPASS1)"
			next
		endif

	rule	// log anything not bypassed
		if $inlin =~~ "(LOGONLY)"
			=output_alarm_log($inlin)
			next
		endif

	rule	// for flagged stuff, report and log (and possibly page)
		if $inlin =~~ "(FLAGS)"
			output mail $inlin
			=output_alarm_log($inlin)
			// if ...
			// 	=page()
			// endif
			next
		endif

	rule	// report and log any root-related stuff
		if $inlin =~ "root"
			output mail $inlin
			=output_alarm_log($inlin)
			next
		endif

//#ifndef paranoid
//	rule	// bypass everything else
//		next
//#endifdef

	rule	// special alarm-specific bypasses, second bypass
		if $inlin =~~ "(BYPASS2)"
			next
		endif

	rule	// log anything not bypassed
		=output_alarm_log($inlin)

	rule	// report anything not bypassed
		output mail $inlin

	end
		quit

You might invoke the =log_scan() macro in your alarms.cfg file thusly:

NightlyUpdatesLogScan
 
        =log_scan(/tmp/nightly-updates.log,
                  warning|control-c|-fexceptions|no-exceptions|downloading,
                  =nonesuch, !!!, .)

Output from this script might look like, for example:

WARNING:
    NightlyUpdatesLogScan
        Scan the /tmp/nightly-updates.log for noteworthy entries
 
        !!! ERROR: acme-libs/CTAccess-17.3.1 failed.
        !!! died running emake, kde_src_compile:make
        !!! If you need support, post the topmost build error,
            and the call stack if relevant.

For more examples, see Samples.

 
Home | FAQ | News | Intro | Samples | Tutorial | Reference | Software
Developer's Notes | Licensing | Authors | Pikt-Users | Pikt-Workers | Related Projects | Site Index | Privacy Policy | Contact Us
Page best viewed at 1024x768 or greater.   Page last updated 2019-01-12.   This site is PIKT® powered.
Copyright © 1998-2019 Robert Osterlund. All rights reserved.
Home FAQ News Intro Samples Tutorial Reference Software
PIKT Logo
PIKT Page Title
View sample
dmesg scan
script macro