//============================================================================= // // Task: WEBFSCON.TSK // (Generates an .HTML page with Server Connection information/graphs) // Author: Avanti Technology, Inc. // http://www.avanti-tech.com // Version: 1.0 - Initial Release // (15 March 2005) // // Description: // ============ // Generates an .HTML page showing Server Connection information with // simple graphs, automatically updated every minute, for any NetWare // v3.12 (or later) Server (does not require WEB Server software or IP). // The task runs continuously, updating the WEBFSCON.HTML Page every // minute, until the task is terminated or TaskMaster is unloaded. // // This use of colors is intended to provide quick information at a glance. // // The WEBFSCON.HTML file can be directed to any directory on the Server, // including the SYS:LOGIN directory, thus allowing general access to // Server Status information by any network user able to attach to the // Server (no Login required). For Servers with WEB Server software // loaded or with directories accessible via generic IP means, the // file can be directed to any directory that allows sufficient access. // // Objective: // ========== // Provide general access to generic Server Connection information without // concerns for security or account management. // // Usage: // ====== // Script can be manually executed using the TaskMaster TMRUN command // at the TMConsole (Shell) Screen: // // Example: TMRUN [vol:path\]WEBFSCON.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 WEBFSCON.TSK 01 02:00 // (Executes the 1st of each month at 2:00am) // // TMSCHEDULE ADD WEBFSCON.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. // // Note: Logic has been incorporated to avoid multiple concurrent executions. // Therefore, it can be scheduled as frequently as desired to insure // continuous operation. // // Compatibility: // ============== // This task has been tested on the following platforms without demonstrating // any compatibility issues or any other reported/confirmed conflicts: // TaskMaster v3.13 (or later), TaskMaster Lite v3.15 (or later) // NetWare v3.12 / v3.2 / 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: // ========= // This task script is provided free of charge and without any warranty or // guarantee of fitness of purpose or performance. // // For additional TaskMaster script examples, visit the Sample Tasks page // on the Avanti Technology, Inc. WEB Site: http://www.avanti-tech.com // // Note: The .HTML output is designed so that the page will automatically // refresh (reload) approximately once per minute, in support of the // sample task design which re-cycles (re-executes) the task and // generates an updated .HTML page of information every minute. // // To remove the refresh cycle, delete the following line from the task: // WRITE // // Note: Search for {MODIFY} comments indicating items which need // to be modified or renamed (as appropriate). // //============================================================================= // Check that the version of TaskMaster loaded is compatible (3.13 or later) IF "%TM_VERSION%.%TM_SUBVERSION%"<"3.16" // Echo the problem message to the screen ECHO. ECHO Error: Incompatible TaskMaster release (requires v3.16 or later)! ECHO. ABORT ENDIF // Check if already active. Terminate this copy if already active. IF ACTIVE_TASK %TASK% ECHO. ECHO %TASK%: Already active! Terminating... ECHO. EXIT ENDIF // Set %0 for use as OPEN_WRITE error counter // Note: Must also be reset before restart (i.e., goto START) DEFINE %0 0 :START // {MODIFY} Destination (output) HTML file // Create the output HTML page (TRUNCATE overwrites an existing copy) OPEN_WRITE SYS:LOGIN\webfscon.html TRUNCATE // Check for error (WEB browser refresh conflict?) and re-try up to 3 times IF ERRORLEVEL IF %0<3 // Increment the error counter and re-try DEFINE %0 %0+=1 goto START ENDIF ECHO. ECHO %TASK%: Unable to create/open OPEN_WRITE file for .HTML output... ECHO Check file status and re-start task. ECHO. ABORT ENDIF // Output basic HTML template WRITE WRITE WRITE WRITE %SERVER%: Status Page WRITE WRITE WRITE WRITE WRITE // Output Server Connection information WRITE
WRITE WRITE %DAY_OF_WEEK%, %MONTH_NAME% %DAY%, %YEAR%
IF %HOUR24%>12 DEFINE %1 (%HOUR24%:%MINUTE%:%SECOND%) ELSE DEFINE %1 ENDIF WRITE %HOUR%:%MINUTE%:%SECOND%%AM_PM% %1
WRITE
WRITE

WRITE %SERVER%
IF "%NW_SUPPORTPACK%">"" WRITE (NetWare v%NW_VERSION%.%NW_SUBVERSION% %NW_SUPPORTPACK%) ELSE WRITE (NetWare v%NW_VERSION%.%NW_SUBVERSION%) ENDIF WRITE

:STAT_TABLE WRITE

WRITE WRITE WRITE WRITE WRITE WRITE WRITE WRITE WRITE WRITE WRITE WRITE IF SCREEN_LOCKED DEFINE %1 [Locked] ELSE DEFINE %1 ENDIF WRITE WRITE WRITE WRITE WRITE
WRITE Up-Time: WRITE WRITE     WRITE %UPTIME_STRING% WRITE
WRITE Cache LRU: WRITE WRITE     WRITE %CACHE_LRU_STRING% WRITE
WRITE
WRITE
WRITE Active Screen: WRITE WRITE     WRITE %SCREEN_NAME% %1 WRITE
WRITE
WRITE

WRITE

