Class SysctlUtil

java.lang.Object
oshi.util.platform.mac.SysctlUtil

@ThreadSafe public final class SysctlUtil extends Object
Provides access to sysctl calls on macOS
  • Method Details

    • sysctl

      public static int sysctl(String name, int def)
      Executes a sysctl call with an int result
      Parameters:
      name - name of the sysctl
      def - default int value
      Returns:
      The int result of the call if successful; the default otherwise
    • sysctl

      public static int sysctl(String name, int def, boolean logWarning)
      Executes a sysctl call with an int result
      Parameters:
      name - name of the sysctl
      def - default int value
      logWarning - whether to log the warning if not available
      Returns:
      The int result of the call if successful; the default otherwise
    • sysctl

      public static long sysctl(String name, long def)
      Executes a sysctl call with a long result
      Parameters:
      name - name of the sysctl
      def - default long value
      Returns:
      The long result of the call if successful; the default otherwise
    • sysctl

      public static String sysctl(String name, String def)
      Executes a sysctl call with a String result
      Parameters:
      name - name of the sysctl
      def - default String value
      Returns:
      The String result of the call if successful; the default otherwise
    • sysctl

      public static String sysctl(String name, String def, boolean logWarning)
      Executes a sysctl call with a String result
      Parameters:
      name - name of the sysctl
      def - default String value
      logWarning - whether to log the warning if not available
      Returns:
      The String result of the call if successful; the default otherwise
    • sysctl

      public static boolean sysctl(String name, com.sun.jna.Structure struct)
      Executes a sysctl call with a Structure result
      Parameters:
      name - name of the sysctl
      struct - structure for the result
      Returns:
      True if structure is successfuly populated, false otherwise
    • sysctl

      public static com.sun.jna.Memory sysctl(String name)
      Executes a sysctl call with a Pointer result
      Parameters:
      name - name of the sysctl
      Returns:
      An allocated memory buffer containing the result on success, null otherwise. Its value on failure is undefined.