Package oshi.hardware

Interface CentralProcessor

    • Method Detail

      • getVendor

        java.lang.String getVendor()
        Processor vendor.
        Returns:
        vendor string.
      • setVendor

        void setVendor​(java.lang.String vendor)
        Set processor vendor.
        Parameters:
        vendor - Vendor.
      • getName

        java.lang.String getName()
        Name, eg. Intel(R) Core(TM)2 Duo CPU T7300 @ 2.00GHz
        Returns:
        Processor name.
      • setName

        void setName​(java.lang.String name)
        Set processor name.
        Parameters:
        name - Name.
      • getVendorFreq

        long getVendorFreq()
        Vendor frequency (in Hz), eg. for processor named Intel(R) Core(TM)2 Duo CPU T7300 @ 2.00GHz the vendor frequency is 2000000000.
        Returns:
        Processor frequency or -1 if unknown.
      • setVendorFreq

        void setVendorFreq​(long freq)
        Set processor vendor frequency (in Hz).
        Parameters:
        freq - Frequency.
      • getProcessorID

        java.lang.String getProcessorID()
        Gets the Processor ID. This is a hexidecimal string representing an 8-byte value, normally obtained using the CPUID opcode with the EAX register set to 1. The first four bytes are the resulting contents of the EAX register, which is the Processor signature, represented in human-readable form by getIdentifier() . The remaining four bytes are the contents of the EDX register, containing feature flags. NOTE: The order of returned bytes is platform and software dependent. Values may be in either Big Endian or Little Endian order.
        Returns:
        A string representing the Processor ID
      • setProcessorID

        void setProcessorID​(java.lang.String processorID)
        Set processor ID
        Parameters:
        processorID - The processor ID
      • getIdentifier

        java.lang.String getIdentifier()
        Identifier, eg. x86 Family 6 Model 15 Stepping 10.
        Returns:
        Processor identifier.
      • setIdentifier

        void setIdentifier​(java.lang.String identifier)
        Set processor identifier.
        Parameters:
        identifier - Identifier.
      • isCpu64bit

        boolean isCpu64bit()
        Is CPU 64bit?
        Returns:
        True if cpu is 64bit.
      • setCpu64

        void setCpu64​(boolean cpu64)
        Set flag is cpu is 64bit.
        Parameters:
        cpu64 - True if cpu is 64.
      • getStepping

        java.lang.String getStepping()
        Returns:
        the stepping
      • setStepping

        void setStepping​(java.lang.String stepping)
        Parameters:
        stepping - the stepping to set
      • getModel

        java.lang.String getModel()
        Returns:
        the model
      • setModel

        void setModel​(java.lang.String model)
        Parameters:
        model - the model to set
      • getFamily

        java.lang.String getFamily()
        Returns:
        the family
      • setFamily

        void setFamily​(java.lang.String family)
        Parameters:
        family - the family to set
      • getSystemCpuLoadBetweenTicks

        double getSystemCpuLoadBetweenTicks()
        Returns the "recent cpu usage" for the whole system by counting ticks from 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.
        Returns:
        CPU load between 0 and 1 (100%)
      • getSystemCpuLoadTicks

        long[] getSystemCpuLoadTicks()
        Get System-wide CPU Load tick counters. Returns an array with 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), Software interrupts/DPC (SoftIRQ) (6), or Steal (7) 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 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, SoftIRQ, and Steal ticks should be added to the System value to get the total. System ticks also include time executing other virtual hosts (steal).
        Returns:
        An array of 7 long values representing time spent in User, Nice, System, Idle, IOwait, IRQ, SoftIRQ, and Steal states.
      • getSystemCpuLoad

        double getSystemCpuLoad()
        Returns the "recent cpu usage" for the whole system from 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 getSystemCpuLoadBetweenTicks().
        Returns:
        the "recent cpu usage" for the whole system; a negative value if not available.
      • getSystemLoadAverage

        double getSystemLoadAverage()
        Returns the system load average for the last minute. This is equivalent to calling getSystemLoadAverage(int) with an argument of 1 and returning the first value, and is retained for compatibility.
        Returns:
        the system load average; or a negative value if not available.
      • getSystemLoadAverage

        double[] getSystemLoadAverage​(int nelem)
        Returns the system load average for the number of elements specified, up to 3, representing 1, 5, and 15 minutes. The system load average is the sum of the number of runnable entities queued to the available processors and the number of runnable entities running on the available processors averaged over a period of time. The way in which the load average is calculated is operating system specific but is typically a damped time-dependent average. If the load average is not available, a negative value is returned. This method is designed to provide a hint about the system load and may be queried frequently. The load average may be unavailable on some platforms (e.g., Windows) where it is expensive to implement this method.
        Parameters:
        nelem - Number of elements to return.
        Returns:
        an array of the system load averages for 1, 5, and 15 minutes with the size of the array specified by nelem; or negative values if not available.
      • getProcessorCpuLoadBetweenTicks

        double[] getProcessorCpuLoadBetweenTicks()
        Returns the "recent cpu usage" for all logical processors by counting ticks for the processors from 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.
        Returns:
        array of CPU load between 0 and 1 (100%) for each logical processor
      • getProcessorCpuLoadTicks

        long[][] getProcessorCpuLoadTicks()
        Get Processor CPU Load tick counters. Returns a two dimensional array, with 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), Software interrupts/DPC (SoftIRQ) (6), or Steal (7) 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, SoftIRQ and Steal ticks should be added to the System value to get the total. System ticks also include time executing other virtual hosts (steal).
        Returns:
        A 2D array of logicalProcessorCount x 7 long values representing time spent in User, Nice, System, Idle, IOwait, IRQ, SoftIRQ, and Steal states.
      • getSystemUptime

        long getSystemUptime()
        Get the System uptime (time since boot).
        Returns:
        Number of seconds since boot.
      • getLogicalProcessorCount

        int getLogicalProcessorCount()
        Get the number of logical CPUs available for processing. This value may be higher than physical CPUs if hyperthreading is enabled.
        Returns:
        The number of logical CPUs available.
      • getPhysicalProcessorCount

        int getPhysicalProcessorCount()
        Get the number of physical CPUs/cores available for processing.
        Returns:
        The number of physical CPUs available.
      • getPhysicalPackageCount

        int getPhysicalPackageCount()
        Get the number of packages/sockets in the system. A single package may contain multiple cores.
        Returns:
        The number of physical packages available.
      • getContextSwitches

        long getContextSwitches()
        Get the number of context switches which have occurred
        Returns:
        The number of context switches
      • getInterrupts

        long getInterrupts()
        Get the number of interrupts which have occurred
        Returns:
        The number of interrupts