WRITE // ROW: Table Headings WRITE WRITE WRITE WRITE WRITE // ROW: Licenses // Note: Only applies to NetWare v4+ (each NWv3 conn equals a license) IF %NW_VERSION%>3 // Pre-format %3 for fixed 3 digit result DEFINE %3 000 // Determine the % of Licenses In Use (MLA returns -1 value) IF "%LICENSES_MAX%">"0000" CALC %3 (%LICENSES_IN_USE% * 100) / %LICENSES_MAX% ENDIF // Set the text/graph color by value (0-75=Green, 76-89=Yellow, 90+=Red) IF %3<=075 DEFINE %0 green ELSEIF %3>=090 DEFINE %0 red ELSE DEFINE %0 yellow ENDIF // This logic trick strips the leading zeros from fixed format fields DEFINE %1 0+=%LICENSES_IN_USE% IF NOT "%LICENSES_MAX%"=="-1" DEFINE %2 0+=%LICENSES_MAX% ELSE DEFINE %2 MLA ENDIF DEFINE %4 100-=%3 WRITE WRITE WRITE WRITE WRITE ENDIF // ROW: Connections // Pre-format %3 for fixed 3 digit result DEFINE %3 000 IF %NW_VERSION%==3 // Determine the % of Connections (i.e., Licenses) In Use CALC %3 (%CONNS_IN_USE% * 100) / %CONNS_MAX% // Set the text/graph color by value (0-75=Green, 76-89=Yellow, 90+=Red) IF %3<=075 DEFINE %0 green ELSEIF %3>=090 DEFINE %0 red ELSE DEFINE %0 yellow ENDIF ELSE DEFINE %0 green ENDIF // This logic trick strips the leading zeros from fixed format fields DEFINE %1 0+=%CONNS_IN_USE% DEFINE %4 100-=%3 WRITE WRITE WRITE WRITE WRITE WRITE
WRITE   Statistic WRITE WRITE Current WRITE WRITE WRITE WRITE
0% WRITE Graph100% WRITE
WRITE
WRITE   Licenses WRITE WRITE %1 / %2 WRITE WRITE IF %3>000 WRITE ENDIF IF %4>000 WRITE ENDIF WRITE
WRITE
WRITE
WRITE
WRITE
WRITE
WRITE   Connections WRITE WRITE %1 // For NetWare v3, Max Conns is important (though irrelevant for NWv4+) IF %NW_VERSION%==3 DEFINE %2 0+=%CONNS_MAX% WRITE / %2 ENDIF WRITE WRITE IF %3>000 WRITE ENDIF IF %4>000 WRITE ENDIF WRITE
WRITE
WRITE
WRITE
WRITE
WRITE
WRITE
WRITE

WRITE

WRITE // ROW: Table Headings WRITE WRITE WRITE WRITE WRITE WRITE // By redirecting the output from USERLIST to a temporary file, a log of the // active (logged in) Users, listed in Connection order, is generated. // Note: The /A (address) option optionally includes the Connection Address. // // {MODIFY} Specify the destination (temporary file) for the redirected output USERLIST /A >SYS:LOGIN\webfscon.tmp // At this point, the information could be sorted on any of the fields to // change the order output to the .HTML page. // // To list by User Name: // SORT SYS:LOGIN\webfscon.tmp SYS:LOGIN\webfscon.tmp 7-34 // // To list by Login Time: // SORT SYS:LOGIN\webfscon.tmp SYS:LOGIN\webfscon.tmp 60-77 // // To list by Connection Address: // SORT SYS:LOGIN\webfscon.tmp SYS:LOGIN\webfscon.tmp 37-57 // {MODIFY} Read the redirected output from USERLIST (check for errors) OPEN_READ SYS:LOGIN\webfscon.tmp // Check for OPEN_READ errors when attempting to access the temporary file // with the redirected USERLIST data IF ERRORLEVEL WRITE WRITE WRITE goto EOJ ENDIF // Clear READ variable for WHILE/LOOP DEFINE %0 WHILE NOT SCAN_STRING "/" "%0" // READ the first/header record READ %0 // Handle a premature EOF condition (there must be at least 1 active conn) IF ERRORLEVEL WRITE WRITE WRITE BREAK ENDIF LOOP WHILE SCAN_STRING "/" "%0" // ROW: Connection Info (%0) WRITE // Parse and write the Connection Number PARSE %1 %0 1-4 WRITE // Parse and write the Logged In User Name PARSE %1 %0 7-34 WRITE // Parse and write the Logged In Time PARSE %1 %0 60-77 WRITE // Parse and write the Connection Address PARSE %1 %0 37-57 WRITE WRITE // READ next record READ %0 // Check for EOF (i.e., no more records) IF ERRORLEVEL THEN BREAK LOOP WRITE
WRITE   Conn WRITE WRITE   Indentification WRITE WRITE   Login Time WRITE WRITE   Network Address WRITE
WRITE WRITE USERLIST Error: Connection data unavailable WRITE WRITE
WRITE WRITE READ Error: Connection data unavailable WRITE WRITE
WRITE   %1 WRITE WRITE   %1 WRITE WRITE   %1 WRITE WRITE   %1 WRITE
WRITE
// Remove (cleanup) temporary file // {MODIFY} Specify the destination (temporary file) for the redirected output DELETE SYS:LOGIN\webfscon.tmp :EOJ WRITE

WRITE Produced by: %TASK%
WRITE Processed by: TaskMaster v%TM_VERSION%.%TM_SUBVERSION%
WRITE Time Elapsed: %ELAPSED_TIME%
WRITE

WRITE WRITE WRITE WRITE // Close the input/output files CLOSE // Suspec for a second (make sure to pass current second) SLEEP 1 // Continue to suspend for a second until next new minute (i.e., second == 00 ) WHILE %SECOND%>00 SLEEP 1 LOOP GOTO START