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()); }
public void output(long pid) throws SigarException { String[] argv = this.proxy.getProcArgs(pid); try { String exe = this.proxy.getProcExe(pid).getName(); println("exe=" + exe); } catch (SigarNotImplementedException e) { } catch (SigarException e) { println("exe=???"); } try { String cwd = this.proxy.getProcExe(pid).getCwd(); println("cwd=" + cwd); } catch (SigarNotImplementedException e) { } catch (SigarException e) { println("cwd=???"); } for (int i=0; i<argv.length; i++) { println(" " + i + "=>" + argv[i] + "<="); } }
/** * @return null if process executable or cwd is unavailable. Otherwise the Cwd as returned from the * process executable. * @throws SystemInfoException */ public String getCurrentWorkingDirectory() throws SystemInfoException { String result = null; try { if (null != ProcessInfo.this.procExe) { result = ProcessInfo.this.procExe.getCwd(); } } catch (Exception e) { ProcessInfo.this.handleSigarCallException(e, "procExe.getCwd()"); } return result; }
/** * @return null if process executable or cwd is unavailable. Otherwise the Cwd as returned from the * process executable. * @throws SystemInfoException */ public String getCurrentWorkingDirectory() throws SystemInfoException { String result = null; try { if (null != ProcessInfo.this.procExe) { result = ProcessInfo.this.procExe.getCwd(); } } catch (Exception e) { ProcessInfo.this.handleSigarCallException(e, "procExe.getCwd()"); } return result; }
private File getAbsoluteFile(File file) { File absoluteFile; if (!file.isAbsolute()) { if ((this.process != null) && (this.process.getExecutable() != null)) { String cwd = this.process.getExecutable().getCwd(); absoluteFile = new File(cwd, file.getPath()); } else { String homeDir = getSystemProperties().get(HOME_DIR_SYSPROP); if (homeDir != null) { File binDir = new File(homeDir, "bin"); absoluteFile = new File(binDir, file.getPath()); } else { LOG.error("Failed to resolve relative properties file path [" + file + "]."); return null; } } } else { absoluteFile = file; } return absoluteFile; }
public Object doMonitor(Map<String, Object> params) throws Exception { Map<String, Object> result = new HashMap<>(); ProcExe procExe = SigarFactory.getSigar().getProcExe(SigarFactory.getSigar().getPid()); result.put("cmd", procExe.getCwd()); result.put("name", procExe.getName()); result.put("inputArguments", ManagementFactory.getRuntimeMXBean().getInputArguments()); return result; }
protected File getHomeDir(ProcessInfo processInfo, JavaCommandLine javaCommandLine) { String home = javaCommandLine.getSystemProperties().get(HOME_DIR_SYSPROP); File homeDir = new File(home); if (!homeDir.isAbsolute()) { if (processInfo.priorSnaphot().getExecutable() == null) { throw new RuntimeException(HOME_DIR_SYSPROP + " for AS7 process " + processInfo + " is a relative path, and the RHQ Agent process does not have permission to resolve it."); } String cwd = processInfo.priorSnaphot().getExecutable().getCwd(); homeDir = new File(cwd, home); } return new File(FileUtils.getCanonicalPath(homeDir.getPath())); }
String cwd = parentProcessExe.getCwd(); startScriptFile = new File(cwd, startScriptFile.getPath()); startScriptFile = new File(FileUtils.getCanonicalPath(startScriptFile.getPath()));
protected File getLogDir(ProcessInfo process, AS7CommandLine commandLine, File baseDir) { String logDirString = commandLine.getSystemProperties().get(getLogDirSystemPropertyName()); File logDir; if (logDirString != null) { logDir = new File(logDirString); if (!logDir.isAbsolute()) { if (process.priorSnaphot().getExecutable() == null) { throw new RuntimeException(getLogDirSystemPropertyName() + " for AS7 process " + process + " is a relative path, and the RHQ Agent process does not have permission to resolve it."); } String cwd = process.priorSnaphot().getExecutable().getCwd(); logDir = new File(cwd, logDirString); } logDir = new File(FileUtils.getCanonicalPath(logDir.getPath())); } else { logDir = new File(baseDir, getDefaultLogDirName()); } return logDir; }
protected File getBaseDir(ProcessInfo process, JavaCommandLine javaCommandLine, File homeDir) { String baseDirString = javaCommandLine.getSystemProperties().get(getBaseDirSystemPropertyName()); File baseDir; if (baseDirString != null) { baseDir = new File(baseDirString); if (!baseDir.isAbsolute()) { if (process.priorSnaphot().getExecutable() == null) { baseDir = new File(homeDir, baseDirString); if (!baseDir.exists()) { throw new RuntimeException(getBaseDirSystemPropertyName() + " for AS7 process " + process + " is a relative path, and the RHQ Agent process does not have permission to resolve it."); } } else { String cwd = process.priorSnaphot().getExecutable().getCwd(); baseDir = new File(cwd, baseDirString); if (!baseDir.exists()) { baseDir = new File(homeDir, baseDirString); } } } baseDir = new File(FileUtils.getCanonicalPath(baseDir.getPath())); } else { baseDir = new File(homeDir, getDefaultBaseDirName()); } return baseDir; }
protected File getConfigDir(ProcessInfo process, JavaCommandLine javaCommandLine, File baseDir) { String configDirString = javaCommandLine.getSystemProperties().get(getConfigDirSystemPropertyName()); File configDir; if (configDirString != null) { configDir = new File(configDirString); if (!configDir.isAbsolute()) { if (process.priorSnaphot().getExecutable() == null) { throw new RuntimeException(getConfigDirSystemPropertyName() + " for AS7 process " + process + " is a relative path, and the RHQ Agent process does not have permission to resolve it."); } String cwd = process.priorSnaphot().getExecutable().getCwd(); configDir = new File(cwd, configDirString); } configDir = new File(FileUtils.getCanonicalPath(configDir.getPath())); } else { configDir = new File(baseDir, getDefaultConfigDirName()); } return configDir; }