當前位置: 首頁>>代碼示例>>Java>>正文


Java SigarException類代碼示例

本文整理匯總了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());
}
 
開發者ID:EnFlexIT,項目名稱:AgentWorkbench,代碼行數:18,代碼來源:ProcFileInfo.java

示例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);
    }
}
 
開發者ID:EnFlexIT,項目名稱:AgentWorkbench,代碼行數:21,代碼來源:Route.java

示例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());
        }
    };
}
 
開發者ID:Axway,項目名稱:ats-framework,代碼行數:20,代碼來源:ReadingInstancesFactory.java

示例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());
                }
            }
        }
    }
}
 
開發者ID:EnFlexIT,項目名稱:AgentWorkbench,代碼行數:19,代碼來源:FileVersionInfo.java

示例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);
    }
}
 
開發者ID:EnFlexIT,項目名稱:AgentWorkbench,代碼行數:21,代碼來源:Kill.java

示例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;
}
 
開發者ID:EnFlexIT,項目名稱:AgentWorkbench,代碼行數:24,代碼來源:Uptime.java

示例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);
}
 
開發者ID:EnFlexIT,項目名稱:AgentWorkbench,代碼行數:20,代碼來源:Ls.java

示例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());
        }
    }
}
 
開發者ID:EnFlexIT,項目名稱:AgentWorkbench,代碼行數:20,代碼來源:Ps.java

示例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]);
        }
    }
}
 
開發者ID:EnFlexIT,項目名稱:AgentWorkbench,代碼行數:20,代碼來源:Tail.java

示例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());
        }
    };
}
 
開發者ID:Axway,項目名稱:ats-framework,代碼行數:20,代碼來源:ReadingInstancesFactory.java

示例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;
}
 
開發者ID:yanfanvip,項目名稱:RedisClusterManager,代碼行數:23,代碼來源:MonitorUtil.java

示例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());
        }
    };
}
 
開發者ID:Axway,項目名稱:ats-framework,代碼行數:20,代碼來源:ReadingInstancesFactory.java

示例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();
	}
}
 
開發者ID:funtl,項目名稱:framework,代碼行數:18,代碼來源:SysInfo.java

示例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();
	}
}
 
開發者ID:funtl,項目名稱:framework,代碼行數:20,代碼來源:SysInfo.java

示例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());
        }
    };
}
 
開發者ID:Axway,項目名稱:ats-framework,代碼行數:20,代碼來源:ReadingInstancesFactory.java


注:本文中的org.hyperic.sigar.SigarException類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。