本文整理匯總了Java中org.hyperic.sigar.SigarException類的典型用法代碼示例。如果您正苦於以下問題:Java SigarException類的具體用法?Java SigarException怎麽用?Java SigarException使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。
SigarException類屬於org.hyperic.sigar包,在下文中一共展示了SigarException類的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: output
import org.hyperic.sigar.SigarException; //導入依賴的package包/類
public void output(long pid) throws SigarException {
println("pid=" + pid);
try {
ProcFd fd = sigar.getProcFd(pid);
println("open file descriptors=" + fd.getTotal());
} catch (SigarNotImplementedException e) {}
ProcExe exe = sigar.getProcExe(pid);
String name = exe.getName();
if (name.length() == 0) {
name = "unknown";
}
println("name=" + name);
println("cwd=" + exe.getCwd());
}
示例2: output
import org.hyperic.sigar.SigarException; //導入依賴的package包/類
public void output(String[] args) throws SigarException {
NetRoute[] routes = this.sigar.getNetRouteList();
printf(HEADER);
for (int i=0; i<routes.length; i++) {
NetRoute route = routes[i];
ArrayList items = new ArrayList();
items.add(route.getDestination());
items.add(route.getGateway());
items.add(route.getMask());
items.add(flags(route.getFlags()));
items.add(String.valueOf(route.getMetric()));
items.add(String.valueOf(route.getRefcnt()));
items.add(route.getIfname());
printf(items);
}
}
示例3: getTcpClosing
import org.hyperic.sigar.SigarException; //導入依賴的package包/類
private static ReadingInstance getTcpClosing(
SigarWrapper sigarWrapper,
ReadingBean reading ) throws SigarException {
return new ReadingInstance(sigarWrapper,
String.valueOf(reading.getDbId()),
reading.getMonitorName(),
reading.getName(),
reading.getUnit(),
1.0F) {
private static final long serialVersionUID = 1L;
@Override
public float poll() {
return fixLongValue(sigarWrapper.netstat.getTcpClosing());
}
};
}
示例4: output
import org.hyperic.sigar.SigarException; //導入依賴的package包/類
public void output(String[] args) throws SigarException {
for (int i=0; i<args.length; i++) {
String exe = args[i];
if (new File(exe).exists()) {
output(exe);
}
else {
long[] pids = this.shell.findPids(exe);
for (int j=0; j<pids.length; j++) {
try {
output(sigar.getProcExe(pids[j]).getName());
} catch (SigarException e) {
println(exe + ": " + e.getMessage());
}
}
}
}
}
示例5: output
import org.hyperic.sigar.SigarException; //導入依賴的package包/類
public void output(String[] args) throws SigarException {
String signal = "SIGTERM";
long[] pids;
String query;
if (args.length == 2) {
signal = args[0];
query = args[1];
}
else {
query = args[0];
}
pids = this.shell.findPids(new String[] { query });
for (int i=0; i<pids.length; i++) {
println("kill " + signal + " " + pids[i]);
this.sigar.kill(pids[i], signal);
}
}
示例6: getInfo
import org.hyperic.sigar.SigarException; //導入依賴的package包/類
public static String getInfo(SigarProxy sigar) throws SigarException {
double uptime = sigar.getUptime().getUptime();
String loadAverage;
try {
double[] avg = sigar.getLoadAverage();
loadAvg[0] = new Double(avg[0]);
loadAvg[1] = new Double(avg[1]);
loadAvg[2] = new Double(avg[2]);
loadAverage = "load average: " +
formatter.sprintf(loadAvg);
} catch (SigarNotImplementedException e) {
loadAverage = "(load average unknown)";
}
return
" " + getCurrentTime() +
" up " + formatUptime(uptime) +
", " + loadAverage;
}
示例7: output
import org.hyperic.sigar.SigarException; //導入依賴的package包/類
public void output(String[] args) throws SigarException {
String file = args[0];
FileInfo link = this.sigar.getLinkInfo(file);
FileInfo info = this.sigar.getFileInfo(file);
if (link.getType() == FileInfo.TYPE_LNK) {
try {
file = file + " -> " + new File(file).getCanonicalPath();
} catch (IOException e) {
e.printStackTrace();
}
}
println(link.getTypeChar() +
info.getPermissionsString() + "\t" +
info.getUid() + "\t" + info.getGid() + "\t" +
info.getSize() + "\t" +
getDate(info.getMtime()) + "\t" +
file);
}
示例8: output
import org.hyperic.sigar.SigarException; //導入依賴的package包/類
public void output(String[] args) throws SigarException {
long[] pids;
if (args.length == 0) {
pids = this.proxy.getProcList();
}
else {
pids = this.shell.findPids(args);
}
for (int i=0; i<pids.length; i++) {
long pid = pids[i];
try {
output(pid);
} catch (SigarException e) {
this.err.println("Exception getting process info for " +
pid + ": " + e.getMessage());
}
}
}
示例9: parseArgs
import org.hyperic.sigar.SigarException; //導入依賴的package包/類
public void parseArgs(String args[]) throws SigarException {
for (int i=0; i<args.length; i++) {
String arg = args[i];
if (arg.charAt(0) != '-') {
this.files.add(arg);
continue;
}
arg = arg.substring(1);
if (arg.equals("f")) {
this.follow = true;
}
else if (Character.isDigit(arg.charAt(0))) {
this.number = Integer.parseInt(arg);
}
else {
throw new SigarException("Unknown argument: " + args[i]);
}
}
}
示例10: getTcpFinWait1
import org.hyperic.sigar.SigarException; //導入依賴的package包/類
private static ReadingInstance getTcpFinWait1(
SigarWrapper sigarWrapper,
ReadingBean reading ) throws SigarException {
return new ReadingInstance(sigarWrapper,
String.valueOf(reading.getDbId()),
reading.getMonitorName(),
reading.getName(),
reading.getUnit(),
1.0F) {
private static final long serialVersionUID = 1L;
@Override
public float poll() {
return fixLongValue(sigarWrapper.netstat.getTcpFinWait1());
}
};
}
示例11: totalDisk
import org.hyperic.sigar.SigarException; //導入依賴的package包/類
/**
* 磁盤總量
*/
public static long totalDisk() throws SigarException {
if(staticResource.totalDisk == null){
FileSystem[] fs = sigar.getFileSystemList();
long total = 0L;
for (FileSystem fileSystem : fs) {
try {
if(fileSystem.getType() == 2){
FileSystemUsage usage = sigar.getFileSystemUsage(fileSystem.getDirName());
total += usage.getTotal();
}
} catch (Exception e) {}
}
if(total == 0){
return 1;
}
staticResource.totalDisk = total;
}
return staticResource.totalDisk;
}
示例12: getTcpCloseWait
import org.hyperic.sigar.SigarException; //導入依賴的package包/類
private static ReadingInstance getTcpCloseWait(
SigarWrapper sigarWrapper,
ReadingBean reading ) throws SigarException {
return new ReadingInstance(sigarWrapper,
String.valueOf(reading.getDbId()),
reading.getMonitorName(),
reading.getName(),
reading.getUnit(),
1.0F) {
private static final long serialVersionUID = 1L;
@Override
public float poll() {
return fixLongValue(sigarWrapper.netstat.getTcpCloseWait());
}
};
}
示例13: getCpuTotal
import org.hyperic.sigar.SigarException; //導入依賴的package包/類
public void getCpuTotal() {
Sigar sigar = new Sigar();
CpuInfo[] infos;
try {
infos = sigar.getCpuInfoList();
for (int i = 0; i < infos.length; i++) {// 不管是單塊CPU還是多CPU都適用
CpuInfo info = infos[i];
System.out.println("CPU的總量:" + info.getMhz());// CPU的總量MHz
System.out.println("獲得CPU的賣主:" + info.getVendor());// 獲得CPU的賣主,如:Intel
System.out.println("CPU的類別:" + info.getModel());// 獲得CPU的類別,如:Celeron
System.out.println("緩衝存儲器數量:" + info.getCacheSize());// 緩衝存儲器數量
System.out.println("**************");
}
} catch (SigarException e) {
e.printStackTrace();
}
}
示例14: testWho
import org.hyperic.sigar.SigarException; //導入依賴的package包/類
public void testWho() {
try {
Sigar sigar = new Sigar();
Who[] who = sigar.getWhoList();
if (who != null && who.length > 0) {
for (int i = 0; i < who.length; i++) {
System.out.println("\n~~~~~~~~~" + String.valueOf(i) + "~~~~~~~~~");
Who _who = who[i];
System.out.println("獲取設備getDevice() = " + _who.getDevice());
System.out.println("獲得主機getHost() = " + _who.getHost());
System.out.println("獲取的時間getTime() = " + _who.getTime());
// 當前係統進程表中的用戶名
System.out.println("獲取用戶getUser() = " + _who.getUser());
}
}
} catch (SigarException e) {
e.printStackTrace();
}
}
示例15: getNetstatInErrors
import org.hyperic.sigar.SigarException; //導入依賴的package包/類
private static ReadingInstance getNetstatInErrors(
SigarWrapper sigarWrapper,
ReadingBean reading ) throws SigarException {
return new ReadingInstance(sigarWrapper,
String.valueOf(reading.getDbId()),
reading.getMonitorName(),
reading.getName(),
reading.getUnit(),
1.0F) {
private static final long serialVersionUID = 1L;
@Override
public float poll() {
return fixLongValue(sigarWrapper.tcp.getInErrs());
}
};
}