PIKT

Samples: Process Macros

PIKT Logo
Home FAQ News Intro Samples Tutorial Reference Software Authors Licensing SiteSearch


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
#if solaris
                do #popen(TOP, "=top -b -n1 -d(N) | =head -30", "r")
#elif redhat | debian
                // redhat's top is nonstandard, and it's not clear
                // how to run it in batch mode;
                // do #popen(TOP, "=top (N) | =head -30", "r")
                do #popen(TOP, "echo 'top info unavailable'", "r")
#endif
                while #read(TOP) > 0
                        output mail $readline
                endwhile
                do #pclose(TOP)
                output mail =newline

///////////////////////////////////////////////////////////////////////////////

[For more examples, see Samples.]

Home | FAQ | News | Intro | Samples | Tutorial | Reference | Software | Authors | Licensing | SiteSearch
Links | SiteIndex | Pikt-Users | Pikt-Workers | Contribute | ContactUs | Top of Page
Page best viewed at 1024x768.   Page last updated 2005-06-22.
This site is PIKT® powered.
PIKT® is a registered trademark of the University of Chicago.
Copyright © 1998-2005 Robert Osterlund.  All rights reserved.

Computer Books at Amazon.com

The Linux Enterprise Cluster
The Linux Enterprise Cluster

Linux Server Hacks
Linux Server Hacks

CVS Pocket Reference
CVS Pocket Reference

The Book of Webmin
The Book of Webmin

Essential CVS
Essential CVS