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.
For more examples, see Samples.