create mysql-server.cr as same content with mysql-server
Signed-off-by: Zhou Shengrui zhoushengrui1@huawei.com --- stats/crystal/mysql-server.cr | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) create mode 100755 stats/crystal/mysql-server.cr
diff --git a/stats/crystal/mysql-server.cr b/stats/crystal/mysql-server.cr new file mode 100755 index 00000000..82956c3d --- /dev/null +++ b/stats/crystal/mysql-server.cr @@ -0,0 +1,26 @@ +#!/usr/bin/env crystal +# frozen_string_literal: true + +require "../../lib/string_ext" + +results = [] of String + +while (line = STDIN.gets) + line = line.remediate_invalid_byte_sequence(replace: "_") unless line.valid_encoding? + line = line.to_s + + case line + # The output is as below: + # 200706 14:35:48 [ 99%] main.subquery_sj_innodb_all w8 [ pass ] 140 + # 200706 14:35:52 [ 99%] main.ssl_dynamic_persisted w1 [ fail ] 5953 + # 200706 14:35:59 [ 99%] main.mysql_upgrade_grant w7 [ skipped ] 80805 + when /[\s*\d+%]/ + results << line.split("]")[1].split[0] + ".pass: 1" if line.includes?("[ pass ]") + results << line.split("]")[1].split[0] + ".fail: 1" if line.includes?("[ fail ]") + results << line.split("]")[1].split[0] + ".skip: 1" if line.includes?("[ skipped ]") + end +end + +results.each do |item| + puts item +end