public class CentralProcessorImpl extends AbstractOshiJsonObject implements CentralProcessor
| Constructor and Description |
|---|
CentralProcessorImpl(CentralProcessor processor)
Creates a new platform-specific CentralProcessor object wrapping the
provided argument
|
| Modifier and Type | Method and Description |
|---|---|
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.
|
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. |
long[][] |
getProcessorCpuLoadTicks()
Get Processor CPU Load tick counters.
|
String |
getProcessorID()
Gets the Processor ID.
|
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. |
long[] |
getSystemCpuLoadTicks()
Get System-wide CPU Load tick counters.
|
double |
getSystemLoadAverage()
Returns the system load average for the last minute.
|
double[] |
getSystemLoadAverage(int nelem)
Returns the system load average for the number of elements specified, up
to 3, representing 1, 5, and 15 minutes.
|
String |
getSystemSerialNumber()
Deprecated.
|
long |
getSystemUptime()
Get the System uptime (time since boot).
|
String |
getVendor()
Processor vendor.
|
long |
getVendorFreq()
Vendor frequency (in Hz), eg.
|
boolean |
isCpu64bit()
Is CPU 64bit?
|
void |
setCpu64(boolean cpu64)
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 |
setProcessorID(String processorID)
Set processor ID
|
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(Properties properties)
Returns this object as a
JsonObject. |
String |
toString() |
toCompactJSON, toCompactJSON, toJSON, toPrettyJSON, toPrettyJSONclone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, waittoCompactJSON, toCompactJSON, toJSON, toPrettyJSON, toPrettyJSONpublic CentralProcessorImpl(CentralProcessor processor)
processor - a platform-specific CentralProcessor objectpublic 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 String getProcessorID()
CentralProcessor.getIdentifier() . The remaining four
bytes are the contents of the EDX register, containing feature flags.
NOTE: The order of returned bytes is platform dependent. Windows and
macOS return the values in Big-Endian order, while Linux and Unix results
are in Little-Endian order.getProcessorID in interface CentralProcessorpublic void setProcessorID(String processorID)
setProcessorID in interface CentralProcessorprocessorID - The processor IDpublic 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 cpu64)
setCpu64 in interface CentralProcessorcpu64 - 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 long[] getSystemCpuLoadTicks()
CentralProcessor.TickType.getIndex() to
retrieve the appropriate index. By measuring the difference between ticks
across a time interval, CPU load over that interval may be calculated.
Nice information is not available on Windows, and IOwait and IRQ
information is not available on macOS, so these ticks will always be
zero.
To calculate overall Idle time using this method, include both Idle and
IOWait ticks. Similarly, IRQ and SoftIRQ ticks should be added to the
System value to get the total. System ticks also include time executing
other virtual hosts (steal).getSystemCpuLoadTicks in interface CentralProcessorpublic 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 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 long[][] getProcessorCpuLoadTicks()
CentralProcessor.getLogicalProcessorCount() arrays, each containing seven
elements representing either clock ticks or milliseconds (platform
dependent) spent in User (0), Nice (1), System (2), Idle (3), IOwait (4),
Hardware interrupts (IRQ) (5), or Software interrupts/DPC (SoftIRQ) (6)
states. Use CentralProcessor.TickType.getIndex() to
retrieve the appropriate index. By measuring the difference between ticks
across a time interval, CPU load over that interval may be calculated.
Nice and IOwait per processor information is not available on Windows,
and IOwait and IRQ information is not available on macOS, so these ticks
will always be zero.
To calculate overall Idle time using this method, include both Idle and
IOWait ticks. Similarly, IRQ and SoftIRQ ticks should be added to the
System value to get the total. System ticks also include time executing
other virtual hosts (steal).
Note that the System IOwait reported by CentralProcessor.getSystemCpuLoadTicks()
will be included in the per-processor Idle time rather than attributed to
any logical processor's IOwait counter (i.e., the sum of per-processor
Idle time will equal the System Idle + IOwait time.)getProcessorCpuLoadTicks in interface CentralProcessorpublic long getSystemUptime()
getSystemUptime in interface CentralProcessor@Deprecated public String getSystemSerialNumber()
getSystemSerialNumber in interface CentralProcessorpublic int getLogicalProcessorCount()
getLogicalProcessorCount in interface CentralProcessorpublic int getPhysicalProcessorCount()
getPhysicalProcessorCount in interface CentralProcessorpublic javax.json.JsonObject toJSON(Properties properties)
JsonObject. The provided
properties will be set on this object to configure the type of
information returned using this and future invocations of
OshiJsonObject.toJSON().toJSON in interface OshiJsonObjectproperties - Properties to configure returned resultsJsonObject for this class.public String toString()
toString in class AbstractOshiJsonObjectCopyright © 2010–2017 oshi. All rights reserved.