getNumScriptsOnStack
int session.getNumScriptsOnStack ( )
Description
Get the number of scripts currently running.
Parameters
This method does not receive any parameters.
Return Values
Returns number of running scripts, as an integer.
Change Log
Version | Description |
---|---|
5.0 | Added for all editions. |
Examples
Check If More Scripts Can Be Run
import java.math.*;
// Get Number of Scripts (running and max)
BigDecimal numRunningScripts = new BigDecimal(session.getNumScriptsOnStack());
BigDecimal maxAllowedScripts = new BigDecimal(session.getMaxScriptsOnStack());
// Calculate percentage used
BigDecimal percentageUsedBD = numRunningScripts.divide(maxAllowedScripts, 2, BigDecimal.ROUND_HALF_UP);
double percentageUsed = percentageUsedBD.doubleValue();
if (percentageUsed < 90)
{
session.log(percentageUsed.toString() + "% of max scripts used");
}
else
{
session.logWarn("90% max scripts threshold has been reached.");
}
// Get Number of Scripts (running and max)
BigDecimal numRunningScripts = new BigDecimal(session.getNumScriptsOnStack());
BigDecimal maxAllowedScripts = new BigDecimal(session.getMaxScriptsOnStack());
// Calculate percentage used
BigDecimal percentageUsedBD = numRunningScripts.divide(maxAllowedScripts, 2, BigDecimal.ROUND_HALF_UP);
double percentageUsed = percentageUsedBD.doubleValue();
if (percentageUsed < 90)
{
session.log(percentageUsed.toString() + "% of max scripts used");
}
else
{
session.logWarn("90% max scripts threshold has been reached.");
}
See Also
- getMaxScriptsOnStack() [session] - Returns the maximum number of scripts that will be allowed on the stack
- setMaxScriptsOnStack() [session] - Sets the maximum number of scripts that will be allowed on the stack
scraper on 07/16/2010 at 5:19 pm
- Printer-friendly version
- Login or register to post comments