From ab185d49238c8e98ebe3b12ff946c8f67e8089dd Mon Sep 17 00:00:00 2001 From: "Christian P. MOMON" Date: Thu, 9 Dec 2021 11:53:17 +0100 Subject: [PATCH] Added directory as probe parameter. --- .../statoolinfos/cli/StatoolInfosCLI.java | 32 +++++++++++++++---- 1 file changed, 26 insertions(+), 6 deletions(-) diff --git a/src/fr/devinsy/statoolinfos/cli/StatoolInfosCLI.java b/src/fr/devinsy/statoolinfos/cli/StatoolInfosCLI.java index 545c41b..1053e3a 100644 --- a/src/fr/devinsy/statoolinfos/cli/StatoolInfosCLI.java +++ b/src/fr/devinsy/statoolinfos/cli/StatoolInfosCLI.java @@ -109,7 +109,7 @@ public final class StatoolInfosCLI message.appendln(" statoolinfos clear remove property files from conf"); message.appendln(" statoolinfos crawl crawl all file from conf and input"); message.appendln(" statoolinfos htmlize generate web pages from conf"); - message.appendln(" statoolinfos probe generate metrics files from conf"); + message.appendln(" statoolinfos probe [|] generate metrics files from conf"); message.appendln(" statoolinfos uptime update uptime journal"); message.appendln(); message.appendln(" statoolinfos format format property files in tiny way"); @@ -386,14 +386,34 @@ public final class StatoolInfosCLI else if (isMatching(args, "probe", "\\s*.+\\.conf\\s*")) { File configurationFile = new File(StringUtils.trim(args[1])); - try + + if (configurationFile.isDirectory()) { - StatoolInfos.probe(configurationFile); + Files inputs = FilesUtils.searchEndingWith(configurationFile, ".conf"); + for (File input : inputs) + { + try + { + StatoolInfos.probe(input); + } + catch (Exception exception) + { + logger.error("Error with [{}]: {}", input.getAbsoluteFile(), exception.getMessage()); + exception.printStackTrace(); + } + } } - catch (Exception exception) + else { - logger.error("Error with [{}]: {}", configurationFile.getAbsoluteFile(), exception.getMessage()); - exception.printStackTrace(); + try + { + StatoolInfos.probe(configurationFile); + } + catch (Exception exception) + { + logger.error("Error with [{}]: {}", configurationFile.getAbsoluteFile(), exception.getMessage()); + exception.printStackTrace(); + } } } else if (isMatching(args, "stat", "ip", "\\s*\\S+\\s*"))