Process Macros

The macros in the sample process_macros.cfg configuration file below can be used as shortcuts or quasi functions for special handling processes, for example determining process counts, displaying top output, etc.

///////////////////////////////////////////////////////////////////////////////
 
// process macros - process shortcuts
 
///////////////////////////////////////////////////////////////////////////////

procchk(P, I)   // report if a process is not running
                // (P) is the process (e.g., syslogd)
                // (I) is the interpreter (e.g., perl)
                if $proc =~ "(P)"
                        if $command("=psall | =egrep '(I).+$proc' |
                                     =grep -v grep") eq ""
                                output mail "The process '$proc' is not running"
                        endif
                        next
                endif
 
///////////////////////////////////////////////////////////////////////////////
 
#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
                #val($command("=ps -eo comm | grep -c (P)"))
#endif
 
///////////////////////////////////////////////////////////////////////////////

toptop(N)       // actually not the top N procs by size, since we don't
                // know how to sort by size non-interactively
                =outputproc(mail, "=top -b -n1 -d1 2>/dev/null | =head -n (N)")
 
///////////////////////////////////////////////////////////////////////////////

pszombies       =psall | =egrep '$'
 
///////////////////////////////////////////////////////////////////////////////

psheader
                if #doheader
                        output mail $command("=psall | =head -n 1")
                        set #doheader = #false()
                fi
 
///////////////////////////////////////////////////////////////////////////////
 
// a filter to render, e.g., 'perl foo.pl' as simply 'foo.pl' in a ps display

#fix
zapinterpreters /bin/sed 's/.usr.bin.perl //' | /bin/sed 's/perl //' |
                /bin/sed 's/.usr.bin.python //' | /bin/sed 's/python //' |
                /bin/sed 's/.bin.bash //' | /bin/sed 's/bash //' |
                /bin/sed 's/.bin.sh -c //'
#unfix
 
///////////////////////////////////////////////////////////////////////////////

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
high
CPU usage
Pikt script