public abstract class AbstractCentralProcessor extends Object implements CentralProcessor
| Modifier and Type | Field and Description |
|---|---|
protected Boolean |
cpu64 |
protected String |
cpuFamily |
protected String |
cpuIdentifier |
protected String |
cpuModel |
protected String |
cpuName |
protected String |
cpuSerialNumber |
protected String |
cpuStepping |
protected String |
cpuVendor |
protected Long |
cpuVendorFreq |
protected long[][] |
curProcTicks |
protected long[] |
curTicks |
protected javax.json.JsonBuilderFactory |
jsonFactory |
protected int |
logicalProcessorCount |
protected int |
physicalProcessorCount |
protected long[][] |
prevProcTicks |
protected long[] |
prevTicks |
protected long |
procTickTime |
protected long |
tickTime |
| Constructor and Description |
|---|
AbstractCentralProcessor()
Create a Processor
|
| Modifier and Type | Method and Description |
|---|---|
protected abstract void |
calculateProcessorCounts()
Updates logical and physical processor counts
|
String |
getFamily() |
String |
getIdentifier()
Identifier, eg.
|
int |
getLogicalProcessorCount()
Get the number of logical CPUs available for processing.
|
String |
getModel() |
String |
getName()
Name, eg.
|
int |
getPhysicalProcessorCount()
Get the number of physical CPUs/cores available for processing.
|
abstract int |
getProcessCount()
Get the number of processes currently running
|
double[] |
getProcessorCpuLoadBetweenTicks()
Returns the "recent cpu usage" for all logical processors by counting
ticks for the processors from
CentralProcessor.getProcessorCpuLoadTicks() between
successive calls of this method, with a minimum interval slightly less
than 1 second. |
abstract long[][] |
getProcessorCpuLoadTicks()
Get Processor CPU Load tick counters.
|
String |
getStepping() |
double |
getSystemCpuLoad()
Returns the "recent cpu usage" for the whole system from
OperatingSystemMXBean.getSystemCpuLoad() if a
user is running the Oracle JVM. |
double |
getSystemCpuLoadBetweenTicks()
Returns the "recent cpu usage" for the whole system by counting ticks
from
CentralProcessor.getSystemCpuLoadTicks() between successive calls of this
method, with a minimum interval slightly less than 1 second. |
abstract long[] |
getSystemCpuLoadTicks()
Get System-wide CPU Load tick counters.
|
abstract long |
getSystemIOWaitTicks()
Get System IOWait tick counters (if available on that Operating System).
|
abstract long[] |
getSystemIrqTicks()
Get System IRQ tick counters (if available on that Operating System).
|
double |
getSystemLoadAverage()
Returns the system load average for the last minute.
|
abstract double[] |
getSystemLoadAverage(int nelem)
Returns the system load average for the number of elements specified, up
to 3, representing 1, 5, and 15 minutes.
|
abstract String |
getSystemSerialNumber()
Get the System/CPU Serial Number, if available.
|
abstract long |
getSystemUptime()
Get the System uptime (time since boot).
|
abstract int |
getThreadCount()
Get the number of threads currently running
|
String |
getVendor()
Processor vendor.
|
long |
getVendorFreq()
Vendor frequency (in Hz), eg.
|
protected void |
initTicks()
Initializes tick arrays
|
boolean |
isCpu64bit()
Is CPU 64bit?
|
void |
setCpu64(boolean value)
Set flag is cpu is 64bit.
|
void |
setFamily(String family) |
void |
setIdentifier(String identifier)
Set processor identifier.
|
void |
setModel(String model) |
void |
setName(String name)
Set processor name.
|
void |
setStepping(String stepping) |
void |
setVendor(String vendor)
Set processor vendor.
|
void |
setVendorFreq(long freq)
Set processor vendor frequency (in Hz).
|
javax.json.JsonObject |
toJSON()
Creates a compact JSON string containing the information for this class
|
String |
toString() |
protected void |
updateProcessorTicks()
Updates per-processor tick information.
|
protected void |
updateSystemTicks()
Updates system tick information.
|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, waitgetProcess, getProcesses, getProcessIdprotected int logicalProcessorCount
protected int physicalProcessorCount
protected long tickTime
protected long[] prevTicks
protected long[] curTicks
protected long procTickTime
protected long[][] prevProcTicks
protected long[][] curProcTicks
protected String cpuVendor
protected String cpuName
protected String cpuSerialNumber
protected String cpuIdentifier
protected String cpuStepping
protected String cpuModel
protected String cpuFamily
protected Long cpuVendorFreq
protected Boolean cpu64
protected javax.json.JsonBuilderFactory jsonFactory
protected void initTicks()
protected abstract void calculateProcessorCounts()
public String getVendor()
getVendor in interface CentralProcessorpublic void setVendor(String vendor)
setVendor in interface CentralProcessorvendor - Vendor.public String getName()
getName in interface CentralProcessorpublic void setName(String name)
setName in interface CentralProcessorname - Name.public long getVendorFreq()
getVendorFreq in interface CentralProcessorpublic void setVendorFreq(long freq)
setVendorFreq in interface CentralProcessorfreq - Frequency.public String getIdentifier()
getIdentifier in interface CentralProcessorpublic void setIdentifier(String identifier)
setIdentifier in interface CentralProcessoridentifier - Identifier.public boolean isCpu64bit()
isCpu64bit in interface CentralProcessorpublic void setCpu64(boolean value)
setCpu64 in interface CentralProcessorvalue - True if cpu is 64.public String getStepping()
getStepping in interface CentralProcessorpublic void setStepping(String stepping)
setStepping in interface CentralProcessorstepping - the _stepping to setpublic String getModel()
getModel in interface CentralProcessorpublic void setModel(String model)
setModel in interface CentralProcessormodel - the _model to setpublic String getFamily()
getFamily in interface CentralProcessorpublic void setFamily(String family)
setFamily in interface CentralProcessorfamily - the _family to setpublic double getSystemCpuLoadBetweenTicks()
CentralProcessor.getSystemCpuLoadTicks() between successive calls of this
method, with a minimum interval slightly less than 1 second. If less than
one second has elapsed since the last call of this method, it will return
a calculation based on the tick counts and times of the previous two
calls. If at least a second has elapsed, it will return the average CPU
load for the interval and update the "last called" times. This method is
intended to be used for periodic polling at intervals of 1 second or
longer.getSystemCpuLoadBetweenTicks in interface CentralProcessorpublic abstract long[] getSystemCpuLoadTicks()
CentralProcessor.getSystemIOWaitTicks(). The system time
includes system time spent servicing Hardware and Software IRQ requests
as reported by CentralProcessor.getSystemIrqTicks() as well as executing other
virtual hosts (steal) or running a virtual cpu (guest).getSystemCpuLoadTicks in interface CentralProcessorpublic abstract long getSystemIOWaitTicks()
CentralProcessor.getSystemCpuLoadTicks() but is provided separately
for more detail.getSystemIOWaitTicks in interface CentralProcessorpublic abstract long[] getSystemIrqTicks()
CentralProcessor.getSystemCpuLoadTicks() but is provided separately for more
detail.getSystemIrqTicks in interface CentralProcessorprotected void updateSystemTicks()
public double getSystemCpuLoad()
OperatingSystemMXBean.getSystemCpuLoad() if a
user is running the Oracle JVM. This value is a double in the [0.0,1.0]
interval. A value of 0.0 means that all CPUs were idle during the recent
period of time observed, while a value of 1.0 means that all CPUs were
actively running 100% of the time during the recent period being
observed. All values between 0.0 and 1.0 are possible depending of the
activities going on in the system. If the system recent cpu usage is not
available, the method returns a negative value. Calling this method
immediately upon instantiating the CentralProcessor may give
unreliable results. If a user is not running the Oracle JVM, this method
will default to the behavior and return value of
CentralProcessor.getSystemCpuLoadBetweenTicks().getSystemCpuLoad in interface CentralProcessorpublic double getSystemLoadAverage()
CentralProcessor.getSystemLoadAverage(int) with an
argument of 1 and returning the first value, and is retained for
compatibility.getSystemLoadAverage in interface CentralProcessorpublic abstract double[] getSystemLoadAverage(int nelem)
getSystemLoadAverage in interface CentralProcessornelem - Number of elements to return.public double[] getProcessorCpuLoadBetweenTicks()
CentralProcessor.getProcessorCpuLoadTicks() between
successive calls of this method, with a minimum interval slightly less
than 1 second. If less than one second has elapsed since the last call of
this method, it will return a calculation based on the tick counts and
times of the previous two calls. If at least a second has elapsed, it
will return the average CPU load for the interval and update the
"last called" times. This method is intended to be used for periodic
polling (iterating over all processors) at intervals of 1 second or
longer.getProcessorCpuLoadBetweenTicks in interface CentralProcessorpublic abstract long[][] getProcessorCpuLoadTicks()
CentralProcessor.getLogicalProcessorCount() arrays, each containing four
elements representing clock ticks or milliseconds (platform dependent)
spent in User (0), Nice (1), System (2), and Idle (3) states. By
measuring the difference between ticks across a time interval, CPU load
over that interval may be calculated.
The Idle time for this method includes processor time spent idle waiting
for IO as reported by CentralProcessor.getSystemIOWaitTicks(). The system time
includes processor time spent servicing Hardware IRQ requests as reported
by CentralProcessor.getSystemIrqTicks() as well as Software IRQ requests
(softirq), executing other virtual hosts (steal) or running a virtual cpu
(guest).getProcessorCpuLoadTicks in interface CentralProcessorprotected void updateProcessorTicks()
public abstract long getSystemUptime()
getSystemUptime in interface CentralProcessorpublic abstract String getSystemSerialNumber()
getSystemSerialNumber in interface CentralProcessorpublic int getLogicalProcessorCount()
getLogicalProcessorCount in interface CentralProcessorpublic int getPhysicalProcessorCount()
getPhysicalProcessorCount in interface CentralProcessorpublic abstract int getProcessCount()
getProcessCount in interface CentralProcessorpublic abstract int getThreadCount()
getThreadCount in interface CentralProcessorpublic javax.json.JsonObject toJSON()
toJSON in interface OshiJsonObjectCopyright © 2010–2016 com.github.dblock. All rights reserved.