@Override public void onShutDown() { if (sigar != null) { sigar.close(); sigar = null; } }
public void shutdown() { this.sigar.close(); //cleanup for dmalloc //using reflection incase junit.jar is not present try { //SigarTestCase.closeSigar(); Class.forName("org.hyperic.sigar.test.SigarTestCase"). getMethod("closeSigar", new Class[0]).invoke(null, new Object[0]); } catch (ClassNotFoundException e) { //SigarTestCase.java not compiled w/o junit.jar } catch (Exception e) { e.printStackTrace(); } catch (NoClassDefFoundError e) { //avoiding possible Class Not Found: junit/framework/TestCase } super.shutdown(); }
@Inject public SigarService() { Sigar sigar = null; try { sigar = new Sigar(); Sigar.load(); LOG.debug("Successfully loaded SIGAR {}", Sigar.VERSION_STRING); } catch (Throwable t) { LOG.info("Failed to load SIGAR. Falling back to JMX implementations."); LOG.debug("Reason for SIGAR loading failure", t); if (sigar != null) { try { sigar.close(); } catch (Throwable t1) { // ignore } finally { sigar = null; } } } this.sigar = sigar; }
private static String getenv(String key) { try { return System.getenv("ANT_HOME"); //check for junit.jar } catch (Error e) { /*1.4*/ Sigar sigar = new Sigar(); try { return sigar.getProcEnv("$$", "ANT_HOME"); } catch (Exception se) { return null; } finally { sigar.close(); } } }
private Sigar sigar; public synchronized Sigar getSigar() { if (sigar == null) { sigar = new Sigar(); } return sigar; } public synchronized void forceRelease() { if (sigar != null) { sigar.close(); sigar = null; } } public long getPid() { return getSigar().getPid(); }
fqdn = "unknown"; } finally { sigar.close();
public static void main(String[] args) throws SigarException { String pid; if (args.length == 0) { pid = "$$"; //default to this process } else { pid = args[0]; } Sigar sigar = new Sigar(); ProcState procState = sigar.getProcState(pid); String state; System.out.println(procState.getName() + ": " + getStateString(procState.getState())); sigar.close(); } }
@Override public void onShutDown() { if (sigar != null) { sigar.close(); sigar = null; } }
private void closeLocalSigarInstance(Sigar sigar) { localSigarLock.lock(); try { sigar.close(); localSigarInstancesCount--; } finally { localSigarLock.unlock(); } }
private void closeLocalSigarInstance(Sigar sigar) { localSigarLock.lock(); try { sigar.close(); localSigarInstancesCount--; } finally { localSigarLock.unlock(); } }
void close() { if (sharedSigar != null) { sharedSigarLock.lock(); try { closed = true; sharedSigar.close(); sharedSigar = null; } finally { sharedSigarLock.unlock(); } } scheduledExecutorService.shutdownNow(); }
public void destroy() throws SystemInfoException { if (this.sigar instanceof Sigar) { try { ((Sigar) this.sigar).close(); } catch (RuntimeException e) { throw new SystemInfoException(e); } } }
public void destroy() throws SystemInfoException { if (this.sigar instanceof Sigar) { try { ((Sigar) this.sigar).close(); } catch (RuntimeException e) { throw new SystemInfoException(e); } } }
public static synchronized void release() { if (!SystemBoot.isRunningWithinGSC()) { if (sigar != null) { sigar.close(); sigar = null; } } } }
public void stop() { if (sigar != null) { sigar.close(); } if (reporter != null) { reporter.close(); } } }
public void kill(Process process, long pid) throws IOException { Sigar sigar = new Sigar(); try { sigar.kill(pid, "KILL"); } catch (SigarException sigarException) { throw new IOException("kill failed", sigarException); } finally { sigar.close(); } }
private void testItWorks() throws SigarException { final Sigar sigar = new Sigar(); sigar.getCpu(); sigar.close(); }
public void kill(Process process, long pid) throws IOException { Sigar sigar = new Sigar(); try { sigar.kill(pid, Sigar.getSigNum("KILL")); } catch (SigarException sigarException) { throw new IOException("kill failed", sigarException); } finally { sigar.close(); } }
public void kill(Process process, long pid) throws IOException { Sigar sigar = new Sigar(); try { sigar.kill(pid, Sigar.getSigNum("KILL")); } catch (SigarException sigarException) { throw new IOException("kill failed", sigarException); } finally { sigar.close(); } }
public static void main(String[] args) throws Exception { Sigar sigar = new Sigar(); NetstatData data = new NetstatData(); if (args.length != 0) { data.setFlags(args); } data.populate(sigar); data.print(System.out); sigar.close(); } }