Pls ingore this email.
On Tue, Feb 09, 2021 at 02:12:22PM +0800, Wang Chenglong wrote:
[How] ansible_stats_openeuler < ${job_output}
Signed-off-by: Wang Chenglong 18509160991@163.com
stats/ansible_test | 102 ++++++++++++++++++++++++++++++++++++++++----- 1 file changed, 92 insertions(+), 10 deletions(-)
diff --git a/stats/ansible_test b/stats/ansible_test index 4c7d07b3e..556d4bcdd 100755 --- a/stats/ansible_test +++ b/stats/ansible_test @@ -1,15 +1,97 @@ #!/usr/bin/env ruby
+require 'json'
while (line = STDIN.gets)
- case line.chomp!
- when /ok=(\d+)\s+changed=(\d+)\s+unreachable=(\d+)\s+failed=(\d+)\s+skipped=(\d+)\s+rescued=(\d+)\s+ignored=(\d+)/
- puts "ansible_test.total.nr_ok: #{$1}"
- puts "ansible_test.total.nr_changed: #{$2}"
- puts "ansible_test.total.nr_failed: #{$4}"
- puts "ansible_test.total.nr_skipped: #{$5}"
- puts "ansible_test.total.nr_rescued: #{$6}"
- puts "ansible_test.total.nr_ignored: #{$7}"
- when /playbook_run_on_fail/
- puts line
- line = line.gsub(/'/, ' ')
- ansible_stats_error = `echo '#{line}' |grep -E 'FAILED! |failed: .*}$' | awk -F'=>' '{$1="";print $0}'`
- next if ansible_stats_error.empty?
- a = JSON.load(ansible_stats_error)
+# a['msg'].each_line do
- unless a['msg'].nil?
- # When running some plug-in, the file was not found
- if a['msg'].match(/No file was found when using (.+)./)
puts "files.error.no-file-was-found-when-using.#{$1}: 1"
puts "files.error.no-file-was-found-when-using.#{$1}.message: #{ansible_stats_error}"
- end
- # No such command
- if a['msg'].match(/No such file or directory: b (.+) :/)
puts "command.error.no-such-file-or-directory.#{$1}: 1"
puts "command.error.no-such-file-or-directory.#{a['cmd']}.message: #{ansible_stats_error}"
- end
- # The URL of the RPM is invalid
- if a['msg'].match(/Failure downloading (.+), /)
puts "download.error.http-error-404 [#{$1}]: 1"
puts "download.error.http-error-404 [#{$1}]: #{ansible_stats_error}"
- end
- # Failed to download the yum repodata
- if a['msg'].match(/Failed to download metadata for repo (.+) :/)
puts "download.error.failed-to-download-metadata.#{$1}: 1"
puts "download.error.failed-to-download-metadata.#{$1}.message: #{ansible_stats_error}"
- end
- if a['msg'].match(/Failed to download packages: Cannot download (.+):/)
puts "download.error.failed-to-download-package.#{$1}: 1"
puts "download.error.failed-to-download-package.#{$1}.message: #{ansible_stats_error}"
- end
- # The task includes an option with an undefined variable.
- if a['msg'].match(/: (.+) is undefined/)
puts "syntax.error.an-undefined-variable.#{$1}: 1"
puts "syntax.error.an-undefined-variable.#{$1}.message: #{ansible_stats_error}"
- end
- # The command runing error.
- if a['msg'].match(/non-zero return code/)
puts "command.error[#{a['cmd']}]: 1"
puts "command.error [#{a['cmd']}].message: #{ansible_stats_error}"
- end
- # Some service could not fand the requested host.
- if a['msg'].match(/Could not find the requested service (.+): host/)
puts "request.error.could-not-find-service-host.#{$1}: 1"
puts "request.error.could-not-find-service-host.#{$1}.messgae: #{ansible_stats_error}"
- end
- # Unable to start some services
- if a['msg'].match(/Unable to start service (.+):/)
puts "service.error.unable-to-star-service.#{$1}: 1"
puts "service.error.unable-to-star-service.#{$1}.message: #{ansible_stats_error}"
- end
- # Some role in not sipported this system
- if a['msg'].match(/(.+) is not supported/)
puts "system.error.not-supported.#{$1.gsub(/ /, '-')}: 1"
puts "system.error.not-supported.message: #{ansible_stats_error}"
- end
- # failed to create temporary content file: The read operation timed out.
- if a['msg'].match(/The read operation timed out/)
puts 'connection.error.read-timed-out: 1'
puts "read.error.read-timed-out.message: #{ansible_stats_error}"
- end
- end
- unless a['failures'].nil?
- a['failures'].each do |items|
# Failed to install some of the specified packages.
items.match(/No package (.+) available/)
puts "yum.error.no-package-match.#{$1}: 1"
puts "yum.error.no-package-match.#{$1}.message: #{line}"
- end
- end
- next if a['message'].nil?
- # Could not find or access ansible yaml.
- if a['message'].to_s.match(/Could not find or access (.+) /)
- puts "yaml.error.not-find-yml.#{$1}: 1"
- puts "yaml.error.not-find-yml.#{$1}.message: #{ansible_stats_error}" end
end
2.23.0