#val(), #value()

DESCRIPTION
    returns the numerical value of a string; or ERR, if the string doesn't resolve
    to a number
SYNOPSIS
    #val(s)
    #value(s)
ARGUMENTS
	s - a string, or string expression, usually (but not necessarily) representing a number
EXAMPLES
        rule    // get log file size, in lines for text files, and KB for
                // binary files
                set #size = #if(#binary, #filesize($name)/=KB,
                                         #val($command("=wc -l $name | =awk '{print \$1}'")))
#if solaris

proc_count(P)   // return the process count for process (P)
                // (P) is the process name (without quotes, e.g., =inetd)
                // sample usage:  if =proc_count(=inetd) > 1
                #value($command("=ps -eo comm | grep -c (P)"))

#endif
checkpoint(LA)
#ifdef debug
                output $chop($command("=uptime | =awk '{print \$10}'"))
#endifdef
                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
        rule    // if it's been more than #hrs hours since the last piktd_log
                // entry, piktd is not logging, hence appears to be hung/dead;
                do #split($time, ":")
                set #t =   #datevalue(#yrnow - #if(#monnow == 1 && $mon eq "Dec", 1, 0),
                                                   #monthnumber($mon), #date)
                         + #timevalue(#val($[1]), #val($[2]), #val($[3]))
                if #timenow - #t > #hrs*60*60
                        output mail "piktd appears to be hung/dead on $sys"
                endif
SEE ALSO
    $fixed(), $str(), $string(), $text()

    Numerical Functions
    String Functions
 
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
Learn about
include
files