diff --git a/hadoop-hdds/docs/content/tools/AuditParser.md b/hadoop-hdds/docs/content/tools/AuditParser.md index ee2acd959c5e..ebc5c8ae6a86 100644 --- a/hadoop-hdds/docs/content/tools/AuditParser.md +++ b/hadoop-hdds/docs/content/tools/AuditParser.md @@ -40,25 +40,25 @@ UNIQUE(datetime,level,logger,user,ip,op,params,result)) Usage: {{< highlight bash >}} -ozone auditparser [COMMAND] [PARAM] +ozone debug auditparser [COMMAND] [PARAM] {{< /highlight >}} To load an audit log to database: {{< highlight bash >}} -ozone auditparser load +ozone debug auditparser load {{< /highlight >}} Load command creates the audit table described above. To run a custom read-only query: {{< highlight bash >}} -ozone auditparser query {{< /highlight >}} Audit Parser comes with a set of templates(most commonly used queries). To run a template query: {{< highlight bash >}} -ozone auditparser template +ozone debug auditparser template {{< /highlight >}} Following templates are available: diff --git a/hadoop-hdds/docs/content/tools/AuditParser.zh.md b/hadoop-hdds/docs/content/tools/AuditParser.zh.md index 10786d5174a1..ffe0617328a9 100644 --- a/hadoop-hdds/docs/content/tools/AuditParser.zh.md +++ b/hadoop-hdds/docs/content/tools/AuditParser.zh.md @@ -38,25 +38,25 @@ UNIQUE(datetime,level,logger,user,ip,op,params,result)) 用法: {{< highlight bash >}} -ozone auditparser <数据库文件的路径> [命令] [参数] +ozone debug auditparser <数据库文件的路径> [命令] [参数] {{< /highlight >}} 将审计日志加载到数据库: {{< highlight bash >}} -ozone auditparser <数据库文件的路径> load <审计日志的路径> +ozone debug auditparser <数据库文件的路径> load <审计日志的路径> {{< /highlight >}} Load 命令会创建如上所述的审计表。 运行一个自定义的只读查询: {{< highlight bash >}} -ozone auditparser <数据库文件的路径> query <双引号括起来的 select 查询> +ozone debug auditparser <数据库文件的路径> query <双引号括起来的 select 查询> {{< /highlight >}} 审计解析起自带了一些模板(最常用的查询) 运行模板查询: {{< highlight bash >}} -ozone auditparser <数据库文件的路径 template <模板名称> +ozone debug auditparser <数据库文件的路径 template <模板名称> {{< /highlight >}} Ozone 提供了以下模板: diff --git a/hadoop-ozone/dist/src/main/smoketest/auditparser/auditparser.robot b/hadoop-ozone/dist/src/main/smoketest/auditparser/auditparser.robot index 55e4ed841d42..5af45d97c552 100644 --- a/hadoop-ozone/dist/src/main/smoketest/auditparser/auditparser.robot +++ b/hadoop-ozone/dist/src/main/smoketest/auditparser/auditparser.robot @@ -42,15 +42,15 @@ Testing audit parser ${logdir} = Get Environment Variable OZONE_LOG_DIR /var/log/ozone ${logfile} = Execute ls -t "${logdir}" | grep om-audit | head -1 - Execute ozone auditparser "${auditworkdir}/audit.db" load "${logdir}/${logfile}" - ${result} = Execute ozone auditparser "${auditworkdir}/audit.db" template top5cmds + Execute ozone debug auditparser "${auditworkdir}/audit.db" load "${logdir}/${logfile}" + ${result} = Execute ozone debug auditparser "${auditworkdir}/audit.db" template top5cmds Should Contain ${result} ALLOCATE_KEY - ${result} = Execute ozone auditparser "${auditworkdir}/audit.db" template top5users + ${result} = Execute ozone debug auditparser "${auditworkdir}/audit.db" template top5users Run Keyword If '${SECURITY_ENABLED}' == 'true' Set username Should Contain ${result} ${user} - ${result} = Execute ozone auditparser "${auditworkdir}/audit.db" query "select count(*) from audit where op='CREATE_VOLUME' and RESULT='SUCCESS'" + ${result} = Execute ozone debug auditparser "${auditworkdir}/audit.db" query "select count(*) from audit where op='CREATE_VOLUME' and RESULT='SUCCESS'" ${result} = Convert To Number ${result} Should be true ${result}>=1 - ${result} = Execute ozone auditparser "${auditworkdir}/audit.db" query "select count(*) from audit where op='CREATE_BUCKET' and RESULT='SUCCESS'" + ${result} = Execute ozone debug auditparser "${auditworkdir}/audit.db" query "select count(*) from audit where op='CREATE_BUCKET' and RESULT='SUCCESS'" ${result} = Convert To Number ${result} Should be true ${result}>=${buckets} diff --git a/hadoop-ozone/dist/src/shell/ozone/ozone b/hadoop-ozone/dist/src/shell/ozone/ozone index d868f0217e45..08bbf1acfe63 100755 --- a/hadoop-ozone/dist/src/shell/ozone/ozone +++ b/hadoop-ozone/dist/src/shell/ozone/ozone @@ -36,7 +36,6 @@ function ozone_usage ozone_add_option "--jvmargs arguments" "append JVM options to any existing options defined in the OZONE_OPTS environment variable. Any defined in OZONE_CLIENT_OPTS will be append after these jvmargs" ozone_add_option "--validate (continue)" "validates if all jars as indicated in the corresponding OZONE_RUN_ARTIFACT_NAME classpath file are present, command execution shall continue post validation failure if 'continue' is passed" - ozone_add_subcommand "auditparser" client "runs audit parser tool" ozone_add_subcommand "classpath" client "prints the class path needed for running ozone commands" ozone_add_subcommand "datanode" daemon "run a HDDS datanode" ozone_add_subcommand "envvars" client "display computed Hadoop environment variables" @@ -83,10 +82,6 @@ function ozonecmd_case RATIS_OPTS="-Dorg.apache.ratis.thirdparty.io.netty.allocator.useCacheForAllThreads=false ${RATIS_OPTS}" case ${subcmd} in - auditparser) - OZONE_CLASSNAME=org.apache.hadoop.ozone.audit.parser.AuditParser - OZONE_RUN_ARTIFACT_NAME="ozone-tools" - ;; classpath) if [[ "$#" -gt 0 ]]; then OZONE_RUN_ARTIFACT_NAME="$1" @@ -309,7 +304,13 @@ if [[ $# = 0 ]]; then fi OZONE_SUBCMD=$1 -shift + +if [[ "$OZONE_SUBCMD" == "auditparser" ]]; then + echo "warning: 'ozone auditparser' is deprecated, use 'ozone debug auditparser' instead." + OZONE_SUBCMD="debug" +else + shift +fi if ozone_need_reexec ozone "${OZONE_SUBCMD}"; then diff --git a/hadoop-ozone/tools/src/main/java/org/apache/hadoop/ozone/audit/parser/AuditParser.java b/hadoop-ozone/tools/src/main/java/org/apache/hadoop/ozone/debug/audit/parser/AuditParser.java similarity index 78% rename from hadoop-ozone/tools/src/main/java/org/apache/hadoop/ozone/audit/parser/AuditParser.java rename to hadoop-ozone/tools/src/main/java/org/apache/hadoop/ozone/debug/audit/parser/AuditParser.java index ccfadba28197..067c5e549138 100644 --- a/hadoop-ozone/tools/src/main/java/org/apache/hadoop/ozone/audit/parser/AuditParser.java +++ b/hadoop-ozone/tools/src/main/java/org/apache/hadoop/ozone/debug/audit/parser/AuditParser.java @@ -15,20 +15,21 @@ * limitations under the License. */ -package org.apache.hadoop.ozone.audit.parser; +package org.apache.hadoop.ozone.debug.audit.parser; -import org.apache.hadoop.hdds.cli.GenericCli; +import org.apache.hadoop.hdds.cli.DebugSubcommand; import org.apache.hadoop.hdds.cli.HddsVersionProvider; -import org.apache.hadoop.ozone.audit.parser.handler.LoadCommandHandler; -import org.apache.hadoop.ozone.audit.parser.handler.QueryCommandHandler; -import org.apache.hadoop.ozone.audit.parser.handler.TemplateCommandHandler; +import org.apache.hadoop.ozone.debug.audit.parser.handler.LoadCommandHandler; +import org.apache.hadoop.ozone.debug.audit.parser.handler.QueryCommandHandler; +import org.apache.hadoop.ozone.debug.audit.parser.handler.TemplateCommandHandler; +import org.kohsuke.MetaInfServices; import picocli.CommandLine.Command; import picocli.CommandLine.Parameters; /** * Ozone audit parser tool. */ -@Command(name = "ozone auditparser", +@Command(name = "auditparser", description = "Shell parser for Ozone Audit Logs", subcommands = { LoadCommandHandler.class, @@ -37,7 +38,8 @@ }, versionProvider = HddsVersionProvider.class, mixinStandardHelpOptions = true) -public class AuditParser extends GenericCli { +@MetaInfServices(DebugSubcommand.class) +public class AuditParser implements DebugSubcommand { /* <.db file path> load <.db file path> template