Script Abort Macros
The macros in the sample script_abort_macros.cfg configuration file below are for quitting Pikt scripts--for example, if the system load average is too high, and continuing with the Pikt script might add to the system burden.
/////////////////////////////////////////////////////////////////////////////// // script abort macros /////////////////////////////////////////////////////////////////////////////// lalim #if missioncritical # if server # ifdef scripts 0.50 # elsedef 0.25 # endifdef # else # ifdef scripts 1.00 # elsedef 0.40 # endifdef # endif #else # ifdef debug 0.10 # elsedef 1.00 # endifdef #endif /////////////////////////////////////////////////////////////////////////////// checkpoint(LA) // if certain conditions apply, quit the current script // (and perhaps log the reason why) // (LA) is the system load average #ifdef debug output $chop($command("=uptime | =awk '{print \$10}'")) #endifdef #if server if =businesshours(#hour()) if $level() !~~ "emerg" quit fi fi #endif set #la = #val($chop($command("=uptime | =awk '{print \$10}'"))) if #la >= (LA) output log "=logdir/Checkpoint.log" "quit $alarm(), load average $text(#la, 2)" quit fi ///////////////////////////////////////////////////////////////////////////////
You might invoke these macros at the beginning of a Pikt script like so:
begin if $level() !~~ "emerg" =checkpoint(=lalim) fi
See Dmesg Scan Macro for a concrete example.
For more examples, see Samples.