In this example, we report the existence of unwanted files--for example, system startup files--also possibly move or delete them.
The SystemFileExistUrgent script might send an alert message like the following:
-------------------------------------------------------------------------------
PIKT ALERT
Thu Jun 13 9:55:43 2003
padua
URGENT:
SystemFileExistUrgent
Report the existence of unwanted files, and possibly move or remove them
/etc/rc3.d/S50apache found! doing exec: /usr/bin/mv /etc/rc3.d/S50apache
/etc/rc3.d/xS50apache
-------------------------------------------------------------------------------
SystemFileExistUrgent makes reference to the =files_unwanted_obj macro, which resolves to the name of the FilesUnwanted.obj file. The script follows.
///////////////////////////////////////////////////////////////////////////////
//
// files_system_alarms.cfg
//
///////////////////////////////////////////////////////////////////////////////
[other alarms omitted...]
///////////////////////////////////////////////////////////////////////////////
SystemFileExistUrgent // use this to warn about /etc/nologin files, or
// unwanted service startup files (in /etc/rc?.d),
// for example
init
status active
level urgent
task "Report the existence of unwanted files,
and possibly move or remove them"
input file "=files_unwanted_obj"
seps ":"
dat $name [1]
dat $cmd [2]
keys $name
rule // every $name (file) has its own #hr value
set #hr = #hour()
rule
if -e $name
set $state = "+"
if $cmd eq "."
if $state ne %state // report initial
// appearance
|| #hr < %hr // repeat daily
// if still exist
output mail "$name found!"
endif
else
if %state eq "+" // existed last run,
// hence possible rm
// or mv $cmd failed
// before
&& #hr < %hr // repeat daily
// if still exist
output mail "$name found!"
else
=outputmail "$name found!
doing exec: $cmd"
=execwait $cmd
endif
endif
else
set $state = "-"
endif
///////////////////////////////////////////////////////////////////////////////
[other alarms omitted...]
///////////////////////////////////////////////////////////////////////////////
[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.
|