bin/metrics-ioping.rb in sensu-plugins-io-checks-2.0.0 vs bin/metrics-ioping.rb in sensu-plugins-io-checks-3.0.0

- old
+ new

@@ -1,7 +1,8 @@ #! /usr/bin/env ruby -# encoding: UTF-8 +# frozen_string_literal: true + # # metrics-ioping # # DESCRIPTION: # Push ioping stats into graphite @@ -94,22 +95,22 @@ stats = parse_0_8(str) stats = parse_0_6(str) if stats.nil? stats end - NUMBER = /\d+(?:\.\d+)?/ - TIME_UNIT = /(?:ns|us|ms|s|min|hour|day)/ + NUMBER = /\d+(?:\.\d+)?/.freeze + TIME_UNIT = /(?:ns|us|ms|s|min|hour|day)/.freeze TIME_UNITS = { 'ns' => 1e-9, 'us' => 1e-6, 'ms' => 1e-3, 's' => 1, 'min' => 60, 'hour' => 60 * 60, 'day' => 24 * 60 * 60 }.freeze # #YELLOW - STATS_HEADER = /min\/avg\/max\/mdev/ + STATS_HEADER = /min\/avg\/max\/mdev/.freeze def parse_0_6(str) value = /#{NUMBER}/ sep = /\// pattern = /^#{STATS_HEADER} = (#{value})#{sep}(#{value})#{sep}(#{value})#{sep}(#{value}) (#{TIME_UNIT})$/