1/* 2 * Copyright (c) 2003, 2015, Oracle and/or its affiliates. All rights reserved. 3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 4 * 5 * This code is free software; you can redistribute it and/or modify it 6 * under the terms of the GNU General Public License version 2 only, as 7 * published by the Free Software Foundation. Oracle designates this 8 * particular file as subject to the "Classpath" exception as provided 9 * by Oracle in the LICENSE file that accompanied this code. 10 * 11 * This code is distributed in the hope that it will be useful, but WITHOUT 12 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 13 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 14 * version 2 for more details (a copy is included in the LICENSE file that 15 * accompanied this code). 16 * 17 * You should have received a copy of the GNU General Public License version 18 * 2 along with this work; if not, write to the Free Software Foundation, 19 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. 20 * 21 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA 22 * or visit www.oracle.com if you need additional information or have any 23 * questions. 24 */ 25 26package com.sun.management.internal; 27 28import sun.management.BaseOperatingSystemImpl; 29import sun.management.VMManagement; 30/** 31 * Implementation class for the operating system. 32 * Standard and committed hotspot-specific metrics if any. 33 * 34 * ManagementFactory.getOperatingSystemMXBean() returns an instance 35 * of this class. 36 */ 37class OperatingSystemImpl extends BaseOperatingSystemImpl 38 implements com.sun.management.UnixOperatingSystemMXBean { 39 40 OperatingSystemImpl(VMManagement vm) { 41 super(vm); 42 } 43 44 public long getCommittedVirtualMemorySize() { 45 return getCommittedVirtualMemorySize0(); 46 } 47 48 public long getTotalSwapSpaceSize() { 49 return getTotalSwapSpaceSize0(); 50 } 51 52 public long getFreeSwapSpaceSize() { 53 return getFreeSwapSpaceSize0(); 54 } 55 56 public long getProcessCpuTime() { 57 return getProcessCpuTime0(); 58 } 59 60 public long getFreePhysicalMemorySize() { 61 return getFreePhysicalMemorySize0(); 62 } 63 64 public long getTotalPhysicalMemorySize() { 65 return getTotalPhysicalMemorySize0(); 66 } 67 68 public long getOpenFileDescriptorCount() { 69 return getOpenFileDescriptorCount0(); 70 } 71 72 public long getMaxFileDescriptorCount() { 73 return getMaxFileDescriptorCount0(); 74 } 75 76 public double getSystemCpuLoad() { 77 return getSystemCpuLoad0(); 78 } 79 80 public double getProcessCpuLoad() { 81 return getProcessCpuLoad0(); 82 } 83 84 /* native methods */ 85 private native long getCommittedVirtualMemorySize0(); 86 private native long getFreePhysicalMemorySize0(); 87 private native long getFreeSwapSpaceSize0(); 88 private native long getMaxFileDescriptorCount0(); 89 private native long getOpenFileDescriptorCount0(); 90 private native long getProcessCpuTime0(); 91 private native double getProcessCpuLoad0(); 92 private native double getSystemCpuLoad0(); 93 private native long getTotalPhysicalMemorySize0(); 94 private native long getTotalSwapSpaceSize0(); 95 96 static { 97 initialize0(); 98 } 99 100 private static native void initialize0(); 101} 102