public OSDetails probeDetails() { if (uid == null) { return new OSDetails(); } long totalSwapSpaceSize = -1; if (getTotalSwapSpaceSize != null) { try { totalSwapSpaceSize = (Long) getTotalSwapSpaceSize.invoke(operatingSystemMXBean); } catch (Exception e) { // ignore } } long totalPhysicalMemorySize = -1; if (getTotalPhysicalMemorySize != null) { try { totalPhysicalMemorySize = (Long) getTotalPhysicalMemorySize.invoke(operatingSystemMXBean); } catch (Exception e) { // ignore } } OSNetInterfaceDetails[] osNetInterfaceDetailsArray = retrieveOSNetInterfaceDetails(); return new OSDetails(uid, operatingSystemMXBean.getName(), operatingSystemMXBean.getArch(), operatingSystemMXBean.getVersion(), operatingSystemMXBean.getAvailableProcessors(), totalSwapSpaceSize, totalPhysicalMemorySize, localHostName, localHostAddress, osNetInterfaceDetailsArray, null, null); }
private static LogEntries toEntries(LogProcessType type, long pid, File[] files, List<LogEntry> entries, long latestLogTimestamp) { LinkedList<LogEntry> reveredEntries = new LinkedList<LogEntry>(); LogEntry fileMarker = null; for (ListIterator<LogEntry> it = entries.listIterator(entries.size()); it.hasPrevious(); ) { LogEntry entry = it.previous(); if (entry.isFileMarker()) { if (fileMarker != null) { reveredEntries.addFirst(fileMarker); } fileMarker = entry; } else { reveredEntries.add(entry); } } if (fileMarker != null) { reveredEntries.addFirst(fileMarker); } OSDetails osDetails = OSHelper.getDetails(); return new LogEntries(type, reveredEntries, files.length, pid, latestLogTimestamp, osDetails.getHostName(), osDetails.getHostAddress()); }
public static LogEntries logEntries(final LogProcessType type, final long pid, LogEntryMatcher matcher) throws IOException { if (!RollingFileHandler.isMonitoringCreatedFiles()) { throw new IOException("Logger not monitoring created files..."); } File logDir = RollingFileHandler.filesCreated()[0].getParentFile(); File[] logFiles = BootIOUtils.listFiles(logDir, new FilenameFilter() { @Override public boolean accept(File dir, String name) { String nameInLowerCase = name.toLowerCase(); String typeNameInLowerCase = type.name().toLowerCase(); return nameInLowerCase.contains("-" + pid) || nameInLowerCase.contains("_" + pid) && (nameInLowerCase.contains("_" + typeNameInLowerCase) || nameInLowerCase.contains("-" + typeNameInLowerCase)); } }); if (logFiles.length == 0) { OSDetails osDetails = OSHelper.getDetails(); return new LogEntries(type, pid, osDetails.getHostName(), osDetails.getHostAddress()); } Arrays.sort(logFiles, new NewestToOldestFileComparator()); return logEntriesDirect(logFiles, pid, type, matcher); }
return new OSDetails(uid, sys.getName(), sys.getArch(), sys.getVersion(), infos[0].getTotalCores(), sigar.getSwap().getTotal(), sigar.getMem().getTotal(), localHostName, localHostAddress, netInterfaceConfigArray,
SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss,SSS"); OSDetails osDetails = OSHelper.getDetails(); matcher.initialize(new LogEntryMatcher.InitializationContext(osDetails.getHostAddress(), osDetails.getHostName(), pid, type)); StringBuilder sb = new StringBuilder(); File latestFile = files[0];