Package org.hyperic.sigar

Examples of org.hyperic.sigar.SigarProxy


        this.mountPoint = mountPoint;
        refresh();
    }

    public void refresh() {
        SigarProxy sigar = SigarAccess.getSigar();

        try {
            // this only needs to be loaded once - it will never change during the lifetime of the file system
            if (this.fs == null) {
                this.fs = sigar.getFileSystemMap().getFileSystem(this.mountPoint);
            }
        } catch (Exception e) {
            throw new SystemInfoException("Cannot refresh file system mounted at [" + this.mountPoint + "]", e);
        }

        try {
            // this is the usage data and therefore should be refreshed
            this.fsUsage = sigar.getMountedFileSystemUsage(this.mountPoint);
        } catch (SigarException e) {
            // this happens when the file system is not available (e.g. if it's a CD-ROM without a CD loaded in it) or
            // if we don't have permission to access the filesystem. we can ignore it and set the usage data to null.
            this.fsUsage = null;
            if (LOG.isTraceEnabled()) {
View Full Code Here


     * constructor, because pollers are constructed during PC initialization, and at that time the PC EventManager,
     * which the EventContext relies on, is not yet available. Instead it is called from {@link #poll()} on the first
     * invocation of that method, at which point the PC will be initialized.
     */
    protected void init() {
        SigarProxy sigar = this.eventContext.getSigar();
        if (sigar != null) {
            try {
                this.logFileInfo = new LogFileInfo(sigar.getFileInfo(logFile.getPath()));
            } catch (SigarException e) {
                throw new RuntimeException("Failed to obtain file info for log file [" + this.logFile + "].", e);
            }
        } else {
            LOG.warn("SIGAR is unavailable - cannot poll log file [" + this.logFile + "] for events.");
View Full Code Here

     * @param name Binary base name to match against
     * @return The process executable path.
     */
    @Nullable
    public static File getProcExe(long pid, String name) {
        SigarProxy sigar = SigarAccess.getSigar();
        File argv0;
        try {
            String exe = sigar.getProcExe(pid).getName();
            // may be "" on Solaris
            if (exe.length() > 0) {
                return new File(exe);
            }
        } catch (SigarException e) {
View Full Code Here

    }

    public static void main(String[] args) throws Exception {
        Sigar sigarImpl = new Sigar();

        SigarProxy sigar =
            SigarProxyCache.newInstance(sigarImpl, SLEEP_TIME);

        while (true) {
            Shell.clearScreen();

            System.out.println(Uptime.getInfo(sigar));

            System.out.println(toString(sigar.getProcStat()));

            System.out.println(sigar.getCpuPerc());

            System.out.println(sigar.getMem());

            System.out.println(sigar.getSwap());
                              
            System.out.println();

            System.out.println(HEADER);

            long[] pids = Shell.getPids(sigar, args);

            for (int i=0; i<pids.length; i++) {
                long pid = pids[i];

                String cpuPerc = "?";

                List info;
                try {
                    info = Ps.getInfo(sigar, pid);
                } catch (SigarException e) {
                    continue; //process may have gone away
                }
                try {
                    ProcCpu cpu = sigar.getProcCpu(pid);
                    cpuPerc = CpuPerc.format(cpu.getPercent());
                } catch (SigarException e) {
                }

                info.add(info.size()-1, cpuPerc);
View Full Code Here

* @author Leo Xu
*/
public class SystemInformationEnv{

    public static SystemInformationEnvObject getSystemEnv(){
        SigarProxy sigar = SigarHolder.getInstance();
        SystemInformationEnvObject envObj = new SystemInformationEnvObject();
        long[] pids = new long[0];
        try {
            pids = sigar.getProcList();
        } catch (SigarException ex) {

        }

        for(int i = 0; i < pids.length; i++){
            Map env;
            try {
                env = sigar.getProcEnv(pids[i]);
                envObj.addAllEnv(env);          
            } catch(SigarPermissionDeniedException pEx){

            } catch (SigarException ex) {
                Logger.getLogger(SystemInformationEnv.class.getName()).log(Level.SEVERE, null, ex);
View Full Code Here

* @author Leo Xu
*/
public class NetInformation{
  
    public static NetInfoObject getNetInfo() {
        SigarProxy sigar = SigarHolder.getInstance();
        NetInfoObject netObj = new NetInfoObject();
        try {
            org.hyperic.sigar.NetInfo netInfo = sigar.getNetInfo();
            netObj.setDefaultGateway(netInfo.getDefaultGateway());
            netObj.setDomainName(netInfo.getDomainName());
            netObj.setHostName(netInfo.getHostName());
            netObj.setPrimaryDns(netInfo.getPrimaryDns());
            netObj.setSecondaryDns(netInfo.getSecondaryDns());
View Full Code Here

    }

    public void testCreate() throws Exception {
        Sigar sigar = new Sigar();

        SigarProxy proxy =
            SigarProxyCache.newInstance(sigar);

        testOK(proxy);

        sigar.close();
View Full Code Here

        long[] pids = sigar.getProcList();

        assertTrue(stat.getTotal() > 1);
        traceln(stat.toString());
        SigarProxy proxy = SigarProxyCache.newInstance(getSigar());
        traceln(CurrentProcessSummary.get(proxy).toString());
    }
View Full Code Here

    public static void main(String[] args) throws Exception {
        int expire = 30 * 1000;

        Sigar sigar = new Sigar();

        SigarProxy proxy = SigarProxyCache.newInstance(sigar, expire);

        new Proxy(sigar, proxy).run(args);
    }
View Full Code Here

        //true should make things blow up
        boolean useGlobal = false;

        public void run() {
            Sigar sigar;
            SigarProxy proxy;

            try {
                synchronized (lock) {
                    if (useGlobal) {
                        if (gSigar == null) {
View Full Code Here

TOP

Related Classes of org.hyperic.sigar.SigarProxy

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.