Maurice van ’t Loo

Skip to content

Housekeeping scripts

[this page is under construction]

Hereby an example of a SP housekeeping.

The daily housekeeping script is cut in a few seperate scripts and started by a main script. This way, you can edit parts of the housekeeping that is currently not running, giving the admin the possibility to edit the housekeeping without stopping all tasks.

The scripts are free to use, change and distribute, but respect the developer and don't call them your own ;-)

***NOTE

In this example, the daily full DB backup is started via the hourly housekeeping script.
In the hourly DB backup script, once per day, after 14:00 and only if there is no succesfull DB backup yet, a new full DB backup shall be started. In all other 23 cases, it shall run an incremental DB backup.

Daily Housekeeping

/*---------------------------------------------------------------------*/
/* Daily Housekeeping                                                  */
/*---------------------------------------------------------------------*/

DEFINE SCRIPT  HK.MAIN.D DESC="Main DAILY housekeeping script"
UPDATE SCRIPT  HK.MAIN.D "issue message i 'Maintenance tasks started'"
UPDATE SCRIPT  HK.MAIN.D "run HK.REPL.D"
UPDATE SCRIPT  HK.MAIN.D "run HK.MIGR"
UPDATE SCRIPT  HK.MAIN.D "run HK.EXPR.RECL"

DEFINE SCRIPT  HK.REPL.D DESC="DAILY Protect STG pools plus Node Replication"
UPDATE SCRIPT  HK.REPL.D "/********************************************************************/"
UPDATE SCRIPT  HK.REPL.D "/* Protect stgpools                                                 */"
UPDATE SCRIPT  HK.REPL.D "/********************************************************************/"
UPDATE SCRIPT  HK.REPL.D "protect stgpool RPLDIRC wait=yes"
UPDATE SCRIPT  HK.REPL.D "/********************************************************************/"
UPDATE SCRIPT  HK.REPL.D "/* Node Replication                                                 */"
UPDATE SCRIPT  HK.REPL.D "/********************************************************************/"
UPDATE SCRIPT  HK.REPL.D "replicate node * wait=yes"

DEFINE SCRIPT  HK.MIGR DESC="Migration of disk STG pools"
UPDATE SCRIPT  HK.MIGR "/********************************************************************/"
UPDATE SCRIPT  HK.MIGR "/* Migrate disk stgpool                                             */"
UPDATE SCRIPT  HK.MIGR "/********************************************************************/"
UPDATE SCRIPT  HK.MIGR "/* none */"

DEFINE SCRIPT  HK.EXPR.RECL DESC="Expiration and Reclaimation"
UPDATE SCRIPT  HK.EXPR.RECL "/********************************************************************/"
UPDATE SCRIPT  HK.EXPR.RECL "/* Expire inventory                                                 */"
UPDATE SCRIPT  HK.EXPR.RECL "/********************************************************************/"
UPDATE SCRIPT  HK.EXPR.RECL "expire inventory skipdir=no quiet=yes wait=yes"
UPDATE SCRIPT  HK.EXPR.RECL "/********************************************************************/"
UPDATE SCRIPT  HK.EXPR.RECL "/* Reclaim prim tape stgpools                                       */"
UPDATE SCRIPT  HK.EXPR.RECL "/********************************************************************/"
UPDATE SCRIPT  HK.EXPR.RECL "/* none */"

def sched HK.MAIN.D t=a startd=01/01/2001 startt=09:00 active=yes cmd="run HK.MAIN.D"

Hourly Housekeeping

/*---------------------------------------------------------------------*/
/* Hourly Housekeeping                                                 */
/*---------------------------------------------------------------------*/

DEFINE SCRIPT  HK.MAIN.H DESC="Main HOURLY housekeeping script"
UPDATE SCRIPT  HK.MAIN.H "issue message i 'Maintenance tasks started'"
UPDATE SCRIPT  HK.MAIN.H "run HK.REPL.H"
UPDATE SCRIPT  HK.MAIN.H "run HK.BADB"

