$fixed(), $str(), $string(), $text()
DESCRIPTION
returns a truncated number as a string with no decimal places
or:
returns a number as a string with the specified decimal places
SYNOPSIS
$fixed(n)
$str(n)
$string(n)
$text(n)
or:
$fixed(n,i)
$str(n,i)
$string(n,i)
$text(n,i)
ARGUMENTS
n - a number, or numerical expression
or:
n - a number, or numerical expression
i - a positive integer, or integer expression
EXAMPLES
#ifdef debug
rule
output $inlin
output "\#cpuid is $fixed(100*#cpuid,1)%"
quit
#endifdef
rule
if $level() =~~ "emerg"
if $proc =~~ "(PROCS)"
=psheader
output mail =newline
output mail $inlin
output mail "\%CPU $string(#cpu,1) >= (LIMEMERG),
PROPOSED ACTION: =kill -9 $PID"
else
=periodically(=psheader output mail =newline output mail $inlin, , #period)
fi
next
fi
rule // for exceeding max thresholds
if $typ eq "+"
set $msg = "$dev: $oid $text(#oidval) >= mailval $text(#mailval)"
// email if greater than or equal to #mailval,
// and thereafter only if is rising
if #oidval >= #mailval
&& (! #defined(%oidval) || #oidval > %oidval )
output mail $msg
=shout($msg, =always)
fi
// page if greater than or equal to #pageval,
// but only once every hour
if #oidval >= #pageval
=hourly(=page($msg, =allpager, =always), )
fi
rule
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
SEE ALSO
String Functions
Numerical Functions