# Class Stats

java.lang.Object
org.apache.jmeter.monitor.util.Stats

public class Stats extends Object
Description:

Stats is responsible for calculating the load and health of a given server. It uses tomcat's status servlet results. A schema was generated for the XML output and JAXB was used to generate classes.

The equations are:

memory weight = (int)(50 * (free/max))
thread weight = (int)(50 * (current/max))

The load factors are stored in the properties files. Simply change the values in the properties to change how load is calculated. The defaults values are memory (50) and threads (50). The sum of the factors must equal 100.

## Field Summary

Fields
Modifier and Type
Field
Description
`static final int`
`ACTIVE`
`static final double`
`ACTIVE_PER`
`static final int`
`DEAD`
`static final int`
`DEFAULT_MEMORY_FACTOR`
`static final int`
`DEFAULT_THREAD_FACTOR`
`static final int`
`HEALTHY`
`static final double`
`HEALTHY_PER`
`static final int`
`WARNING`
`static final double`
`WARNING_PER`

## Constructor Summary

Constructors
Constructor
Description
`Stats()`

## Method Summary

Modifier and Type
Method
Description
`static int`
`calculateLoad(Status stat)`
The method is responsible for taking a status object and calculating an int value from 1 to 100.
`static int`
`calculateMemoryLoad(Status stat)`
Method will calculate the memory load: used / max = load.
`static int`
`calculateStatus(Status stat)`
Method should calculate if the server is: dead, active, warning or healthy.
`static int`
`calculateThreadLoad(Status stat)`
Method will calculate the thread load: busy / max = load.

### Methods inherited from class Object

`clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

## Field Details

### DEAD

public static final int DEAD

See Also:
  - Constant Field Values

### ACTIVE

public static final int ACTIVE

See Also:
  - Constant Field Values

### WARNING

public static final int WARNING

See Also:
  - Constant Field Values

### HEALTHY

public static final int HEALTHY

See Also:
  - Constant Field Values

### DEFAULT_MEMORY_FACTOR

public static final int DEFAULT_MEMORY_FACTOR

See Also:
  - Constant Field Values

### DEFAULT_THREAD_FACTOR

public static final int DEFAULT_THREAD_FACTOR

See Also:
  - Constant Field Values

### HEALTHY_PER

public static final double HEALTHY_PER

See Also:
  - Constant Field Values

### ACTIVE_PER

public static final double ACTIVE_PER

See Also:
  - Constant Field Values

### WARNING_PER

public static final double WARNING_PER

See Also:
  - Constant Field Values

## Constructor Details

### Stats

public Stats()

## Method Details

### calculateLoad

public static int calculateLoad(Status stat)
The method is responsible for taking a status object and calculating an int value from 1 to 100. We use a combination of free memory and free threads. The current factor is 50/50.

Parameters:
  `stat` - status information about the server
Returns:
  calculated load value

### calculateStatus

public static int calculateStatus(Status stat)
Method should calculate if the server is: dead, active, warning or healthy. We do this by looking at the current busy threads.

1. free > spare is `healthy`
2. free < spare is `active`
3. busy threads > 75% is `warning`
4. none of the above is `dead`

Parameters:
  `stat` - status information about the server
Returns:
  integer representing the status (one of `HEALTHY`, `ACTIVE`, `WARNING` or `DEAD`)

### calculateMemoryLoad

public static int calculateMemoryLoad(Status stat)
Method will calculate the memory load: used / max = load. The load value is an integer between 1 and 100. It is the percent memory used. Changed this to be more like other system monitors. Peter Lin 2-11-05

Parameters:
  `stat` - status information about the jvm
Returns:
  memory load

### calculateThreadLoad

public static int calculateThreadLoad(Status stat)
Method will calculate the thread load: busy / max = load. The value is an integer between 1 and 100. It is the percent busy.

Parameters:
  `stat` - status information about the server
Returns:
  thread load