@Override public void execute(Output output, String... params) throws Exception { String filter = Values.of(params).at(0).toLowerCase(); output.apply("%-39s %40s", "NAME", "VALUE"); output.separator(); for (Map.Entry<Object, Object> prop : System.getProperties().entrySet()) { if (Strings.isEmpty(filter) || prop.getKey().toString().toLowerCase().contains(filter) || prop.getValue() .toString() .toLowerCase() .contains( filter)) { output.apply("%-39s %40s", prop.getKey(), prop.getValue()); } } output.separator(); }
@Override @SuppressWarnings("squid:S1215") @Explain("The whole purpose of this call is to invoke the garbage collector.") public void execute(Output output, String... params) throws Exception { output.apply(LINE_FORMAT, "TYPE", "SIZE"); output.separator(); output.apply(LINE_FORMAT, "Free", NLS.formatSize(Runtime.getRuntime().freeMemory())); output.apply(LINE_FORMAT, "Total", NLS.formatSize(Runtime.getRuntime().totalMemory())); output.apply(LINE_FORMAT, "Max", NLS.formatSize(Runtime.getRuntime().maxMemory())); Runtime.getRuntime().gc(); output.separator(); output.apply(LINE_FORMAT, "Free", NLS.formatSize(Runtime.getRuntime().freeMemory())); output.apply(LINE_FORMAT, "Total", NLS.formatSize(Runtime.getRuntime().totalMemory())); output.apply(LINE_FORMAT, "Max", NLS.formatSize(Runtime.getRuntime().maxMemory())); output.separator(); }
output.separator(); for (StackTraceElement e : thread.getValue()) { output.apply("%-60s %19s", e.getClassName() + "." + e.getMethodName(), e.getFileName() + ":" + e.getLineNumber()); output.separator(); for (Tuple<String, String> e : cc.get().getMDC()) { output.apply("%-20s %59s", e.getFirst(), e.getSecond()); output.apply("Flow duration: %s", cc.get().getWatch().duration());
@Override public void execute(Output output, String... params) throws Exception { output.apply("%-20s %8s %8s %8s %12s %8s %8s", "POOL", "ACTIVE", output.separator(); for (AsyncExecutor exec : tasks.getExecutors()) { output.apply("%-20s %8d %8d %8d %12.1f %8d %8d", exec.getCategory(), exec.getActiveCount(), output.apply("Frequency Limited Tasks"); output.separator(); for (Tuple<String, LocalDateTime> task : tasks.getScheduledTasks()) { output.apply("%-60s %s", task.getFirst(), NLS.toUserString(task.getSecond())); output.apply("Background Loops"); output.separator(); for (BackgroundLoop loop : loops) { output.apply("%-60s %s", loop.getName(), loop.getExecutionInfo()); if (!ops.isEmpty()) { output.blankLine(); output.apply("Active Operations"); output.separator(); for (Operation op : ops) {
output.line(USAGE); } else if (!ACCEPTED_PARAMS.contains(params[0])) { output.apply("'%s' is not an accepted parameter!", params[0]); output.line(USAGE); } else { output.line("System Timers - Last Execution"); output.separator(); output.apply(LINE_FORMAT, "One-Minute", ts.getLastOneMinuteExecution()); output.apply(LINE_FORMAT, "Ten-Minutes", ts.getLastTenMinutesExecution()); output.apply(LINE_FORMAT, "One-Hour", ts.getLastHourExecution()); output.separator(); output.blankLine(); output.separator(); for (EveryDay task : ts.getDailyTasks()) { output.apply("%30s: %2sh", task.getConfigKeyName(), Sirius.getSettings().getInt(Timers.TIMER_DAILY_PREFIX + task.getConfigKeyName()));
output.line(c.getKey()); output.separator(); output.apply("%8s %9s %5s %5s %s", "AVG[ms]", "TOTAL[ms]", "RATIO", "COUNT", "NAME"); output.separator(); c.getValue().forEach(v -> { double totalTime = avg.getAvg() / 1000d * avg.getCount(); double percentTime = (totalTime * 100d) / delta; output.apply("%8.2f %9d %4.2f%% %5d %s", avg.getAvg() / 1000d, Math.round(totalTime),
@Override public void execute(Output output, String... params) throws Exception { if (!redis.isConfigured()) { output.line("Redis is not configured..."); return; } if (params.length > 1 && "unlock".equals(params[0])) { output.line("Killing lock: " + params[1]); redis.unlock(params[1], true); } output.line("Redis Statistics"); output.separator(); for (Map.Entry<String, String> e : redis.getInfo().entrySet()) { output.apply("%-40s %40s", e.getKey(), e.getValue()); } output.blankLine(); output.line("Redis Locks (use redis unlock <lock> to forcefully remove a lock)"); output.separator(); for (Redis.LockInfo info : redis.getLockList()) { output.apply("%-45s %-5s %-25s %-15s", info.name, info.value, info.since != null ? info.since.toString() : "-", info.ttl != null ? info.ttl.toString() + "s" : "-"); } }
@Override public void execute(Output output, String... params) throws Exception { Values values = Values.of(params); if ("query".equalsIgnoreCase(values.at(0).asString())) { query(output, values); } else if ("update".equalsIgnoreCase(values.at(0).asString())) { update(output, values); } else if ("delete".equalsIgnoreCase(values.at(0).asString())) { delete(output, values); } else if ("resave".equalsIgnoreCase(values.at(0).asString())) { resave(output, values); } else if ("unbalance".equalsIgnoreCase(values.at(0).asString())) { unbalance(output); } else if ("balance".equalsIgnoreCase(values.at(0).asString())) { balance(output); } else { output.apply("Unknown command: %s", values.at(0)); output.line("Use: query <type> <filter>"); output.line(" or update <type> <filter> <field> <value> (Limit 500)"); output.line(" or delete <type> <filter>"); output.line(" or resave <type> <filter>"); output.line(" or unbalance"); output.line(" or balance"); } }
@Override public void execute(Output output, String... params) { if (params.length > 0) { for (Cache<?, ?> c : CacheManager.getCaches()) { if (Value.indexOf(0, params).asString().equals(c.getName())) { output.apply("Flushing: %s", params[0]); c.clear(); } } } else { output.line("Use cache <name> to flush the given cache..."); } output.blankLine(); output.apply("%-53s %8s %8s %8s", "NAME", "SIZE", "MAX-SIZE", "HIT-RATE"); output.separator(); for (Cache<?, ?> c : CacheManager.getCaches()) { output.apply("%-53s %8d %8d %8d", c.getName(), c.getSize(), c.getMaxSize(), c.getHitRate()); } output.separator(); }
@Override public void execute(Output output, String... params) throws Exception { boolean withTraces = Value.indexOf(0, params).isFilled(); boolean includeWaiting = "Y".equals(Value.indexOf(1, params).asString()); if (withTraces) { outputThreadInfos(output, includeWaiting, params[0]); } else { output.line("Usage: threads [<filter> (or 'all')] [Y=include WAITING/NATIVE]"); output.separator(); output.apply("%-15s %10s %53s", "STATE", "ID", "NAME"); output.separator(); for (ThreadInfo info : t.dumpAllThreads(false, false)) { output.apply("%-15s %10s %53s", info.isInNative() ? "NATIVE" : info.getThreadState().name(), info.getThreadId(), info.getThreadName()); } output.separator(); } }
@Override public void execute(Output output, String... params) { if (params.length == 2) { output.apply("Setting %s to: %s", params[0], params[1]); Log.setLevel(params[0], Level.toLevel(params[1])); output.blankLine(); } else { output.line("Usage: logger <name> <LEVEL>"); output.blankLine(); output.line("Known loggers:"); output.separator(); for (Log l : Log.getAllLoggers()) { output.line(l.getName()); } output.separator(); } }
@Override public void execute(Output output, String... params) throws Exception { output.blankLine(); output.apply("C O N S O L E - %s", Product.getProduct()); output.blankLine(); output.apply("%-20s %s", "CMD", "DESCRIPTION"); output.separator(); List<Command> parts = new ArrayList<>(ctx.getParts(Command.class)); parts.sort(Comparator.comparing(Command::getName)); for (Command cmd : parts) { output.apply("%-20s %s", cmd.getName(), cmd.getDescription()); } output.separator(); }
private void outputAffectedRows(Output output, AtomicInteger rows) { output.separator(); output.apply("%s rows affected", rows.get()); output.blankLine(); }
@Override public void execute(Output output, String... params) throws Exception { output.apply("%-8s %-30s %15s", "STATE", "NAME", "VALUE"); output.separator(); for (Metric metric : metrics.getMetrics()) { output.apply("%-8s %-30s %15s", metric.getState(), metric.getLabel(), metric.getValueAsString()); } output.separator(); }