#abs(), #absval(), #absolutevalue()
DESCRIPTION
returns the absolute value of a number
SYNOPSIS
#abs(n)
#absval(n)
#absolutevalue(n)
ARGUMENTS
n - a number, or numerical expression
EXAMPLES
# pikt +C 'output $text(#abs(-3))'
3
# pikt +C 'output $text(#abs(3))'
3
rule // there is a problem with autotruncating just any system log
// file: if we time this wrong, we might lose sight of vital
// signs that other alarms might detect; we *could* try to
// time this just right, but it's safer, in the case of
// security-related logs (like authlog and sulog) simply to
// report that they are oversized, and leave the truncation
// to the human operator, after he/she has had the chance
// to review the tail end of the log file; report-no-truncate
// is indicated by #maxsize being set to a negative number
if #size > #abs(#maxsize)
&& #maxsize < 0 // negative number signals report only
output mail "$name is due for truncation,
is $text(#size) " . $if(#binary, "KB", "lines")
output mail "review the file, then do: " .
$if($preproc eq ".", "", "$preproc; ") .
"=trunc " .
$if(#binary, "0", "100") .
" $name" .
$if($postproc eq ".", "", "; $postproc")
next
endif
rule // if oversized, do special pre-truncation actions
if #size > #abs(#maxsize)
if $preproc ne "."
=execwait $preproc
endif
endif
rule // if oversized, truncate
if #size > #abs(#maxsize)
=outputmail "Truncating $name, was $text(#size) " .
$if(#binary, "KB", "lines")
=execwait "=trunc " . $if(#binary, "0", "100") . " $name"
endif
rule // if oversized, do special post-truncation actions
if #size > #abs(#maxsize)
if $postproc ne "."
=execwait $postproc
endif
endif
SEE ALSO
Numerical Functions
String Functions