Skip to content
This repository has been archived by the owner on Jul 11, 2022. It is now read-only.

Commit

Permalink
Replace direct Sigar access with proxy
Browse files Browse the repository at this point in the history
  • Loading branch information
Michael Burman committed Jan 13, 2017
1 parent fb6d71f commit 6f71078
Showing 1 changed file with 6 additions and 4 deletions.
Expand Up @@ -35,10 +35,12 @@
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.hyperic.sigar.ProcCred;
import org.hyperic.sigar.Sigar;
import org.hyperic.sigar.SigarException;
import org.hyperic.sigar.SigarProxy;

import org.rhq.core.system.ProcessInfo;
import org.rhq.core.system.SigarAccess;
import org.rhq.core.system.SystemInfoException;
import org.rhq.plugins.jmx.MBeanResourceComponent;

/**
Expand Down Expand Up @@ -142,14 +144,14 @@ private static VirtualMachine attachToVirtualMachine(ProcessInfo process) throws
}

private static long getAgentProcessUid() {
Sigar sigar = new Sigar();
try {
SigarProxy sigar = SigarAccess.getSigar();
ProcCred procCred = sigar.getProcCred(sigar.getPid());
return procCred.getEuid();
} catch (SystemInfoException e) {
return 0;
} catch (SigarException e) {
return 0;
} finally {
sigar.close();
}
}

Expand Down

0 comments on commit 6f71078

Please sign in to comment.