bin/metrics-curl.rb in sensu-plugins-http-5.1.1 vs bin/metrics-curl.rb in sensu-plugins-http-6.0.0

- old
+ new

@@ -27,11 +27,10 @@ # LICENSE: # Copyright 2012 Joe Miller # Released under the same terms as Sensu (the MIT license); see LICENSE # for details. # - require 'socket' require 'English' require 'sensu-plugin/metric/cli' # @@ -56,13 +55,18 @@ long: '--scheme SCHEME', required: true, default: "#{Socket.gethostname}.curl_timings" def run + `type -t "curl" > /dev/null 2>&1` + unless $CHILD_STATUS == 0 + critical 'CRITICAL: curl executable not found in PATH on this system.'\ + ' If curl cannot be installed, consider using metrics_libcurl.rb instead.' + end + cmd = "LC_NUMERIC=C curl --silent --output /dev/null #{config[:curl_args]} " cmd += '-w "%{time_total},%{time_namelookup},%{time_connect},%{time_pretransfer},%{time_redirect},%{time_starttransfer},%{http_code}" ' cmd += config[:url] - output = `#{cmd}` (time_total, time_namelookup, time_connect, time_pretransfer, time_redirect, time_starttransfer, http_code) = output.split(',') output "#{config[:scheme]}.time_total", time_total output "#{config[:scheme]}.time_namelookup", time_namelookup