DEFINE SCRIPT  HK.REPL.H DESC="HOURLY Node Replication"
UPDATE SCRIPT  HK.REPL.H "/********************************************************************/"
UPDATE SCRIPT  HK.REPL.H "issue message i 'HOURLY Node Replication'" 
UPDATE SCRIPT  HK.REPL.H "/********************************************************************/"
UPDATE SCRIPT  HK.REPL.H "replicate node * priority=high wait=yes"

DEFINE SCRIPT  HK.BADB DESC="HOURLY Database backup"
UPDATE SCRIPT  HK.BADB "/********************************************************************/"
UPDATE SCRIPT  HK.BADB "/* Database backup                                                  */"
UPDATE SCRIPT  HK.BADB "/********************************************************************/"
UPDATE SCRIPT  HK.BADB "/* Start in this hourly script, daily the full database backup */"
UPDATE SCRIPT  HK.BADB "/* Req: - one successful per day                               */"
UPDATE SCRIPT  HK.BADB "/*      - at earliest 14:00                                    */"
UPDATE SCRIPT  HK.BADB "/*      - no dbbackup running                                  */"
UPDATE SCRIPT  HK.BADB "select 'Current running DB backup: '||process from processes where process='Database Backup'"
UPDATE SCRIPT  HK.BADB "if (rc_ok) goto continue"
UPDATE SCRIPT  HK.BADB " "
UPDATE SCRIPT  HK.BADB "/* When select is True, then no full backup                    */"
UPDATE SCRIPT  HK.BADB "select 'Full of today: '||activity||' '||start_time as LastFull from summary where date(current_timestamp)=date(start_time) and activity='FULL_DBBACKUP' and successful='YES' union -"
UPDATE SCRIPT  HK.BADB "select 'Current time: '||time(current_timestamp) from sysibm.sysdummy1 where time(current_timestamp)<'14:00'"
UPDATE SCRIPT  HK.BADB " "
UPDATE SCRIPT  HK.BADB "if (rc_ok) goto dbbackup_incr"
UPDATE SCRIPT  HK.BADB "  issue message i 'Starting FULL database backup'"
UPDATE SCRIPT  HK.BADB "  backup db dev=DBBDEV type=full numstreams=2 wait=yes"
UPDATE SCRIPT  HK.BADB "  if (error) goto continue"
UPDATE SCRIPT  HK.BADB "  backup devconf file=dr/devconf.txt"
UPDATE SCRIPT  HK.BADB "  backup volhist file=dr/volhist.txt"
UPDATE SCRIPT  HK.BADB "  delete volhist type=dbb todate=today-5 totime=now"
UPDATE SCRIPT  HK.BADB "  delete volhist type=stgn todate=+1"
UPDATE SCRIPT  HK.BADB "  delete volhist type=stgd todate=+1"
UPDATE SCRIPT  HK.BADB "  /* skip incremental backup */"
UPDATE SCRIPT  HK.BADB "goto continue"
UPDATE SCRIPT  HK.BADB " "
UPDATE SCRIPT  HK.BADB "dbbackup_incr:"
UPDATE SCRIPT  HK.BADB "  issue message i 'Starting INCREMENTAL database backup'"
UPDATE SCRIPT  HK.BADB "  backup db dev=DBBSRV type=incr numstreams=4 wait=yes"
UPDATE SCRIPT  HK.BADB " "
UPDATE SCRIPT  HK.BADB "continue:"
UPDATE SCRIPT  HK.BADB "prepare wait=yes dev=DBBSRV wait=yes"
UPDATE SCRIPT  HK.BADB "prepare wait=yes"

def sched HK.MAIN.H t=a cmd="run HK.MAIN.H" startd=01/01/2001 startt=00:00 dur=50 duru=M peru=h active=yes

Daily correction

