Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Newer
Older
100755 61 lines (50 sloc) 1.678 kB
eb716fa @flores Tests for new SSL connections; just a wrapper around openssl s_time w…
flores authored
1 #!/usr/bin/env ruby
2 #################
3 #
4 # This script is a wrapper around openssl s_time to ensure
5 # clients can make new connections to a resource, as well
6 # as time those connections.
7 #
8 # OpenSSL is licensed under the OpenSSL license.
9 #
10 # This script was written by carlo@borderstylo.com and is released
11 # under a modified BeerWare license: You are free to share or modify
12 # this script as your needs require! There is no warranty, but if
13 # we ever meet, let's have beer.
14 #
15 #################
16
17 if ( ARGV.length != 1 || ARGV[0] =~ /help/ )
18 puts "usage: #{$0} host:port
19 checks if new ssl connections can be made to host:port
20 where host can be a fqdn, ip, localhost, etc
21 critical if there is a tcp error
22 statistics for number of successful connections"
23 exit
24 end
25
26 host = ARGV[0]
27
28 # seconds to test for
29 time = 10
30
31 openssl = `which openssl`
32
33 unless openssl =~ /\w+/
6bf8008 @flores s/critical/err/g
flores authored
34 raise("status err #{$0} needs openssl in the \$PATH")
eb716fa @flores Tests for new SSL connections; just a wrapper around openssl s_time w…
flores authored
35 end
36
37 openssl=openssl.chomp
38
39 # pick one of the ciphers
40 cipher = `#{openssl} ciphers HIGH`.grep /:.+?:/
41
6bf8008 @flores s/critical/err/g
flores authored
42 results = `#{openssl} s_time -connect #{host} -time #{time} -new -cipher #{cipher} 2>&1` || raise("status err cannot test #{host}!")
eb716fa @flores Tests for new SSL connections; just a wrapper around openssl s_time w…
flores authored
43
44 # how openssl displays new connections
45 if results.grep /tttttttttttttttttttttttttttttttttt/
46 results.each do |line|
47 if line =~ /^(\d+) connections in (.+)?\; (.+)? connections\/user/
48 conn = $1
49 initialtime = $2
50 connrate = $3
51 puts "status ok ok
52 metric connections int #{conn}
53 metric connections_initial_time float #{initialtime}
54 metric connections_rate float #{connrate}"
55 end
56 end
57 else
6bf8008 @flores s/critical/err/g
flores authored
58 puts "status err unexpected results! try running #{openssl} s_client -connect #{host} manually"
eb716fa @flores Tests for new SSL connections; just a wrapper around openssl s_time w…
flores authored
59
60 end
Something went wrong with that request. Please try again.