disk io works using cache - also pid cache cleanup and pid cache dump
This commit is contained in:
1 parent
f2ba707d9f
commit
07b221a253
20 files changed
+409
-43
No files matched your search
@@ -42,6 +42,8 @@ public class Sigar implements SigarProxy {
|
||||
private static String loadError = null;
|
||||
|
||||
public static final long FIELD_NOTIMPL = -1;
|
||||
public static final int PID_PROC_CPU_CACHE = 1;
|
||||
public static final int PID_PROC_IO_CACHE = 2;
|
||||
|
||||
/**
|
||||
* The Sigar java version.
|
||||
@@ -661,6 +663,34 @@ public class Sigar implements SigarProxy {
|
||||
return getProcDiskIO(convertPid(pid));
|
||||
}
|
||||
|
||||
/**
|
||||
* Get process cumulative disk IO info.
|
||||
* @param pid THe process id.
|
||||
* @exception SigarException on failure.
|
||||
*/
|
||||
public ProcCumulativeDiskIO getProcCumulativeDiskIO(long pid) throws SigarException {
|
||||
try {
|
||||
return ProcCumulativeDiskIO.fetch(this, pid);
|
||||
} catch (UnsatisfiedLinkError linkErrorException) {
|
||||
// We want to handle exceptions gracefully even if the linked
|
||||
// shared library is older and isn't compiled with the ProcDiskIO APIs.
|
||||
// The downside of this is that we throw SigarNotImplemented exception
|
||||
// also when the shared library can't be loaded.
|
||||
SigarException sigarException = new SigarNotImplementedException();
|
||||
sigarException.initCause(linkErrorException);
|
||||
throw sigarException;
|
||||
}
|
||||
}
|
||||
|
||||
public ProcCumulativeDiskIO getProcCumulativeDiskIO(String pid) throws SigarException {
|
||||
return getProcCumulativeDiskIO(convertPid(pid));
|
||||
}
|
||||
|
||||
public DumpPidCache dumpPidCache() throws SigarException {
|
||||
return DumpPidCache.fetch(this);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Get the cumulative cpu time for the calling thread.
|
||||
*/
|
||||
|
||||
@@ -110,6 +110,12 @@ public interface SigarProxy {
|
||||
|
||||
public ProcDiskIO getProcDiskIO(String pid) throws SigarException;
|
||||
|
||||
public ProcCumulativeDiskIO getProcCumulativeDiskIO(long pid) throws SigarException;
|
||||
|
||||
public ProcCumulativeDiskIO getProcCumulativeDiskIO(String pid) throws SigarException;
|
||||
|
||||
public DumpPidCache dumpPidCache() throws SigarException;
|
||||
|
||||
public FileSystem[] getFileSystemList() throws SigarException;
|
||||
|
||||
public FileSystemMap getFileSystemMap() throws SigarException;
|
||||
|
||||
@@ -0,0 +1,51 @@
|
||||
/*
|
||||
* Copyright (c) 2006-2007 Hyperic, Inc.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package org.hyperic.sigar.cmd;
|
||||
|
||||
import org.hyperic.sigar.SigarException;
|
||||
import org.hyperic.sigar.SigarPermissionDeniedException;
|
||||
|
||||
/**
|
||||
* Display all pid cache information.
|
||||
*/
|
||||
public class PidCacheInfo extends SigarCommandBase {
|
||||
|
||||
|
||||
public PidCacheInfo(Shell shell) {
|
||||
super(shell);
|
||||
}
|
||||
|
||||
public PidCacheInfo() {
|
||||
super();
|
||||
}
|
||||
|
||||
protected boolean validateArgs(String[] args) {
|
||||
return true;
|
||||
}
|
||||
|
||||
public String getUsageShort() {
|
||||
return "Display cache info for CPU cache and for IO cache";
|
||||
}
|
||||
|
||||
public boolean isPidCompleter() {
|
||||
return false;
|
||||
}
|
||||
|
||||
public void output(String[] args) throws SigarException {
|
||||
sigar.dumpPidCache();
|
||||
}
|
||||
}
|
||||
@@ -103,6 +103,11 @@ public class ProcInfo extends SigarCommandBase {
|
||||
try {
|
||||
println("diskio=" + sigar.getProcDiskIO(pid));
|
||||
} catch (SigarException e) {}
|
||||
|
||||
try {
|
||||
println("cumulative diskio=" + sigar.getProcCumulativeDiskIO(pid));
|
||||
} catch (SigarException e) {}
|
||||
|
||||
}
|
||||
|
||||
public static void main(String[] args) throws Exception {
|
||||
|
||||
@@ -103,6 +103,8 @@ public class Shell extends ShellBase {
|
||||
registerCommandHandler("time", new Time(this));
|
||||
registerCommandHandler("ulimit", new Ulimit(this));
|
||||
registerCommandHandler("who", new Who(this));
|
||||
registerCommandHandler("pid_cache_info", new PidCacheInfo(this));
|
||||
|
||||
if (SigarLoader.IS_WIN32) {
|
||||
registerCommandHandler("service", new Win32Service(this));
|
||||
registerCommandHandler("fversion", new FileVersionInfo(this));
|
||||
|
||||
@@ -20,6 +20,7 @@ import org.hyperic.sigar.ProcCpu;
|
||||
import org.hyperic.sigar.ProcFd;
|
||||
import org.hyperic.sigar.ProcMem;
|
||||
import org.hyperic.sigar.ProcUtil;
|
||||
import org.hyperic.sigar.ProcDiskIO;
|
||||
import org.hyperic.sigar.Sigar;
|
||||
import org.hyperic.sigar.SigarException;
|
||||
import org.hyperic.sigar.SigarProxy;
|
||||
@@ -76,6 +77,16 @@ public class SigarProcess implements SigarProcessMBean {
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
private synchronized ProcDiskIO getDiskIO() {
|
||||
try {
|
||||
return this.sigar.getProcDiskIO(getPid());
|
||||
} catch (SigarException e) {
|
||||
throw unexpectedError("DiskIO", e);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
private synchronized ProcFd getFd() throws SigarException {
|
||||
return this.sigar.getProcFd(getPid());
|
||||
}
|
||||
@@ -153,4 +164,9 @@ public class SigarProcess implements SigarProcessMBean {
|
||||
return NOTIMPL;
|
||||
}
|
||||
}
|
||||
|
||||
public Double getBytesReadWriteTotal() {
|
||||
return new Double(getDiskIO().getBytesTotal());
|
||||
}
|
||||
|
||||
}
|
||||
@@ -44,4 +44,6 @@ public interface SigarProcessMBean {
|
||||
public Double getCpuUsage();
|
||||
|
||||
public Long getOpenFd();
|
||||
|
||||
public Double getBytesReadWriteTotal();
|
||||
}
|
||||
Reference in new issue
Block a user