//////////////////////////////////////////////////////////////////////////////// // // Task: FSUPTIME.TSK // (Parse SYS:VOL$LOG.ERR and ABEND.LOG info to document Server uptime) // Author: Avanti Technology, Inc. // http://www.avanti-tech.com // Version: 1.0 - Initial Release // (25 May 2002) // // Description: // ============ // Automatically parses the SYS: Volume activity log (SYS:VOL$LOG.ERR) // extracting all the mount (typical of a Server being brought on-line) // and dismount (typical of a Server being downed in an orderly fashion) // events, reformatting the data, and writing it to the FSUPTIME.LOG file. // Subsequently parses the ABEND information log (SYS:SYSTEM\ABEND.LOG) // extracting all the ABEND events, reformatting the data and writing it // to the FSUPTIME.LOG file. The log is then sorted by date/time which // should provide a fairly complete record of Server reboots and ABENDs. // // Note: SYS: must be a Traditional NetWare Volume (i.e., not NSS, since // NSS volumes do not maintain VOL$LOG.ERR activity logs by volume). // ABEND info only available if NW v4+ and Auto Recovery enabled. // // Objective: // ========== // Using the information in the FSUPTIME.LOG file, the network manager // should be able to document and calculate Server uptime and problems. // // Comments: // --------- // Records are output in fixed format as follows then sorted by date/time: // 0000000001111111111222222222233333333 // 1234567890123456789012345678901234567 // type action wdy yyyy/mm/dd hh:mm:ss.m // // fields offset content (description) // type 01-04 SYS: (mount/dismount) // SRVR (ABEND) // action 06-11 ABEND (SRVR ABEND) // DISMNT (SYS: dismount) // MOUNT (SYS: mount) // wdy 13-15 wdy (day of the week: MON/TUE/WED/THU/FRI/SAT/SUN) // date 17-26 yyyy/mm/dd (date) // time 28-35 hh:mm:ss (time) // am|pm 36-37 am|pm (unless 24 Hour logic option enabled) // // Examples: // --------- // SRVR ABEND FRI 1999/09/17 05:20:09pm // SYS: MOUNT FRI 1999/09/17 05:27:57pm // SYS: DISMNT TUE 2000/01/25 01:22:04pm // // Usage: // ====== // Script can be manually executed using the TaskMaster TMRUN command // at the TMConsole (Shell) Screen: // // Example: TMRUN [vol:path\]FSUPTIME.TSK // // Note: [vol:path\] is not required if the task resides either // in SYS:SYSTEM or the TaskMaster NLM load directory. // // Script can be scheduled for automatic execution using Client interface or // using the TaskMaster TMSCHEDULE command at the TMConsole (Shell) Screen: // // Examples: TMSCHEDULE ADD FSUPTIME.TSK 01 02:00 // (Executes the 1st of each month at 2:00am) // // TMSCHEDULE ADD FSUPTIME.TSK YNNNNNN 02:00 // (Executes every Sunday [SMTWTFS] at 2:00am) // // Note: Scheduled tasks must reside either in SYS:SYSTEM or the // TaskMaster NLM load directory for security reasons. // // Compatibility: // ============== // This task has been tested on the following platforms without demonstrating // any compatibility issues or any other reported/confirmed conflicts: // TaskMaster v3.16 (or later), TaskMaster Lite v3.16 (or later) // NetWare v4.1x / v5.x / v6.0 // // Warning: // ======== // AS WITH ANY NEW SOFTWARE PROGRAM, BATCH SCRIPT, OR AUTOMATED PROCESSING // PROCEDURE, CAUTION SHOULD BE EXERCISED AND DUE DILIGENCE OBSERVED DURING // INITIAL IMPLEMENTATION. WHERE POSSIBLE, TESTING SHOULD BE PERFORMED ON // NON-PRODUCTION SYSTEMS PRIOR TO FULL IMPLEMENTATION. // //////////////////////////////////////////////////////////////////////////////// // Verify TaskMaster compatibility IF "%TM_VERSION%.%TM_SUBVERSION%"<"3.16" // Report the status ECHO. ECHO Error: Incompatible TaskMaster release (requires v3.16 or later)! ECHO. ABORT ENDIF // Open temporary data file for writing parsed events (TRUNCATE = new log) OPEN_WRITE SYS:FSUPTIME.DAT TRUNCATE :PARSE_SYS_LOG // Check if SYS: Volume activity log file exists // (does not exist if NW v6 and SYS: is NSS volume) IF NOT EXIST SYS:VOL$LOG.ERR THEN GOTO PARSE_ABEND_LOG // Open Server SYS: Volume activity tracking log file for input OPEN_READ SYS:VOL$LOG.ERR // WHILE/LOOP to process data in SYS: Volume activity tracking log file WHILE // Read the next line in the log (ERRORLEVEL == End Of File (EOF)) READ %1 IF ERRORLEVEL THEN BREAK // Null record - read next line IF "%1"=="" THEN CONTINUE // If not " SYS " volume and "mounted" (mount/dismount) references, skip it IF NOT SCAN_STRING " SYS " "%1" THEN CONTINUE IF NOT SCAN_STRING "mounted" "%1" THEN CONTINUE // Record the Day Of Week in fixed format (three characters) IF SCAN_STRING "Monday" "%1" THEN DEFINE %2 MON IF SCAN_STRING "Tuesday" "%1" THEN DEFINE %2 TUE IF SCAN_STRING "Wednesday" "%1" THEN DEFINE %2 WED IF SCAN_STRING "Thursday" "%1" THEN DEFINE %2 THU IF SCAN_STRING "Friday" "%1" THEN DEFINE %2 FRI IF SCAN_STRING "Saturday" "%1" THEN DEFINE %2 SAT IF SCAN_STRING "Sunday" "%1" THEN DEFINE %2 SUN // Record the Year in numeric format DEFINE %9 %YEAR% WHILE %9>1981 IF SCAN_STRING " %9 " "%1" THEN BREAK DEFINE %9 %9-=1 LOOP // Store the Year in the date variable DEFINE %3 %9 // Record the Month in numeric format (zero-filled, two digits) IF SCAN_STRING " January " "%1" THEN DEFINE %9 01 IF SCAN_STRING " February " "%1" THEN DEFINE %9 02 IF SCAN_STRING " March " "%1" THEN DEFINE %9 03 IF SCAN_STRING " April " "%1" THEN DEFINE %9 04 IF SCAN_STRING " May " "%1" THEN DEFINE %9 05 IF SCAN_STRING " June " "%1" THEN DEFINE %9 06 IF SCAN_STRING " July " "%1" THEN DEFINE %9 07 IF SCAN_STRING " August " "%1" THEN DEFINE %9 08 IF SCAN_STRING " September " "%1" THEN DEFINE %9 09 IF SCAN_STRING " October " "%1" THEN DEFINE %9 10 IF SCAN_STRING " November " "%1" THEN DEFINE %9 11 IF SCAN_STRING " December " "%1" THEN DEFINE %9 12 // Append the Month to the date variable DEFINE %3 %3/%9 // Record the Day in numeric format // Increment from 1 (single digit) since string will not have leading zero DEFINE %8 1 WHILE NOT %8==31 IF SCAN_STRING " %8," "%1" THEN BREAK DEFINE %8 %8+=1 LOOP // Pre-format the Day variable to two digits (zero filled, two digits) DEFINE %9 00 // Add the Day value found in the string DEFINE %9 %9+=%8 // Append the Day to the date variable DEFINE %3 %3/%9 // Record the Hour in numeric format // Increment from 1 (single digit) since string will not have leading zero DEFINE %8 1 WHILE NOT %8==12 IF SCAN_STRING " %8:" "%1" THEN BREAK DEFINE %8 %8+=1 LOOP // Pre-format the Hour variable to two digits (zero filled, two digits) DEFINE %9 00 // Add the Hour value found in the string DEFINE %9 %9+=%8 // If 24 Hour time is desired, uncomment the next command line // Note: Also be sure to comment out the "%9 am" and "%9 pm" IF tests // which follow right after the Second routine // IF SCAN_STRING " pm" "%1" AND %9<12 THEN DEFINE %9 %9+=12 // Store the Hour in the time variable DEFINE %4 %9 // Record the Minute in numeric format // Decrement from 59 (double digit) since string will have leading zero DEFINE %9 59 WHILE %9>00 IF SCAN_STRING ":%9:" "%1" THEN BREAK DEFINE %9 %9-=01 LOOP // Store the Minute in the time variable DEFINE %4 %4:%9 // Record the Second in numeric format // Decrement from 59 (double digit) since string will have leading zero DEFINE %9 59 WHILE %9>00 IF SCAN_STRING ":%9 " "%1" THEN BREAK DEFINE %9 %9-=01 LOOP // Store the Second in the time variable DEFINE %4 %4:%9 // Comment out the following two IF structures if using 24 Hour time IF SCAN_STRING "%9 am" "%1" THEN DEFINE %4 %4am IF SCAN_STRING "%9 pm" "%1" THEN DEFINE %4 %4pm // Log the information to the data file in proper format IF SCAN_STRING "dismount" "%1" WRITE SYS: DISMNT %2 %3 %4 ELSE WRITE SYS: MOUNT %2 %3 %4 ENDIF LOOP :PARSE_ABEND_LOG // Check if ABEND log exists (does not exist for NetWare v3) IF NOT EXIST SYS:SYSTEM\ABEND.LOG THEN GOTO MERGE_LOGS // Open ABEND log for input (also closes previous OPEN_READ file, if open) OPEN_READ SYS:SYSTEM\ABEND.LOG // WHILE/LOOP to process data in ABEND log file WHILE // Read the next line in the log (ERRORLEVEL == End Of File (EOF)) READ %1 IF ERRORLEVEL THEN BREAK // Null record - read next line IF "%1"=="" THEN CONTINUE // If not "Server [ServerName] halted" reference, skip it IF NOT SCAN_STRING "Server %SERVER% halted " "%1" THEN CONTINUE // Record the Day Of Week in fixed format (three characters) IF SCAN_STRING "Monday" "%1" THEN DEFINE %2 MON IF SCAN_STRING "Tuesday" "%1" THEN DEFINE %2 TUE IF SCAN_STRING "Wednesday" "%1" THEN DEFINE %2 WED IF SCAN_STRING "Thursday" "%1" THEN DEFINE %2 THU IF SCAN_STRING "Friday" "%1" THEN DEFINE %2 FRI IF SCAN_STRING "Saturday" "%1" THEN DEFINE %2 SAT IF SCAN_STRING "Sunday" "%1" THEN DEFINE %2 SUN // Record the Year in numeric format DEFINE %9 %YEAR% WHILE %9>1981 IF SCAN_STRING " %9 " "%1" THEN BREAK DEFINE %9 %9-=1 LOOP // Store the Year in the date variable DEFINE %3 %9 // Record the Month in numeric format (zero-filled, two digits) IF SCAN_STRING " January " "%1" THEN DEFINE %9 01 IF SCAN_STRING " February " "%1" THEN DEFINE %9 02 IF SCAN_STRING " March " "%1" THEN DEFINE %9 03 IF SCAN_STRING " April " "%1" THEN DEFINE %9 04 IF SCAN_STRING " May " "%1" THEN DEFINE %9 05 IF SCAN_STRING " June " "%1" THEN DEFINE %9 06 IF SCAN_STRING " July " "%1" THEN DEFINE %9 07 IF SCAN_STRING " August " "%1" THEN DEFINE %9 08 IF SCAN_STRING " September " "%1" THEN DEFINE %9 09 IF SCAN_STRING " October " "%1" THEN DEFINE %9 10 IF SCAN_STRING " November " "%1" THEN DEFINE %9 11 IF SCAN_STRING " December " "%1" THEN DEFINE %9 12 // Append the Month to the date variable DEFINE %3 %3/%9 // Record the Day in numeric format // Increment from 1 (single digit) since string will not have leading zero DEFINE %8 1 WHILE NOT %8==31 IF SCAN_STRING " %8," "%1" THEN BREAK DEFINE %8 %8+=1 LOOP // Pre-format the Day variable to two digits (zero filled, two digits) DEFINE %9 00 // Add the Day value found in the string DEFINE %9 %9+=%8 // Append the Day to the date variable DEFINE %3 %3/%9 // Record the Hour in numeric format // Increment from 1 (single digit) since string will not have leading zero DEFINE %8 1 WHILE NOT %8==12 IF SCAN_STRING " %8:" "%1" THEN BREAK DEFINE %8 %8+=1 LOOP // Pre-format the Hour variable to two digits (zero filled, two digits) DEFINE %9 00 // Add the Hour value found in the string DEFINE %9 %9+=%8 // If 24 Hour time is desired, uncomment the next command line // Note: Also be sure to comment out the "%9 am" and "%9 pm" IF tests // which follow right after the Second routine // IF SCAN_STRING " pm" AND %9<12 THEN DEFINE %9 %9+=12 // Store the Hour in the time variable DEFINE %4 %9 // Record the Minute in numeric format // Decrement from 59 (double digit) since string will have leading zero DEFINE %9 59 WHILE %9>00 IF SCAN_STRING ":%9:" "%1" THEN BREAK DEFINE %9 %9-=01 LOOP // Store the Minute in the time variable DEFINE %4 %4:%9 // Record the Second in numeric format // Decrement from 59 (double digit) since string will have leading zero DEFINE %9 59 WHILE %9>00 IF SCAN_STRING ":%9 " "%1" THEN BREAK DEFINE %9 %9-=01 LOOP // Store the Second in the time variable DEFINE %4 %4:%9 // Comment out the following two IF structures if using 24 Hour time IF SCAN_STRING "%9 am" "%1" THEN DEFINE %4 %4am IF SCAN_STRING "%9 pm" "%1" THEN DEFINE %4 %4pm // Log the information to the Task ABEND data file WRITE SRVR ABEND %2 %3 %4 LOOP :MERGE_LOGS // Close all logs CLOSE // Check temporary data file status IF NOT EXIST SYS:FSUPTIME.DAT OR "%FILE_SIZE_SYS:FSUPTIME.DAT%"=="0000000000" // Report the status ECHO. ECHO Error: Unable to parse any data to generate report! ECHO. ABORT ENDIF // Sort the data file by date, time, and am/pm fields (if applicable) // Note: If 24 Hour format is used, either eliminate last key or add /P option // // date 17-26 yyyy/mm/dd (date) // time 28-35 hh:mm:ss (time) // am|pm 36-37 am|pm (unless 24 Hour logic option enabled) // SORT SYS:FSUPTIME.DAT SYS:FSUPTIME.LOG 17-26,28-35,36-37 IF ERRORLEVEL // Report the status ECHO. ECHO Error: Unable to sort FSUPTIME.DAT to create FSUPTIME.LOG! ECHO Review the data (.DAT) file and re-try manual SORT. ECHO. ABORT ELSE // Delete the temporary data file DELETE SYS:FSUPTIME.DAT ENDIF