///////////////////////////////////////////////////////////////////////// // // This task does a cursory check of some supported System Environment // variables towards checking the Server's status. It can be launched // periodically as a reporting mechanism or as a result of being spawned // by some other network management product. // ///////////////////////////////////////////////////////////////////////// // First, let's open a file to log anything we find into. OPEN_WRITE SYS:SYSTEM\SRVRALRT.LOG // Check if 90% or more of the max allowed conns (%CONNS_MAX%) are in use // First, set Dynamic System Environment Variable %1 to the appropriate // format (same number of digits for both sides of the comparison) // This is done by setting %1 to the value to be compared then using // CALC to re-define the value of %1 (subtract 10% from the max) // Note: CALC respects/re-uses the pre-defined format of %1 DEFINE %1 %CONNS_IN_USE% CALC %1 %CONNS_MAX% - (%CONNS_MAX% / 10) // Then check this value against the currently active conns (%CONNS_IN_USE%) IF %CONNS_IN_USE%>=%1 WRITE %DAY_OF_WEEK%, %MONTH_NAME% %DAY% at %HOUR%:%MINUTE%%AM_PM% WRITE Conns = %CONNS_IN_USE% WRITE Clearing the NOT_LOGGED_IN connections to free slots! WRITE // If SUPERVISOR is logged in send a 25th line message IF LOGGED_IN SUPERVISOR SEND "Conns reaching Max - Clearing NOT_LOGGED_IN conns!" TO SUPERVISOR ENDIF // Call NLICLEAR.TSK which clears all NOT-LOGGED-IN connections CALL NLICLEAR.TSK ENDIF // Check if the CPU Utilization is above an acceptable level. // If so, various actions can be taken, including unloading NLMs. IF %CPU_UTIL%>075 // First, we will call another .TSK to takes snapshots of processor util. CALL PROCUTIL.TSK WRITE %DAY_OF_WEEK%, %MONTH_NAME% %DAY% at %HOUR%:%MINUTE%%AM_PM% WRITE CPU Utilization = %CPU_UTIL% WRITE Unloading non-critical NLMs to see if that helps! WRITE // If SUPERVISOR is logged in send a 25th line message IF LOGGED_IN SUPERVISOR SEND "CPU Util @ %CPU_UTIL% - Unloading some NLMs!" TO SUPERVISOR ENDIF // At this point, you could unload some non-critical NLMs. IF LOADED DUMMY.NLM // UNLOAD DUMMY ENDIF ENDIF // Check if the allocated Packet Receive Buffers (%RECV_BUFFS_IN_USE%) // are within 10 of maximum Packet Receive Buffers (%RECV_BUFFS_MAX%) // First, set Dynamic System Environment Variable %1 to the appropriate // format (same number of digits for both sides of the comparison) // This is done by setting %1 to the value to be compared then using // CALC to re-define the value of %1 (add 10 to the current value) // Note: CALC respects/re-uses the pre-defined format of %1 DEFINE %1 %RECV_BUFFS_MAX% CALC %1 %RECV_BUFFS_IN_USE% + 10 // Then check this value against the maximum PRBs value IF %1>=%RECV_BUFFS_MAX% WRITE %DAY_OF_WEEK%, %MONTH_NAME% %DAY% at %HOUR%:%MINUTE%%AM_PM% WRITE Recv Buffs = %RECV_BUFFS_IN_USE%, Max Recv Buffs = %RECV_BUFFS_MAX% WRITE Increasing the Maximum Packet Receive Buffers SET parameter by 10 WRITE // If SUPERVISOR is logged in send a 25th line message IF LOGGED_IN SUPERVISOR SEND "Low on Recv Buffs, increased Max by 10" TO SUPERVISOR ENDIF // The following uses the standard console SET command with the // substitution of the current Max level increased by 10. CALC %1 %RECV_BUFFS_MAX% + 10 SET MAXIMUM PACKET RECEIVE BUFFERS = %1 // The following uses a standard console command to reset the // routing information used by the server. On occasion, routing // packets can be the cause of receive buffer congestion. RESET ROUTER ENDIF // Check SYS: volume to see if we need to off-load files to free space CD SYS:\ IF %VOL_FREE%<=010 WRITE %DAY_OF_WEEK%, %MONTH_NAME% %DAY% at %HOUR%:%MINUTE%%AM_PM% WRITE Volume: %VOL_NAME% at %VOL_USED%% of capacity WRITE Off-loading non-critical files to BACKUP: volume WRITE // Send every attached user the following message BROADCAST "SYS: is low on space - Be sure to back up your work" // Check if BACKUP: is mounted - If not, MOUNT BACKUP: IF NOT MOUNTED BACKUP: MOUNT BACKUP: ENDIF // Open the argument file containing the source and dest name // of each file which can be moved in an emergency. // Example: SYS:\DATABASE\DATAFILE.BAK BACKUP:\DATABASE\DATAFILE.BAK IF EXIST SYS:SYSTEM\MOVEFILE.DAT OPEN_READ SYS:SYSTEM\MOVEFILE.DAT WHILE // If there is a read error, such as an End-Of-File, break // out of this WHILE/LOOP READ %0 IF ERRORLEVEL THEN BREAK // The following line takes advantage of a unique aspect in // EXIST - that it only searches for the first specification. // Therefore, even though two files are part of the %0 variable // record read from MOVEFILE.DAT, only the first file name is // checked for existence. // If the first file exists then the COPY command is executed IF EXIST %0 THEN COPY %0 // If the COPY succeeds then DELETE the first file specification. // Again, the logic depends upon a unique aspect of the DELETE // command in that it will only process the first file name. IF NOT ERRORLEVEL THEN DELETE %0 // If the DELETE succeeds then PURGE the first file specification // to free the disk space for immediate re-use. // Again, the logic depends upon a unique aspect of the PURGE // command in that it will only process the first file name. IF NOT ERRORLEVEL THEN PURGE %0 LOOP ENDIF ENDIF // CLOSE any open files before exiting (not required, just proper cleanup). CLOSE