jsysmon
Class CPUMonitoringData

java.lang.Object
  extended byjsysmon.CPUMonitoringData

public class CPUMonitoringData
extends java.lang.Object

This class stores monitoring information for the whole system. CPU Usages are provided as a double value between 0.0 and 1.0. If the underlying system cannot provide some information, they are set to 0

Author:
Francois-Xavier Detourniere

Field Summary
static int IDLE_INDEX
          Index of Idle information in returned results
static int IO_INDEX
          Index of IOWait information in returned results
static int IRQ_INDEX
          Index of IRQ information in returned results
static int NB_INDEXES
          Number of indexes available.
static int NICE_INDEX
          Index of Nice information in returned results
static int SOFT_IRQ_INDEX
          Index of Soft IRQ information in returned results
static int STEAL_INDEX
          Index of Steal information in returned results
static int SYSTEM_INDEX
          Index of System information in returned results
static int TOTAL_INDEX
          Index of Aggregated information in returned results The value at this index are compute on recalcTotal call
static int USER_INDEX
          Index of User information in returned results
 
Constructor Summary
CPUMonitoringData(int nbCpus)
          Initializes SystemMonitoringData for given number of CPUs
 
Method Summary
 long getTime(int cpuIndex, int index)
          Returns the CPU time for the specified type and CPU
 long[] getTimes(int cpuIndex)
          Returns all the Times for the given CPU The indexes of the information in the returned array are ones of *_INDEX
 long getTotalTime(int index)
          Returns the Total time for the specified type
 long[] getTotalTimes()
          Returns all the Total Times.
 double getTotalUsage(int index)
          Return the Total CPU Usage for the specified type
 double[] getTotalUsages()
          Returns all the Total Usages The indexes of the information in the returned array are ones of *_INDEX
 double getUsage(int cpuIndex, int index)
          Return the CPU Usage for the specified type and CPU
 double[] getUsages(int cpuIndex)
          Returns all the Usages for a given CPU The indexes of the information in the returned array are ones of *_INDEX
protected  void recalcTotal()
          Recalculate all values at TOTAL_INDEX
 void recalcUsages(CPUMonitoringData previousInfo)
          Recalculates the CPU Usage during time spent since provided information
 java.lang.String toString()
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

USER_INDEX

public static final int USER_INDEX
Index of User information in returned results

See Also:
Constant Field Values

NICE_INDEX

public static final int NICE_INDEX
Index of Nice information in returned results

See Also:
Constant Field Values

SYSTEM_INDEX

public static final int SYSTEM_INDEX
Index of System information in returned results

See Also:
Constant Field Values

IDLE_INDEX

public static final int IDLE_INDEX
Index of Idle information in returned results

See Also:
Constant Field Values

IRQ_INDEX

public static final int IRQ_INDEX
Index of IRQ information in returned results

See Also:
Constant Field Values

SOFT_IRQ_INDEX

public static final int SOFT_IRQ_INDEX
Index of Soft IRQ information in returned results

See Also:
Constant Field Values

STEAL_INDEX

public static final int STEAL_INDEX
Index of Steal information in returned results

See Also:
Constant Field Values

IO_INDEX

public static final int IO_INDEX
Index of IOWait information in returned results

See Also:
Constant Field Values

TOTAL_INDEX

public static final int TOTAL_INDEX
Index of Aggregated information in returned results The value at this index are compute on recalcTotal call

See Also:
Constant Field Values

NB_INDEXES

public static final int NB_INDEXES
Number of indexes available. Keep this value up to date.

See Also:
Constant Field Values
Constructor Detail

CPUMonitoringData

public CPUMonitoringData(int nbCpus)
Initializes SystemMonitoringData for given number of CPUs

Parameters:
nbCpus -
Method Detail

getTotalTime

public long getTotalTime(int index)
Returns the Total time for the specified type

Parameters:
index - One of *_INDEX
Returns:
Corresponding Total time

getTime

public long getTime(int cpuIndex,
                    int index)
Returns the CPU time for the specified type and CPU

Parameters:
cpuIndex - CPU index to consider
index - One of *_INDEX
Returns:
Corresponding time

getTotalUsage

public double getTotalUsage(int index)
Return the Total CPU Usage for the specified type

Parameters:
index - One of *_INDEX
Returns:
Corresponding usage

getUsage

public double getUsage(int cpuIndex,
                       int index)
Return the CPU Usage for the specified type and CPU

Parameters:
cpuIndex - CPU index to consider
index - One of *_INDEX
Returns:
Corresponding usage

getTotalTimes

public long[] getTotalTimes()
Returns all the Total Times. The indexes of the information in the returned array are ones of *_INDEX

Returns:
Array containing the Total Times

getTimes

public long[] getTimes(int cpuIndex)
Returns all the Times for the given CPU The indexes of the information in the returned array are ones of *_INDEX

Parameters:
cpuIndex - CPU Index to consider
Returns:
Array containing the times for the given CPU

getTotalUsages

public double[] getTotalUsages()
Returns all the Total Usages The indexes of the information in the returned array are ones of *_INDEX

Returns:
Array containing Total Usages

getUsages

public double[] getUsages(int cpuIndex)
Returns all the Usages for a given CPU The indexes of the information in the returned array are ones of *_INDEX

Parameters:
cpuIndex - CPU Index to consider
Returns:
Array containing Usages for given CPU

recalcUsages

public void recalcUsages(CPUMonitoringData previousInfo)
Recalculates the CPU Usage during time spent since provided information

Parameters:
previousInfo -

recalcTotal

protected void recalcTotal()
Recalculate all values at TOTAL_INDEX


toString

public java.lang.String toString()