Dead System Processes

In this example, we report dead system processes.

The ProcessSystemDead script might send an alert message like the following:

                                PIKT ALERT
                         Wed Oct  3 07:08:06 2002
                                 athens2

URGENT:
    ProcessSystemDead
        Report or restart 'dead' crucial system processes

        The process 'syslogd' is not running

ProcessSystemDead makes reference to the =process_system_obj macro, which resolves to the name of the ProcessesSystem.obj file.  The script follows.

ProcessSystemDead

        init
                status =piktstatus
                level =piktlevel
                task "Report or restart 'dead' crucial system processes"
                input file "=process_system_obj"
                seps ":"
                dat $pr1 [1]
                dat $pr2 [2]
                dat $cmd [3]

        rule
                set #norun = #false()

        rule
                if $pr2 ne ""
                        set $c = $command("=psall | =egrep '$pr2.+$pr1' |
                                           =grep -v grep")
                        if $c eq ""
                                set #norun = #true()
#ifdef debug
                                =outputproc(mail, "=psall")
                                output mail "\$pr1 is $pr1"
                                output mail "\$pr2 is $pr2"
                                output mail "\$cmd is $cmd"
                                output mail "\$c is $c"
#endifdef
                        endif
                else
                        if #pid($pr1) == #nil()
                                set #norun = #true()
                        endif
                endif

        rule
                if #norun
                        if $cmd eq "."
                                output mail "The process '$pr1' is not running"
                        else
                                =execwait $cmd
                        endif
                endif

This is just one program example.  You could add rules, or write new scripts, for example to:  report and possibly kill runaway processes, report unusually high counts of per-user processes, report and possibly kill forbidden processes, report extremely high numbers of zombie and defunct processes, log special process accounting data, etc.

Open Hand 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 2008-03-27.   This site is PIKT® powered.
PIKT® is a registered trademark of the University of Chicago.   Copyright © 1998-2008 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