DEFINE SCRIPT HK.CORRECTION DESC="Daily corrections on all SP Servers"
UPDATE SCRIPT HK.CORRECTION "enable sessions all"
UPDATE SCRIPT HK.CORRECTION "update node *_ORA_* passexp=0"
UPDATE SCRIPT HK.CORRECTION "delete volhist type=stgn todate=+1"
UPDATE SCRIPT HK.CORRECTION "delete volhist type=stgd todate=+1"
UPDATE SCRIPT HK.CORRECTION "begin eventlogging userexit"
UPDATE SCRIPT HK.CORRECTION "enable EVENTS userexit all"
UPDATE SCRIPT HK.CORRECTION "enable events console all"
UPDATE SCRIPT HK.CORRECTION "def profassoc admins admins=be*,nl*,pl*"
UPDATE SCRIPT HK.CORRECTION "notify subscribers"
UPDATE SCRIPT HK.CORRECTION "unlock admin storage"

def sched HK.CORR.D t=a startd=01/01/2001 startt=18:00 active=yes cmd="run HK.CORRECTION"


Monitoring

Hourly checks

DELETE SCRIPT CHECK.HOURLY
Y
DEFINE SCRIPT CHECK.HOURLY DESC="Monitoring: Hourly checks"
UPDATE SCRIPT CHECK.HOURLY "* Check disk volumes"
UPDATE SCRIPT CHECK.HOURLY "select '[disk_offline] stgpool:'||stgpool_name||' volume:'||volume_name||' status:'||status from volumes where DEVCLASS_NAME='DISK' and STATUS<>'ONLINE'"
UPDATE SCRIPT CHECK.HOURLY "if(ok) issue message s '[disk_offline] Diskpool volumes offline'"
UPDATE SCRIPT CHECK.HOURLY "* Check diskpool full"
UPDATE SCRIPT CHECK.HOURLY "select '[diskpool_full] stgpool:'||stgpool_name||' pct_migr:'||PCT_MIGR||' pct_util:'||PCT_UTILIZED from stgpools where DEVCLASS='DISK' and PCT_UTILIZED>80"
UPDATE SCRIPT CHECK.HOURLY "if(ok) run mau.diskpoolfull"
UPDATE SCRIPT CHECK.HOURLY "select '[diskpool_full] stgpool:'||stgpool_name||' pct_migr:'||PCT_MIGR||' pct_util:'||PCT_UTILIZED from stgpools where DEVCLASS='DISK' and PCT_UTILIZED>95"
UPDATE SCRIPT CHECK.HOURLY "if(ok) run mau.diskpoolfull"
UPDATE SCRIPT CHECK.HOURLY "select '[diskpool_full] stgpool:'||stgpool_name||' pct_migr:'||PCT_MIGR||' pct_util:'||PCT_UTILIZED from stgpools where DEVCLASS='DISK' and PCT_UTILIZED>95"
UPDATE SCRIPT CHECK.HOURLY "if(ok) issue message s '[diskpool_full] Diskpool more then 95% utilized'"
UPDATE SCRIPT CHECK.HOURLY "* Check if audit library is running"
UPDATE SCRIPT CHECK.HOURLY "select '[audit_libr] '||substr(START_TIME,1,10)||' '||STATUS from processes where process='AUDIT LIBRARY' and (current_timestamp-START_TIME)>1000"
UPDATE SCRIPT CHECK.HOURLY "if(ok) issue message s '[audit_libr] Audit library is running'"
UPDATE SCRIPT CHECK.HOURLY "* Check if Checkin is running"
UPDATE SCRIPT CHECK.HOURLY "select '[checkin] '||substr(START_TIME,1,10)||' '||STATUS from processes where process='CHECKIN LIBVOLUME' and (current_timestamp-START_TIME)>1000"
UPDATE SCRIPT CHECK.HOURLY "if(ok) issue message s '[checkin] Checkin is running'"
UPDATE SCRIPT CHECK.HOURLY "* Check if Checkout is running"
UPDATE SCRIPT CHECK.HOURLY "select '[checkout] '||substr(START_TIME,1,10)||' '||STATUS from processes where process='CHECKOUT LIBVOLUME' and (current_timestamp-START_TIME)>1000"
UPDATE SCRIPT CHECK.HOURLY "if(ok) issue message s '[checkout] Checkout is running'"