//////////////////////////////////////////////////////////////////////////////// // // Task: DSHEALTH.TSK // (NDS Health Check / Repair script) // Author: Avanti Technology, Inc. // http://www.avanti-tech.com // Version: 1.0 - Initial Release // Version: 1.1 - Updated Release (added logic to work around "" in log strings) // (30 June 2004) // // Description: // ============ // Automatically coordinates the use of DSTRACE operations and the execution // of the DSDIAG NLM to diagnosis and log the current state of health for NDS // then parses the information in the DSTRACE and DSDIAG logs to identify any // possible problems. If any problems are detected, launches DSREPAIR in an // attempt to repair them then parses the DSREPAIR log file to determine the // results. A final Summary Report is generated reporting any problems // detected before and after DSREPAIR. // // Objective: // ========== // A scheduled NDS maintenance task to perform a basic NDS Health Check and // attempt to perform any basic repairs needed with a Summary Report provided. // Can easily be modified to add or remove tests according to requirements. // // Note: The task output log file can be renamed or relocated as desired by // modifying the following DEFINE statement located later in the script: // // // Define the task output log file name // // DEFINE %9 SYS:\SYSTEM\DSHEALTH.LOG // // Usage: // ====== // Script can be manually executed using the TaskMaster TMRUN command // at the TMConsole (Shell) Screen: // // Example: TMRUN [vol:path\]DSHEALTH.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 DSHEALTH.TSK 01 02:00 // (Executes the 1st of each month at 2:00am) // // TMSCHEDULE ADD DSHEALTH.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. // // Comments: // ========= // While some may recognize a similarity between this task and a previous // NetWare Cool Solutions promoted CRON/Toolbox version, the differences // and capabilities are profoundly different, not to mention that this // version is also much easier to install, maintain, schedule, and review. // // Some of the more obvious differences are: // // CRON Version // ------------ // 20 .NCF files (NetWare Command Files or batch scripts) // 10 .STK files (Toolbox STUFFKEY.NLM scripts) // 4 .NLMs (CRON.NLM, DSDIAG.NLM, DSREPAIR.NLM, STUFFKEY.NLM) // 2 tasks (minimum to schedule, tasks launch other tasks) // DSTRACE, DSDIAG, DSREPAIR, & log files must be manually checked for errors // // TaskMaster/TMLite Version // ------------------------- // 1 .TSK files (TaskMaster script file) // 3 .NLMs (DSDIAG.NLM, DSREPAIR.NLM, TaskMaster/TMLite NLM) // 1 task // A Summary status report is generated (includes any log file errors) // // This TaskMaster/TMLite task not only automates the generation of the // DSTRACE, DSDIAG, and DSRepair log files but also parses any error // messages into a final formatted report, eliminating the need to check // the logs manually. Note: This is just a basic health check template // which could be expanded upon and customized as needed by the User. // // It is probably too obvious to point out which seems easier to manage, // less likely to break, and provides more information... // // System Environment Variables (%0 - %9) used/usage: // -------------------------------------------------- // %0 Timeout Counter (set using CALC/DEFINE) // %1 Temporary data variable (set by READ) // %2 Temporary data variable (set by DEFINE/READ) // %3 Temporary data variable (set by READ) // %5 Temporary flag variable (set by DEFINE) // %6 Temporary flag variable (set by DEFINE) // %7 Temporary Error Count (set by DEFINE) // %8 Total Error Count (set by DEFINE) // %9 Generated Summary Report (set by DEFINE) // // The internal System Environment Variables are used to simplify processing // and maintenance on the script. For example, using %9 in place of the LOG // file name allows us to easily change the LOG file throughout the task // merely by changing the DEFINE which sets its value. // //////////////////////////////////////////////////////////////////////////////// // Check for compatible version of TaskMaster NLM IF "%TM_VERSION%.%TM_SUBVERSION%%TM_REVISION%"<"3.16" // Report the status ECHO. ECHO Error: Incompatible TaskMaster release (requires v3.16 or later)! ECHO. ABORT ENDIF // Summary Report log file name DEFINE %9 SYS:\SYSTEM\DSHEALTH.LOG // Total Error Count DEFINE %8 0 // Create/truncate the Summary Report OPEN_WRITE %9 TRUNCATE IF ERRORLEVEL // Report the status ECHO. ECHO Error: Unable to create/truncate %9! ECHO. ABORT ENDIF // Report the status WRITE. WRITE Initiating DSHealth (basic NDS Health Check)... WRITE. :DSTRACE // Report the status WRITE %DAY% %MONTH_NAME% %YEAR% @ %HOUR%:%MINUTE%%AM_PM% - Starting DSTrace. // Open the DS transaction trace file (DSTRACE.DBG) SET TTF = ON // Enable DSTRACE Screen SET DSTRACE = ON // Enable debug messages about Janitor (background) processing SET DSTRACE = +AGENT // Enable debug messages about backlinks (external references to real objects) SET DSTRACE = +BACKLINK // Enable debug messages regarding incoming synchronization information SET DSTRACE = +IN // Enable debug messages on pre-Janitor inspections (check if DSRepair needed) SET DSTRACE = +INSPECTOR // Enable debug messages regarding Server connectivity (Limber process) SET DSTRACE = +LIMBER // Enable debug messages for all miscellaneous processes (catch all other) SET DSTRACE = +MISC // Enable debug messages for partition operations SET DSTRACE = +PART // Enable debug messages regarding synchronization SET DSTRACE = +S // Enable debug messages regarding schema modifications and synchronization SET DSTRACE = +SCHEMA // Enable debug messages about synchronization traffic (including SYNC status) SET DSTRACE = +SKULKER // Clear the DS transaction trace file (DSTRACE.DBG) SET DSTRACE = *R // Forces the state of all Servers in the replica to UP SET DSTRACE = *U // Initiates a schema synchronization process SET DSTRACE = *SS // Initiates a flat-cleaner process SET DSTRACE = *F // Initiates a backlink process SET DSTRACE = *B // Initiates a "heartbeat" (i.e., causes the Skulker to synchronize) SET DSTRACE = *H // Report the status WRITE Waiting for completion of DSTrace processing... // Timeout (secs) DEFINE %0 300 // 'All processed =' flag (0 = not displayed, 1 = displayed) DEFINE %5 0 // 'Finished checking backlinks' flag (0 = not displayed, 1 = displayed) DEFINE %6 0 // WHILE/LOOP to await completion of DSTrace processing WHILE "%0">"000" // Check if "Directory Services" screen active IF NOT CURRENT_SCREEN "Directory Services" // If not, activate it CHANGE_SCREEN "Directory Services" ENDIF // Verify "Directory Services" screen active IF CURRENT_SCREEN "Directory Services" // BREAK WHILE/LOOP if both have appeared and at least 60 secs elapsed IF "%5"=="0" AND SCAN_SCREEN "All processed =" THEN DEFINE %5 1 IF "%6"=="0" AND SCAN_SCREEN "Finished checking backli" THEN DEFINE %6 1 IF "%5"=="1" AND "%6"=="1" AND "%0"<"270" THEN BREAK ENDIF // Allow DSTrace to work (secs) SLEEP 1 // Dec timeout count DEFINE %0 %0-=001 LOOP // Report the status WRITE Resetting DSTRACE flags to normal operations... // Close the DS transaction trace file (DSTRACE.DBG) SET TTF = OFF // Turn off all preset filters used for debugging SET DSTRACE = NODEBUG // Reset transaction trace activity to minimal level SET DSTRACE = +MIN // Close DSTRACE Screen SET DSTRACE = OFF // Open the transaction trace file to scan for errors OPEN_READ SYS:\SYSTEM\DSTRACE.DBG IF ERRORLEVEL // Report the status WRITE. WRITE Error: Unable to open SYS:\SYSTEM\DSTRACE.DBG! WRITE. // Set ERROR flag DEFINE %0 ERROR ENDIF // If ERROR, try next test IF "%0"=="ERROR" THEN GOTO DSDIAG_V // Report the status WRITE Scanning SYS:\SYSTEM\DSTRACE.DBG for possible errors... // Errors for this test DEFINE %7 0 // Scan the transaction trace file for errors WHILE // READ next record - ERRORLEVEL = EOF READ %1 IF ERRORLEVEL THEN BREAK // CONTINUE if NULL ("") record IF "%1"=="" THEN CONTINUE // Copy %1 data to %2 DEFINE %2 %1 // Convert to UPPERCASE for scan test TOUPPER %2 // Replace " with ` in %2 to avoid parsing errors with SCAN_STRING REPLACE %2 ""`" // Scan for known error strings (clear %2 on match) IF SCAN_STRING " -7" "%2" THEN DEFINE %2 IF SCAN_STRING " -6" "%2" THEN DEFINE %2 IF SCAN_STRING "ALL PROCESSED = NO" "%2" THEN DEFINE %2 IF SCAN_STRING "ERROR" "%2" THEN DEFINE %2 IF SCAN_STRING "FAILED" "%2" THEN DEFINE %2 // If %2 has data (no match) then CONTINUE IF NOT "%2"=="" THEN CONTINUE // Check if first error and write header IF %7==0 WRITE. WRITE Possible DSTrace error(s) detected: WRITE =================================== ENDIF // WRITE the error as READ WRITE %1 // Inc error count DEFINE %7 %7+=1 LOOP // Report the status IF %7>0 WRITE. WRITE ??? %7 possible problem(s) - Review SYS:\SYSTEM\DSTRACE.DBG ??? WRITE. // Inc Total Errors by temp errors DEFINE %8 %8+=%7 ELSE WRITE No potential problems were detected in SYS:\SYSTEM\DSTRACE.DBG! ENDIF // Report the status WRITE %DAY% %MONTH_NAME% %YEAR% @ %HOUR%:%MINUTE%%AM_PM% - DSTrace Complete. WRITE. WRITE. WRITE -------------------------------------------------------------------------- WRITE. WRITE. :DSDIAG_V // Report the status WRITE %DAY% %MONTH_NAME% %YEAR% @ %HOUR%:%MINUTE%%AM_PM% - Starting DSDIAG (Check NDS Versions). // Check if DSDIAG.NLM is loaded and unload it IF LOADED DSDIAG.NLM UNLOAD DSDIAG // Give it up to 15 seconds to unload completely DEFINE %0 15 WHILE LOADED DSDIAG.NLM AND "%0">"00" // Wait a second before checking again SLEEP 1 // Decrement the timeout counter DEFINE %0 %0-=01 LOOP // Give it another second for good measure SLEEP 1 ENDIF // Re-check if DSDIAG.NLM is loaded IF LOADED DSDIAG.NLM // Report the status WRITE. WRITE Error: Unable to unload DSDIAG! WRITE. ENDIF // Skip remaining DSDIAG tests IF LOADED DSDIAG.NLM THEN GOTO DSDIAG_EXIT // Load the DSDIAG NLM with the -DA options LOAD DSDIAG -DA // Give it up to 15 seconds to load completely DEFINE %0 15 WHILE NOT LOADED DSDIAG.NLM AND "%0">"00" // Wait a second before checking again SLEEP 1 // Decrement the timeout counter DEFINE %0 %0-=01 LOOP // Give it another second for good measure SLEEP 1 // Check if loaded IF NOT LOADED DSDIAG.NLM // Report the status WRITE. WRITE Error: Unable to load DSDIAG.NLM! WRITE. ENDIF // Skip remaining DSDIAG tests IF NOT LOADED DSDIAG.NLM THEN GOTO DSDIAG_EXIT // If DSDIAG NLM screen not active, activate it IF NOT CURRENT_SCREEN "DS Diagnostic" THEN CHANGE_SCREEN "DS Diagnostic" IF NOT CURRENT_SCREEN "DS Diagnostic" // Report the status WRITE. WRITE Error: Unable to activate DSDIAG.NLM Screen! WRITE. ENDIF // If DSDIAG NLM screen not active, skip remaining DSDIAG tests IF NOT CURRENT_SCREEN "DS Diagnostic" THEN GOTO DSDIAG_EXIT // Select Generate Reports from the Main Menu KEYIN "G" ENTER // Give it time to process SLEEP 2 // Check for the proper menu IF NOT SCAN_SCREEN "Report Generation" // Report the status WRITE. WRITE Error: Unable to activate Report Generation menu! WRITE. ENDIF // If Report Generation Menu not available, skip remaining DSDIAG tests IF NOT SCAN_SCREEN "Report Generation" THEN GOTO DSDIAG_EXIT // Is desired option in Report Generation menu? IF NOT SCAN_SCREEN "Check NDS Versions" // Report the status WRITE. WRITE Error: 'Check NDS Versions' menu option not shown! WRITE. ENDIF // If Check NDS Versions option not available, skip to next test IF NOT SCAN_SCREEN "Check NDS Versions" THEN GOTO DSDIAG_T // Hilite Menu choice by typing unique portion (Check NDS V), ENTER to select KEYIN "Check NDS V" ENTER // Check for the proper dialog box IF NOT SCAN_SCREEN "General Options" // Report the status WRITE. WRITE Error: Unable to activate General Options dialog! WRITE. ENDIF // If General Options are not available, skip remaining DSDIAG tests IF NOT SCAN_SCREEN "General Options" THEN GOTO DSDIAG_EXIT // UP put bar at Report File: option / ENTER open Report File Option dialog box KEYIN UP ENTER // Check and set options, as needed IF SCAN_SCREEN "Disabled" // ENTER changes Disabled to Enabled, // opens Report File Options dialog, & // puts cursor at File Name prompt KEYIN ENTER ELSEIF SCAN_SCREEN "Enabled" // DOWN puts cursor at File Name prompt KEYIN DOWN ENDIF // Temp report file name and ENTER to accept KEYIN "SYS:SYSTEM\DSDIAG_V.LOG" ENTER // Give it time to process SLEEP 1 // Verify Overwrite mode IF SCAN_SCREEN "Append" // ENTER change mode then go to next prompt KEYIN ENTER ELSE // Go to next prompt KEYIN DOWN ENDIF // Verify Report format IF SCAN_SCREEN "File Format: Data" // ENTER change format then go to next prompt KEYIN ENTER ENDIF // Verify desired options IF NOT SCAN_SCREEN "File Format: Report" OR NOT SCAN_SCREEN "Overwrite" // Report the status WRITE. WRITE Error: Unable to set Report File Options! WRITE. // Set ERROR flag DEFINE %0 ERROR ENDIF // If unable to set desired options, skip remaining DSDIAG tests IF "%0"=="ERROR" THEN GOTO DSDIAG_EXIT // Accept changes made KEYIN F10 // Verify return to the General Options menu IF NOT SCAN_SCREEN "General Options" // Report the status WRITE. WRITE Error: Did not return to General Options menu! WRITE. ENDIF // If unable to get to desired menu, skip remaining DSDIAG tests IF NOT SCAN_SCREEN "General Options" THEN GOTO DSDIAG_EXIT // Generate report KEYIN F10 // Timeout (secs) DEFINE %0 300 // WHILE/LOOP to await completion of DSDIAG processing WHILE NOT SCAN_SCREEN "Report is complete" AND "%0">"000" // Give it time to process SLEEP 1 // Dec timeout DEFINE %0 %0-=001 LOOP IF "%0"<="000" // Report the status WRITE. WRITE Error: Timeout occurred prior to Check NDS Version completion! WRITE. WRITE Will attempt to scan for errors. Status uncertain due to timeout. WRITE If this error appears periodically, the timeout may need to be WRITE increased to accomodate for Network size or WAN latency factors. WRITE. // Try to stop report KEYIN ESC // Give it time to process SLEEP 15 // Check for Stop the report prompt IF SCAN_SCREEN "Select Stop" THEN KEYIN "Y" ENTER ELSE // Press any key to continue (ESC) KEYIN ESC ENDIF // Check for and follow prompts for proper backout IF SCAN_SCREEN "General Options" THEN KEYIN ESC IF SCAN_SCREEN "Exit this report" THEN KEYIN "Y" ENTER // Check if in a state to continue IF NOT SCAN_SCREEN "Report Generation" // Report the status WRITE. WRITE Error: DSDiag not in a state to allow scanning for errors. WRITE Check DSDIAG NLM status after reviewing the reports. WRITE. ENDIF // Unable to reach a state to continue IF NOT SCAN_SCREEN "Report Generation" THEN GOTO DSDIAG_EXIT // Open the DSDIAG log to scan for errors OPEN_READ SYS:\SYSTEM\DSDIAG_V.LOG IF ERRORLEVEL // Report the status WRITE. WRITE Error: Unable to open SYS:\SYSTEM\DSDIAG_V.LOG! WRITE. // Set ERROR flag DEFINE %0 ERROR ENDIF // If ERROR, try next test IF "%0"=="ERROR" THEN GOTO DSDIAG_P // Report the status WRITE Scanning SYS:\SYSTEM\DSDIAG_V.LOG for possible errors... // Errors for this test DEFINE %7 0 // Scan the DSDIAG log for errors WHILE // READ next record - ERRORLEVEL = EOF READ %1 IF ERRORLEVEL THEN BREAK // CONTINUE if NULL ("") record IF "%1"=="" THEN CONTINUE // Copy %1 data to %2 DEFINE %2 %1 // Convert to UPPERCASE for scan test TOUPPER %2 // Replace " with ` in %2 to avoid parsing errors with SCAN_STRING REPLACE %2 ""`" // Scan for known error strings (clear %2 on match) IF SCAN_STRING "STATUS" "%2" AND SCAN_STRING "WARN" "%2" THEN DEFINE %2 IF SCAN_STRING "STATUS" "%2" AND SCAN_STRING "ERROR" "%2" THEN DEFINE %2 // If %2 has data (no match) then CONTINUE IF NOT "%2"=="" THEN CONTINUE // Check if first error and write header IF %7==0 WRITE. WRITE Possible DSDIAG (Check NDS Versions) error(s) detected: WRITE ======================================================= ENDIF // Inc error count DEFINE %7 %7+=1 // Log the error info WRITE %1 // Check for more information (null record indicates end) WHILE // READ next record - ERRORLEVEL = EOF READ %1 IF ERRORLEVEL THEN BREAK // BREAK if NULL ("") record (no more) IF "%1"=="" THEN BREAK // Log the error info WRITE %1 LOOP LOOP // Report the status IF %7>0 WRITE. WRITE ??? %7 possible problem(s) - Review SYS:\SYSTEM\DSDIAG_V.LOG ??? WRITE. // Inc Total Errors by temp errors DEFINE %8 %8+=%7 ELSE WRITE No potential problems were detected in SYS:\SYSTEM\DSDIAG_V.LOG! ENDIF // Report the status WRITE %DAY% %MONTH_NAME% %YEAR% @ %HOUR%:%MINUTE%%AM_PM% - DSDIAG (Check NDS Versions) Complete. WRITE. WRITE. WRITE -------------------------------------------------------------------------- WRITE. WRITE. :DSDIAG_T // Report the status WRITE %DAY% %MONTH_NAME% %YEAR% @ %HOUR%:%MINUTE%%AM_PM% - Starting DSDIAG (Check Server Time). // Is desired option in Report Generation menu? IF NOT SCAN_SCREEN "Check Server Time" // Report the status WRITE. WRITE Error: 'Check Server Time' menu option not shown! WRITE. ENDIF // If Check Server Time option not available, skip to next test IF NOT SCAN_SCREEN "Check Server Time" THEN GOTO DSDIAG_P // Hilite Menu choice by typing unique portion (Check Server T), ENTER to select KEYIN "Check Server T" ENTER // Check for the proper dialog box IF NOT SCAN_SCREEN "General Options" // Report the status WRITE. WRITE Error: Unable to activate General Options dialog! WRITE. ENDIF // If General Options are not available, skip remaining DSDIAG tests IF NOT SCAN_SCREEN "General Options" THEN GOTO DSDIAG_EXIT // UP put bar at Report File: option / ENTER open Report File Option dialog box KEYIN UP ENTER // Check and set options, as needed IF SCAN_SCREEN "Disabled" // ENTER changes Disabled to Enabled, // opens Report File Options dialog, & // puts cursor at File Name prompt KEYIN ENTER ELSEIF SCAN_SCREEN "Enabled" // DOWN puts cursor at File Name prompt KEYIN DOWN ENDIF // Temp report file name and ENTER to accept KEYIN "SYS:SYSTEM\DSDIAG_T.LOG" ENTER // Give it time to process SLEEP 1 // Verify Overwrite mode IF SCAN_SCREEN "Append" // ENTER change mode then go to next prompt KEYIN ENTER ELSE // Go to next prompt KEYIN DOWN ENDIF // Verify Report format IF SCAN_SCREEN "File Format: Data" // ENTER change format then go to next prompt KEYIN ENTER ENDIF // Verify desired options IF NOT SCAN_SCREEN "File Format: Report" OR NOT SCAN_SCREEN "Overwrite" // Report the status WRITE. WRITE Error: Unable to set Report File Options! WRITE. // Set ERROR flag DEFINE %0 ERROR ENDIF // If unable to set desired options, skip remaining DSDIAG tests IF "%0"=="ERROR" THEN GOTO DSDIAG_EXIT // Accept the changes made KEYIN F10 // Verify return to the General Options menu IF NOT SCAN_SCREEN "General Options" // Report the status WRITE. WRITE Error: Did not return to General Options menu! WRITE. ENDIF // If unable to get to desired menu, skip remaining DSDIAG tests IF NOT SCAN_SCREEN "General Options" THEN GOTO DSDIAG_EXIT // Generate the report KEYIN F10 // Timeout (secs) DEFINE %0 300 // WHILE/LOOP to await completion of DSDIAG processing WHILE NOT SCAN_SCREEN "Report is complete" AND "%0">"000" // Give it time to process SLEEP 1 // Dec timeout DEFINE %0 %0-=001 LOOP IF "%0"<="000" // Report the status WRITE. WRITE Error: Timeout occurred prior to Check Server Time completion! WRITE. WRITE Will attempt to scan for errors. Status uncertain due to timeout. WRITE If this error appears periodically, the timeout may need to be WRITE increased to accomodate for Network size or WAN latency factors. WRITE. // Try to stop report KEYIN ESC // Give it time to process SLEEP 15 // Check for Stop the report prompt IF SCAN_SCREEN "Select Stop" THEN KEYIN "Y" ENTER ELSE // Press any key to continue (ESC) KEYIN ESC ENDIF // Check for and follow prompts for proper backout IF SCAN_SCREEN "General Options" THEN KEYIN ESC IF SCAN_SCREEN "Exit this report" THEN KEYIN "Y" ENTER // Check if in a state to continue IF NOT SCAN_SCREEN "Report Generation" // Report the status WRITE. WRITE Error: DSDiag not in a state to allow scanning for errors. WRITE Check DSDIAG NLM status after reviewing the reports. WRITE. ENDIF // Unable to reach a state to continue IF NOT SCAN_SCREEN "Report Generation" THEN GOTO DSDIAG_EXIT // Open the DSDIAG log to scan for errors OPEN_READ SYS:\SYSTEM\DSDIAG_T.LOG IF ERRORLEVEL // Report the status WRITE. WRITE Error: Unable to open SYS:\SYSTEM\DSDIAG_T.LOG! WRITE. // Set ERROR flag DEFINE %0 ERROR ENDIF // If ERROR, try next test IF "%0"=="ERROR" THEN GOTO DSDIAG_P // Report the status WRITE Scanning SYS:\SYSTEM\DSDIAG_T.LOG for possible errors... // Errors for this test DEFINE %7 0 // Scan the DSDIAG log for errors WHILE // READ next record - ERRORLEVEL = EOF READ %1 IF ERRORLEVEL THEN BREAK // CONTINUE if NULL ("") record IF "%1"=="" THEN CONTINUE // Copy %1 data to %2 DEFINE %2 %1 // Convert to UPPERCASE for scan test TOUPPER %2 // Scan for known error strings // Replace " with ` in %2 to avoid parsing errors with SCAN_STRING REPLACE %2 ""`" IF SCAN_STRING "STATUS" "%2" AND SCAN_STRING "TIME" "%2" // Read next line (second line of header) READ %2 // ERRRORLEVEL = End Of File (EOF) IF ERRORLEVEL THEN BREAK // Resume scan if NULL ("") record IF "%2"=="" THEN CONTINUE WHILE // Read next record READ %3 // ERRRORLEVEL = End Of File (EOF) IF ERRORLEVEL THEN BREAK // Resume scan if NULL ("") record IF "%3"=="" THEN BREAK // Replace " with ` in %3 to avoid parsing errors with SCAN_STRING REPLACE %3 ""`" // Scan for success IF SCAN_STRING " Yes" "%3" THEN CONTINUE IF SCAN_STRING " YES" "%3" THEN CONTINUE // If first error, write a header IF %7==0 WRITE. WRITE Possible DSDIAG (Check Server Time) error(s) detected: WRITE ====================================================== ENDIF // Inc error count DEFINE %7 %7+=1 // If first Server Time error entry (valid headers) IF NOT "%1"=="" WRITE %1 WRITE %2 // Clear headers DEFINE %1 DEFINE %2 ENDIF // Record the error WRITE %3 LOOP ENDIF // Scan for known error summary strings IF NOT SCAN_STRING "COUNT" "%2" THEN CONTINUE IF NOT SCAN_STRING "ERRO" "%2" AND NOT SCAN_STRING "WARN" "%2" THEN CONTINUE // If first error, write a header IF %7==0 WRITE. WRITE Possible DSDIAG (Check Server Time) error(s) detected: WRITE ====================================================== ENDIF // Inc error count DEFINE %7 %7+=1 // Write error summary header WRITE %1 // Write error information WHILE // READ next record - ERRORLEVEL = EOF READ %1 IF ERRORLEVEL THEN BREAK // NULL record indicates end of error info IF "%1"=="" THEN BREAK // Record the error information WRITE %1 LOOP // Resume the WHILE/LOOP processing LOOP // Report the status IF %7>0 WRITE. WRITE ??? %7 possible problem(s) - Review SYS:\SYSTEM\DSDIAG_T.LOG ??? WRITE. // Add temporary error count to total error count DEFINE %8 %8+=%7 ELSE WRITE No potential problems were detected in SYS:\SYSTEM\DSDIAG_T.LOG! ENDIF // Report the status WRITE %DAY% %MONTH_NAME% %YEAR% @ %HOUR%:%MINUTE%%AM_PM% - DSDIAG (Check Server Time) Complete. WRITE. WRITE. WRITE -------------------------------------------------------------------------- WRITE. WRITE. :DSDIAG_P // Report the status WRITE %DAY% %MONTH_NAME% %YEAR% @ %HOUR%:%MINUTE%%AM_PM% - Starting DSDIAG (Check Partition Status). // Is desired option in Report Generation menu? IF NOT SCAN_SCREEN "Check Partition Status" // Report the status WRITE. WRITE Error: 'Check Partition Status' menu option not shown! WRITE. ENDIF // If Check Partition Status option not available, skip to next test IF NOT SCAN_SCREEN "Check Partition Status" THEN GOTO DSDIAG_EXIT // Hilite Menu choice by typing unique portion (Check Part), ENTER to select KEYIN "Check Part" ENTER // Check for the proper dialog box IF NOT SCAN_SCREEN "General Options" // Report the status WRITE. WRITE Error: Unable to activate General Options dialog! WRITE. ENDIF // If General Options are not available, skip remaining DSDIAG tests IF NOT SCAN_SCREEN "General Options" THEN GOTO DSDIAG_EXIT // UP put bar at Report File: option / ENTER open Report File Option dialog box KEYIN UP ENTER // Check and set options, as needed IF SCAN_SCREEN "Disabled" // ENTER changes Disabled to Enabled, // opens Report File Options dialog, & // puts cursor at File Name prompt KEYIN ENTER ELSEIF SCAN_SCREEN "Enabled" // DOWN puts cursor at File Name prompt KEYIN DOWN ENDIF // Temp report file name and ENTER to accept KEYIN "SYS:SYSTEM\DSDIAG_P.LOG" ENTER // Give it time to process SLEEP 1 // Verify Overwrite mode IF SCAN_SCREEN "Append" // ENTER change mode then go to next prompt KEYIN ENTER ELSE // Go to next prompt KEYIN DOWN ENDIF // Verify Report format IF SCAN_SCREEN "File Format: Data" // ENTER change format then go to next prompt KEYIN ENTER ENDIF // Verify desired options IF NOT SCAN_SCREEN "File Format: Report" OR NOT SCAN_SCREEN "Overwrite" // Report the status WRITE. WRITE Error: Unable to set Report File Options! WRITE. // Set ERROR flag DEFINE %0 ERROR ENDIF // If unable to set desired options, skip remaining DSDIAG tests IF "%0"=="ERROR" THEN GOTO DSDIAG_EXIT // Accept the changes made KEYIN F10 // Verify return to the General Options menu IF NOT SCAN_SCREEN "General Options" // Report the status WRITE. WRITE Error: Did not return to General Options menu! WRITE. ENDIF // If unable to get to desired menu, skip remaining DSDIAG tests IF NOT SCAN_SCREEN "General Options" THEN GOTO DSDIAG_EXIT // Generate the report KEYIN F10 // Timeout (secs) DEFINE %0 300 // WHILE/LOOP to await completion of DSDIAG processing WHILE NOT SCAN_SCREEN "Report is complete" AND "%0">"000" // Give it time to process SLEEP 1 // Dec timeout DEFINE %0 %0-=001 LOOP IF "%0"<="000" // Report the status WRITE. WRITE Error: Timeout occurred prior to Check Partition Status completion! WRITE. WRITE Will attempt to scan for errors. Status uncertain due to timeout. WRITE If this error appears periodically, the timeout may need to be WRITE increased to accomodate for Network size or WAN latency factors. WRITE. // Try to stop report KEYIN ESC // Give it time to process SLEEP 15 // Check for Stop the report prompt IF SCAN_SCREEN "Select Stop" THEN KEYIN "Y" ENTER ELSE // Press any key to continue (ESC) KEYIN ESC ENDIF // Check for and follow prompts for proper backout IF SCAN_SCREEN "General Options" THEN KEYIN ESC IF SCAN_SCREEN "Exit this report" THEN KEYIN "Y" ENTER // Check if in a state to continue IF NOT SCAN_SCREEN "Report Generation" // Report the status WRITE. WRITE Error: DSDiag not in a state to allow scanning for errors. WRITE Check DSDIAG NLM status after reviewing the reports. WRITE. ENDIF // Unable to reach a state to continue IF NOT SCAN_SCREEN "Report Generation" THEN GOTO DSDIAG_EXIT // Open the DSDIAG log to scan for errors OPEN_READ SYS:\SYSTEM\DSDIAG_P.LOG IF ERRORLEVEL // Report the status WRITE. WRITE Error: Unable to open SYS:\SYSTEM\DSDIAG_P.LOG! WRITE. // Set ERROR flag DEFINE %0 ERROR ENDIF // If ERROR, try next test IF "%0"=="ERROR" THEN GOTO DSDIAG_EXIT // Report the status WRITE Scanning SYS:\SYSTEM\DSDIAG_P.LOG for possible errors... // Errors for this test DEFINE %7 0 // Scan the DSDIAG log for errors WHILE // READ next record - ERRORLEVEL = EOF READ %1 IF ERRORLEVEL THEN BREAK // CONTINUE if NULL ("") record IF "%1"=="" THEN CONTINUE // Copy %1 data to %2 DEFINE %2 %1 // Convert to UPPERCASE for scan test TOUPPER %2 // Replace " with ` in %2 to avoid parsing errors with SCAN_STRING REPLACE %2 ""`" // Scan for 'Replica Synchronization Summary' string IF SCAN_STRING "REPLICA S" "%2" AND SCAN_STRING "N SUMMARY" "%2" // Record the 'Replica Synchronization Summary' WHILE // Record the (unmodified) READ data WRITE %1 // Read the next line READ %1 // ERRRORLEVEL = End Of File (EOF) IF ERRORLEVEL THEN BREAK // Summary complete if NULL ("") record IF "%2"=="" THEN BREAK LOOP // Resume scan of log data CONTINUE ENDIF // Scan for known error summary strings IF NOT SCAN_STRING "COUNT" "%2" THEN CONTINUE IF NOT SCAN_STRING "ERRO" "%2" AND NOT SCAN_STRING "WARN" "%2" THEN CONTINUE // If first error, write a header IF %7==0 WRITE. WRITE Possible DSDIAG (Check Partition Status) error(s) detected: WRITE =========================================================== ENDIF // Inc error count DEFINE %7 %7+=1 // Write error summary header WRITE %1 // Write error information WHILE // READ next record - ERRORLEVEL = EOF READ %1 IF ERRORLEVEL THEN BREAK // NULL record indicates end of error info IF "%1"=="" THEN BREAK // Record the error information WRITE %1 LOOP // Resume the WHILE/LOOP processing LOOP // Report the status IF %7>0 WRITE. WRITE ??? %7 possible problem(s) - Review SYS:\SYSTEM\DSDIAG_P.LOG ??? WRITE. // Add temporary error count to total error count DEFINE %8 %8+=%7 ELSE WRITE No potential problems were detected in SYS:\SYSTEM\DSDIAG_P.LOG! ENDIF // Report the status WRITE %DAY% %MONTH_NAME% %YEAR% @ %HOUR%:%MINUTE%%AM_PM% - DSDIAG (Check Partition Status) Complete. WRITE. WRITE. WRITE -------------------------------------------------------------------------- WRITE. WRITE. :DSDIAG_EXIT // Press Alt-F10 for the Quick Exit IF SCAN_SCREEN "Alt+F10" THEN KEYIN ALT-F10 // Press 'Y' to select Yes to confirm exit then ENTER IF SCAN_SCREEN "Yes" THEN KEYIN "Y" ENTER // Give it a second to respond SLEEP 1 // Check if DSDIAG still loaded. If so, try to unload it manually. IF LOADED DSDIAG.NLM // Try to manually unload it UNLOAD DSDIAG // Timeout (secs) DEFINE %0 15 // WHILE/LOOP to await completion of DSDIAG processing WHILE LOADED DSDIAG.NLM AND "%0">"00" // Give it time to process SLEEP 1 // Dec timeout count DEFINE %0 %0-=001 LOOP ENDIF :DSREPAIR // If 0 errors, GOTO EOJ IF %8==0 THEN GOTO EOJ // Set %7 to signal early exit DEFINE %7 ERROR // Check if DSREPAIR.NLM is loaded and unload it IF LOADED DSREPAIR.NLM UNLOAD DSREPAIR.NLM // Timeout (secs) DEFINE %0 15 // WHILE/LOOP to await the unloading of DSREPAIR WHILE LOADED DSREPAIR.NLM AND "%0">"00" // Give it time to process SLEEP 1 // Dec timeout count DEFINE %0 %0-=001 LOOP ENDIF // Re-check if DSREPAIR.NLM is loaded IF LOADED DSREPAIR.NLM // Report the status WRITE. WRITE Error: Unable to unload DSREPAIR! WRITE. ENDIF // If unable to unload, exit IF LOADED DSREPAIR.NLM THEN GOTO EOJ // If DSREPAIR.NLM output log exists, delete it (or rename or copy elsewhere) IF EXISTS SYS:\SYSTEM\DSREPAIR.LOG THEN DELETE SYS:\SYSTEM\DSREPAIR.LOG // Record status WRITE %DAY% %MONTH_NAME% %YEAR% @ %HOUR%:%MINUTE%%AM_PM% - Starting DS Repair... // Load DSREPAIR -U to perform an Unattended Full Repair LOAD DSREPAIR -U // Timeout (secs) DEFINE %0 15 // WHILE/LOOP to await completion of DSREPAIR processing WHILE NOT LOADED DSREPAIR.NLM AND "%0">"00" // Give it time to process SLEEP 1 // Dec timeout count DEFINE %0 %0-=001 LOOP IF NOT LOADED DSREPAIR.NLM AND NOT EXIST SYS:SYSTEM\DSREPAIR.LOG // Report the status WRITE. WRITE Error: Unable to load DSREPAIR -U WRITE. ENDIF // If unable to load DSREPAIR, exit IF NOT LOADED DSREPAIR.NLM AND NOT EXIST SYS:SYSTEM\DSREPAIR.LOG THEN GOTO EOJ // Timeout (secs) DEFINE %0 300 // WHILE/LOOP to await completion of DSREPAIR processing WHILE LOADED DSREPAIR.NLM AND "%0">"000" // Give it time to process SLEEP 1 // Dec timeout count DEFINE %0 %0-=001 LOOP // If timeout (DSREPAIR still loaded), check for problems or increase timeout IF LOADED DSREPAIR.NLM // Report the status WRITE. WRITE Error: Timeout occurred prior to DSREPAIR -U completion! WRITE. WRITE If this error appears periodically, the timeout may need to be WRITE increased to accomodate for Network size or WAN latency factors. WRITE. ENDIF // If still loaded DSREPAIR, exit IF LOADED DSREPAIR.NLM THEN EOJ // Open the DSREPAIR log file to scan for errors OPEN_READ SYS:\SYSTEM\DSREPAIR.LOG IF ERRORLEVEL // Report the status WRITE. WRITE Error: Unable to open SYS:\SYSTEM\DSREPAIR.LOG! WRITE. // Set ERROR flag DEFINE %0 ERROR ENDIF // If ERROR, exit IF "%0"=="ERROR" THEN GOTO EOJ // Report the status WRITE Scanning SYS:\SYSTEM\DSREPAIR.LOG log for possible errors... // Errors for this test DEFINE %7 0 // Scan the DSREPAIR log for errors WHILE // READ next record - ERRORLEVEL = EOF READ %1 IF ERRORLEVEL THEN BREAK // CONTINUE if NULL ("") record IF "%1"=="" THEN CONTINUE // Copy %1 data to %2 DEFINE %2 %1 // Convert to UPPERCASE for scan test TOUPPER %2 // Replace " with ` in %2 to avoid parsing errors with SCAN_STRING REPLACE %2 ""`" // Scan for known error strings (clear %2 on match) IF SCAN_STRING "ABORT" "%2" THEN DEFINE %2 IF SCAN_STRING "ERROR:" "%2" THEN DEFINE %2 IF SCAN_STRING "YOU MAY NEED" "%2" THEN DEFINE %2 // If %2 has data (no match) then CONTINUE IF NOT "%2"=="" THEN CONTINUE // Check if first error and write header IF %7==0 WRITE. WRITE Possible DS Repair error(s) detected: WRITE ===================================== ENDIF // Log the error WRITE %1 // Replace " with ` in %1 to avoid parsing errors with SCAN_STRING REPLACE %1 ""`" // Check if supplemental ERROR message (log but only count ERROR messages) IF SCAN_STRING "You may need" "%1" // READ/WRITE next info record READ %1 WRITE %1 ELSE // Inc error count DEFINE %7 %7+=1 ENDIF LOOP // Report the status IF %7>0 WRITE. WRITE ??? %7 possible error(s) - Review SYS:\SYSTEM\DSREPAIR.LOG ??? WRITE. ELSE WRITE No DS Repair problems were detected! ENDIF // Record status WRITE %DAY% %MONTH_NAME% %YEAR% @ %HOUR%:%MINUTE%%AM_PM% - Finished DS Repair... WRITE. WRITE. WRITE -------------------------------------------------------------------------- WRITE. WRITE. :EOJ WRITE Summary: WRITE. // Record status IF "%7"=="ERROR" WRITE %8 possible problem(s) detected during NDS Health Check... WRITE Error(s) encountered running DSREPAIR. Problems unresolved... ELSEIF "%8">"0" WRITE %8 possible problem(s) reported by NDS Health Check... WRITE %7 possible problem(s) reported by unattended DSRepair... ELSE WRITE Finished DSHealth (basic NDS Health Check) - No problems detected. ENDIF // Record trailing record and close the output log before exiting WRITE. CLOSE // Reset the active screen to TMConsole (Shell) screen (or other desired screen) CHANGE_SCREEN "TMConsole (Shell)"