/**********************************************************************/
/* CKDSKUSE - This exec will check the disks of the specified service */
/*            machines to make sure their thresholds are not being    */
/*            exceeded.  It uses the CKDSKUSE CONTROL file to hold    */
/*            the parameters.                                         */
/*                                                                    */
/* Note: The userid that runs this should have OPTION LNKNOPAS set in */
/*       their directory entry.                                       */
/* ------------------------------------------------------------------ */
/* 20010330 -CXK- Original Program                                    */
/**********************************************************************/
                                                                        
/* Set some default variables for later use.                          */
mail_users  = 'ckerner'                                                 
mail_domain = 'amdocs.com'                                              
default_warn = 85                                                       
default_crit = 95                                                       
                                                                        
/* Read the control file, ignoring any comments.                      */
'pipe < ckdskuse control a | nlocate /#/ | stem disks.'                 
                                                                        
/* If the control file doesn't exist, exit the program.               */
if disks.0 = 0 then do                                                  
   say 'CKDSKUSE01 - Control File: CKDSKUSE CONTROL A Not Found.'       
   exit 0                                                               
end                                                                     
                                                                        
/* Process the disks in the control file.                             */
do a = 1 to disks.0                                                     
                                                                        
   parse var disks.a userid minidisk pct_warn pct_crit .                
                                                                        
   /* if the limits aren't specified, then set them to default.       */
   if pct_warn = '' then pct_warn = default_warn                        
   if pct_crit = '' then pct_crit = default_crit                        
                                                                        
   /* Display which disk is being checked.                            */
   say 'CKDSKUSE01 - Processing Disk:' userid minidisk pct_warn pct_crit
                                                                         
   /* Link the minidisk, saving the address and filemode.             */ 
   'pipe cms vmlink' userid minidisk '| var vmlnktxt'                    
   parse var vmlnktxt . . . . . . addr . fmode .                         
                                                                         
   /* query the disk and extract the percent used field. */              
   'pipe (name ckdskuse endchar $)',                                     
      '  cms q disk' fmode ,  /* Query the accessed disk.             */ 
      '| dostem: fanout',     /* Save the output for the email.       */ 
      '| drop 1',             /* Drop the header.                     */ 
      '| spec w9',            /* Get the percentage used.             */ 
      '| change /-/ /',       /* Split the blocks from the percentage */ 
      '| spec w2',            /* Keep the percent used in a variable. */ 
      '| var pct_used',                                                  
    '$',                                                                 
      'dostem:',                                                         
      '| stem disk_details.'  /* Save the detail output for the email.*/ 
                                                                         
   'pipe cms rel' fmode     /* Release the minidisk.                  */ 
   'pipe cp det' addr '*'   /* Detach the disk.                       */ 
                                                                         
   /* If at critical level, send an email and post a message.         */ 
   if pct_used >= pct_crit then do                                       
      line = userid minidisk 'At Critical Level -' pct_used '% Full.'    
      say 'CKDSKUSE03 -' line                                            
      'msg caopera CKDSKUSE03 -' line                                    
      call send_email line                                               
   end                                                                   
                                                                         
   /* If at warning level, post a message.                            */ 
   if pct_used < pct_crit & pct_used >= pct_warn then do                 
      line = userid minidisk 'At Warning Level -' pct_used '% Full.'     
      say 'CKDSKUSE02 -' line                                            
      'msg caopera CKDSKUSE02 -' line                                    
   end                                                                   
end                                                                      
                                                                         
exit 0                                                            


    Source: geocities.com/vmvse/files

               ( geocities.com/vmvse)