20 | <% end %>
21 |
22 |
23 | <% end %>
24 |
25 |
26 |
--------------------------------------------------------------------------------
/Gemfile.lock:
--------------------------------------------------------------------------------
1 | GEM
2 | remote: https://rubygems.org/
3 | specs:
4 | diff-lcs (1.3)
5 | json (2.1.0)
6 | mustermann (1.0.2)
7 | puma (3.11.3)
8 | rack (2.0.4)
9 | rack-protection (2.0.1)
10 | rack
11 | rack-test (0.8.3)
12 | rack (>= 1.0, < 3)
13 | rake (12.3.0)
14 | rspec (3.7.0)
15 | rspec-core (~> 3.7.0)
16 | rspec-expectations (~> 3.7.0)
17 | rspec-mocks (~> 3.7.0)
18 | rspec-core (3.7.1)
19 | rspec-support (~> 3.7.0)
20 | rspec-expectations (3.7.0)
21 | diff-lcs (>= 1.2.0, < 2.0)
22 | rspec-support (~> 3.7.0)
23 | rspec-mocks (3.7.0)
24 | diff-lcs (>= 1.2.0, < 2.0)
25 | rspec-support (~> 3.7.0)
26 | rspec-support (3.7.1)
27 | sinatra (2.0.1)
28 | mustermann (~> 1.0)
29 | rack (~> 2.0)
30 | rack-protection (= 2.0.1)
31 | tilt (~> 2.0)
32 | tilt (2.0.8)
33 |
34 | PLATFORMS
35 | ruby
36 |
37 | DEPENDENCIES
38 | json
39 | puma
40 | rack-test
41 | rake
42 | rspec
43 | sinatra
44 |
45 | BUNDLED WITH
46 | 1.16.0
47 |
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | varnish status
2 | ==============
3 | varnish status provides basic information about varnish backend and director health.
4 | Data is represented as HTML and JSON.
5 |
6 | Prerequisitions
7 | ---------------
8 | You should have installed ruby-1.9.3 and the bundler rubygem (gem install bundler).
9 | The user running varnish_status need access to varnishadm on the machine.
10 |
11 | Installation
12 | ------------
13 | clone the repository on the same machine, where you run a varnish instance.
14 |
15 | git clone https://github.com/otto-de/varnish_status
16 | cd varnish_status.git
17 | bundle install
18 | bundle exec puma
19 |
20 | Configuration
21 | -------------
22 | varnish\_status is using the varnish command line tool varnishadm. Define your specific varnishadm command and special parameters in the config.yaml.
23 |
24 | Namingconvention for backends in vcl
25 | ------------------------------------
26 | varnish\_status expects, you are using naming conventions in your vcl for your backends, \\_\. Example:
27 |
28 | backend server1_pool1 { ... }
29 | backend server2_pool1 { ... }
30 |
31 | director pool1 round-robin {
32 | { .backend = server1_pool1; }
33 | { .backend = server2_pool1; }
34 | }
35 |
36 | Because the backend.list command in varnishadm does not group backends to directors automatically, varnish\_status is using the underscore as seperator to group backends in directors. If no underscore is found in the backend name, varnish\_status create a group for each backend.
37 |
38 | Testing
39 | -------
40 | varnish\_status is tested with rspec, see tests/*.rb for details. You can run the tests with:
41 |
42 | rake spec
43 |
44 | Run in production
45 | -----------------
46 | To run varnish\_status in production, we recommend using unicorn (http://rubygems.org/gems/unicorn)
47 | For testing you can run varnish_status in a puma instance. Just checkout, edit the config.yaml, run a bundle install and bundle exec puma.
48 |
49 | Open http://myhosthame:9292/ for the HTML reprensation.
50 |
51 | Open http://myhostname:9292/internal/status for a basic status json.
52 |
53 | Open http://myhostname:9292/internal/details for more details in the json status response.
54 |
55 |
--------------------------------------------------------------------------------
/sano.rb:
--------------------------------------------------------------------------------
1 | require "json"
2 | require "socket"
3 | require "time"
4 |
5 | module Sano
6 | OK = 'OK'
7 | WARNING = 'WARNING'
8 | CRITICAL = 'CRITICAL'
9 |
10 | LEVELS = [ OK, WARNING, CRITICAL]
11 |
12 | class Page
13 | attr_accessor :application, :status, :system
14 |
15 | def initialize
16 | @details = []
17 | @datasources = []
18 | @application = Application.new
19 | @system = SystemInfo.new
20 | @properties = {}
21 | end
22 |
23 | def add_property(key, value)
24 | @properties[key] = value
25 | end
26 |
27 | def add_datasource(ds)
28 | @datasources << ds
29 | end
30 |
31 | def add_detail(detail)
32 | @details << detail
33 |
34 | calculate_status
35 | true
36 | end
37 |
38 | def to_json
39 | json_hash = {
40 | 'application' => @application.to_h.merge({'statusDetails' => {}}),
41 | 'system' => @system.to_h,
42 | 'datasources' => [],
43 | 'properties' => @properties
44 | }
45 |
46 | @details.each do |d|
47 | json_hash['application']['statusDetails'][d.name] = d.to_h
48 | end
49 |
50 | @datasources.each do |d|
51 | json_hash['datasources'] << d.to_h
52 | end
53 |
54 | JSON.dump(json_hash)
55 | end
56 |
57 | protected
58 |
59 | def calculate_status
60 | tmp_status = OK
61 |
62 | @details.each do |d|
63 | if LEVELS.index(d.status) > LEVELS.index(tmp_status)
64 | tmp_status = d.status
65 | end
66 | end
67 |
68 | @application.status = tmp_status
69 | @status = tmp_status
70 | end
71 | end
72 |
73 | class Application < Struct.new(:name, :status, :version)
74 | def to_h
75 | {
76 | 'name' => name,
77 | 'status' => status,
78 | 'version' => (version || "UNSET")
79 | }
80 | end
81 | end
82 |
83 | class SystemInfo
84 | attr_accessor :hostname, :system_time
85 |
86 | def initialize
87 | @hostname = Socket.gethostbyname(Socket.gethostname).first
88 | @system_time = Time.now
89 | end
90 |
91 | def to_h
92 | {
93 | 'hostname' => @hostname,
94 | 'systemTime' => @system_time.iso8601
95 | }
96 | end
97 | end
98 |
99 | class Detail < Struct.new(:name, :status, :message, :link)
100 | attr_accessor :properties
101 |
102 | def initialize
103 | status = OK
104 | @properties = {}
105 | end
106 |
107 | def self.create(&block)
108 | d = Detail.new
109 | yield(d) if block_given?
110 |
111 | d
112 | end
113 |
114 | def to_h
115 | {
116 | 'name' => name,
117 | 'status' => status,
118 | 'properties' => properties,
119 | 'message' => message,
120 | 'uri' => link
121 | }
122 | end
123 | end
124 |
125 | class Datasource
126 | attr_accessor :name, :type, :properties, :hosts
127 |
128 | def initialize(name, type, hosts = [], properties = {})
129 | @name = name
130 | @type = type
131 | @hosts = hosts
132 | @properties = properties
133 | end
134 |
135 | def self.create(&block)
136 | datasource = Datasource.new("unnamed", "unknown")
137 |
138 | yield(datasource) if block_given?
139 |
140 | datasource
141 | end
142 |
143 | def to_h
144 | {
145 | 'name' => @name,
146 | 'type' => @type,
147 | 'hosts' => @hosts,
148 | 'properties' => @properties
149 | }
150 | end
151 | end
152 | end
153 |
--------------------------------------------------------------------------------
/app.rb:
--------------------------------------------------------------------------------
1 | #!/usr/bin/env ruby
2 |
3 |
4 | require "sinatra"
5 | require "json"
6 | require "timeout"
7 | require "pp"
8 | require "ostruct"
9 | require "yaml"
10 |
11 | require "./sano"
12 |
13 | class VarnishBackendStatus
14 | attr_accessor :directors
15 |
16 | class Backend < OpenStruct
17 | def to_hash
18 | table
19 | end
20 | end
21 |
22 | class Director
23 | attr_reader :name, :status, :availability, :healthy_backends, :sick_backends
24 | attr_accessor :backends
25 |
26 | def initialize(name)
27 | @name = name
28 | @backends = []
29 | @status = "WARNING"
30 | @availability = 0
31 |
32 | @healthy_backends = 0
33 | @sick_backends = 0
34 | end
35 |
36 | def add_backend(be)
37 | @backends << be
38 | recalc_status
39 |
40 | true
41 | end
42 |
43 | def to_hash
44 | recalc_status
45 |
46 | {
47 | :name => @name,
48 | :status => @status,
49 | :backends => @backends.map { |b| b.to_hash },
50 | :availability => @availability,
51 | :healthy_backends => @healthy_backends,
52 | :sick_backends => @sick_backends,
53 | }
54 | end
55 |
56 | private
57 |
58 | def recalc_status
59 | @healthy_backends = @backends.select { |be| be.status == "HEALTHY" }.size
60 | @sick_backends = @backends.size - @healthy_backends
61 |
62 | @availability = (@healthy_backends.to_f / @backends.size)
63 |
64 | @status = "WARNING"
65 | @status = "OK" if @availability == 1
66 | @status = "CRITICAL" if @availability < CONFIG[:critical_threshold]
67 | end
68 | end
69 |
70 | def initialize
71 | @directors = {}
72 | end
73 |
74 | def to_json
75 | json_struct = {}
76 |
77 | @directors.each do |dname, dir|
78 | json_struct[dname] = dir.to_hash
79 | end
80 |
81 | JSON.dump(json_struct)
82 | end
83 |
84 | def self.create_from_varnishadm(proxy_target)
85 | varnish_ident = CONFIG[:varnishadm_opts]
86 | varnish_adm_cmd = CONFIG[:varnishadm]
87 |
88 | out=`#{varnish_adm_cmd} #{varnish_ident} backend.list`
89 | if out.empty?
90 | puts "no result from varnish (cmd: #{varnish_adm_cmd.inspect} #{varnish_ident})"
91 | end
92 |
93 | backend_status = VarnishBackendStatus.new
94 |
95 | out.split("\n").each do |line|
96 | m = line.match(/(\w+)\((([0-9]{1,3}\.){3}[0-9]{1,3})\,[:0-9]*\,(\d+)\) (\d+)\s*probe(.*)/)
97 | if m
98 | name = m[1]
99 | ip = m[2]
100 | port = m[4]
101 | refs = m[5]
102 | probe_status = m[6].strip.split(" ")
103 |
104 | status = probe_status[0]
105 | probes = probe_status[1..-1].join(" ")
106 |
107 | name_match = name.match(/(\w+)(_)(\w+)/)
108 | if !name_match
109 | host = name
110 | director = name
111 | else
112 | host = name_match[1]
113 | director = name_match[3]
114 | end
115 | backend_status.directors[director] ||= Director.new(director)
116 | backend_status.directors[director].add_backend(Backend.new({:name => name, :ip => ip, :port => port, :refs => refs, :status => status.upcase, :probes => probes, :host => host}))
117 | end
118 | end
119 |
120 | backend_status
121 | end
122 | end
123 |
124 | CONFIG = YAML.load_file(File.join(File.dirname(__FILE__), "config.yaml"))
125 |
126 | class VarnishStatus < Sinatra::Base
127 | set :root, File.dirname(__FILE__)
128 |
129 | get "/" do
130 | @vbs = VarnishBackendStatus.create_from_varnishadm(CONFIG[:proxy_mnemonic])
131 |
132 | erb :index
133 | end
134 |
135 | get "/internal/details" do
136 | content_type "application/json"
137 |
138 | vbs = VarnishBackendStatus.create_from_varnishadm(CONFIG[:proxy_mnemonic])
139 | vbs.to_json
140 | end
141 |
142 | get "/internal/status" do
143 | content_type "application/json"
144 |
145 | vbs = VarnishBackendStatus.create_from_varnishadm(CONFIG[:proxy_mnemonic])
146 | page = Sano::Page.new
147 | page.application.name = CONFIG[:proxy_name]
148 |
149 | vbs.directors.each do |dname, dir|
150 | director_detail = Sano::Detail.create do |d|
151 | d.name = dname
152 | d.status = dir.status
153 | d.message = "#{dir.healthy_backends} / #{dir.backends.size} in healthy state"
154 | end
155 |
156 | page.add_detail(director_detail)
157 | end
158 |
159 | page.to_json
160 | end
161 | end
162 |
--------------------------------------------------------------------------------
/spec/varnish_status_spec.rb:
--------------------------------------------------------------------------------
1 | require File.expand_path(File.dirname(__FILE__) + '/spec_helper')
2 |
3 | CONFIG = YAML.load_file(File.join(File.dirname(__FILE__), "../config.yaml"))
4 |
5 | describe 'no directors in server names all healthy' do
6 | before (:each) do
7 | VarnishBackendStatus.should_receive(:'`').with("#{CONFIG[:varnishadm]} #{CONFIG[:varnishadm_opts]} backend.list").and_return ("Backend name Refs Admin Probe\nserver1(1.1.1.1,,80) 1 probe Healthy 10/10\nserver2(2.2.2.2,,80) 1 probe Healthy 10/10\nserver3(3.3.3.3,,80) 1 probe Healthy 10/10\nserver4(4.4.4.4,,80) 1 probe Healthy 10/10\nserver5(5.5.5.5,,80) 1 probe Healthy 10/10")
8 | end
9 |
10 | it "shows the start page" do
11 | get '/'
12 |
13 | last_response.should be_ok
14 | last_response.body.should include "status-OK"
15 | last_response.body.should_not include "status-WARNING"
16 | last_response.body.should_not include "status-CRITICAL"
17 | end
18 |
19 | it "returns the json status" do
20 | get '/internal/status'
21 |
22 | parsed_body = JSON.parse(last_response.body)
23 |
24 | last_response.should be_ok
25 | parsed_body["application"]["status"].should include "OK"
26 | parsed_body["application"]["statusDetails"]["server1"]["status"].should include "OK"
27 | parsed_body["application"]["statusDetails"]["server2"]["status"].should include "OK"
28 | parsed_body["application"]["statusDetails"]["server3"]["status"].should include "OK"
29 | parsed_body["application"]["statusDetails"]["server4"]["status"].should include "OK"
30 | parsed_body["application"]["statusDetails"]["server5"]["status"].should include "OK"
31 | end
32 | end
33 |
34 | describe 'no directors in server names one unhealthy' do
35 | before (:each) do
36 | VarnishBackendStatus.should_receive(:'`').with("#{CONFIG[:varnishadm]} #{CONFIG[:varnishadm_opts]} backend.list").and_return ("Backend name Refs Admin Probe\nserver1(1.1.1.1,,80) 1 probe Healthy 10/10\nserver2(2.2.2.2,,80) 1 probe Healthy 10/10\nserver3(3.3.3.3,,80) 1 probe Healthy 10/10\nserver4(4.4.4.4,,80) 1 probe Healthy 10/10\nserver5(5.5.5.5,,80) 1 probe Sick 2/10")
37 | end
38 |
39 | it "shows the start page" do
40 | get '/'
41 |
42 | last_response.should be_ok
43 | last_response.body.should_not include "status-WARNING"
44 | last_response.body.should include "status-CRITICAL"
45 | last_response.body.should include "server5 (5.5.5.5) / SICK"
46 | end
47 |
48 | it "returns the json status" do
49 | get '/internal/status'
50 |
51 | parsed_body = JSON.parse(last_response.body)
52 |
53 | last_response.should be_ok
54 | parsed_body["application"]["status"].should include "CRITICAL"
55 | parsed_body["application"]["statusDetails"]["server1"]["status"].should include "OK"
56 | parsed_body["application"]["statusDetails"]["server2"]["status"].should include "OK"
57 | parsed_body["application"]["statusDetails"]["server3"]["status"].should include "OK"
58 | parsed_body["application"]["statusDetails"]["server4"]["status"].should include "OK"
59 | parsed_body["application"]["statusDetails"]["server5"]["status"].should include "CRITICAL"
60 | end
61 | end
62 |
63 | describe 'healthy cluster' do
64 |
65 | before (:each) do
66 | VarnishBackendStatus.should_receive(:'`').with("#{CONFIG[:varnishadm]} #{CONFIG[:varnishadm_opts]} backend.list").and_return ("Backend name Refs Admin Probe\nserver1_pool1(1.1.1.1,,80) 1 probe Healthy 10/10\nserver2_pool1(2.2.2.2,,80) 1 probe Healthy 10/10\nserver3_pool2(3.3.3.3,,80) 1 probe Healthy 10/10\nserver4_pool2(4.4.4.4,,80) 1 probe Healthy 10/10\nserver5_pool2(5.5.5.5,,80) 1 probe Healthy 10/10")
67 | end
68 |
69 | it "shows the start page" do
70 | get '/'
71 |
72 | last_response.should be_ok
73 | last_response.body.should include "status-OK"
74 | last_response.body.should_not include "status-WARNING"
75 | last_response.body.should_not include "status-CRITICAL"
76 | end
77 |
78 | it "returns the json status" do
79 | get '/internal/status'
80 |
81 | parsed_body = JSON.parse(last_response.body)
82 |
83 | last_response.should be_ok
84 | parsed_body["application"]["status"].should include "OK"
85 | parsed_body["application"]["statusDetails"]["pool1"]["status"].should include "OK"
86 | parsed_body["application"]["statusDetails"]["pool2"]["status"].should include "OK"
87 | end
88 |
89 | it "returns the details for the cluster" do
90 | get '/internal/details'
91 |
92 | parsed_body = JSON.parse(last_response.body)
93 | last_response.should be_ok
94 | parsed_body["pool1"]["backends"].each do |backend|
95 | backend["status"].should include "HEALTHY"
96 | backend["status"].should_not include "SICK"
97 | end
98 |
99 | parsed_body["pool2"]["backends"].each do |backend|
100 | backend["status"].should include "HEALTHY"
101 | backend["status"].should_not include "SICK"
102 | end
103 | end
104 | end
105 |
106 | describe 'unhealthy cluster below threshold' do
107 | before (:each) do
108 | VarnishBackendStatus.should_receive(:'`').with("#{CONFIG[:varnishadm]} #{CONFIG[:varnishadm_opts]} backend.list").and_return ("Backend name Refs Admin Probe\nserver1_pool1(1.1.1.1,,80) 1 probe Healthy 10/10\nserver2_pool1(2.2.2.2,,80) 1 probe Healthy 10/10\nserver3_pool2(3.3.3.3,,80) 1 probe Sick 2/10\nserver4_pool2(4.4.4.4,,80) 1 probe Healthy 10/10\nserver5_pool2(5.5.5.5,,80) 1 probe Sick 0/10")
109 | end
110 |
111 | it "shows the start page" do
112 | get '/'
113 |
114 | last_response.should be_ok
115 | last_response.body.should include "status-OK"
116 | last_response.body.should include "status-CRITICAL"
117 | last_response.body.should_not include "status-WARNING"
118 |
119 | end
120 |
121 | it "returns the json status" do
122 | get '/internal/status'
123 |
124 | parsed_body = JSON.parse(last_response.body)
125 |
126 | last_response.should be_ok
127 | parsed_body["application"]["status"].should include "CRITICAL"
128 | parsed_body["application"]["statusDetails"]["pool1"]["status"].should include "OK"
129 | parsed_body["application"]["statusDetails"]["pool2"]["status"].should include "CRITICAL"
130 | end
131 |
132 | it "returns the details for the cluster" do
133 | get '/internal/details'
134 |
135 | parsed_body = JSON.parse(last_response.body)
136 | last_response.should be_ok
137 | parsed_body["pool1"]["backends"].each do |backend|
138 | backend["status"].should include "HEALTHY"
139 | backend["status"].should_not include "SICK"
140 | end
141 |
142 | parsed_body["pool2"]["backends"][0]["status"].should_not include "HEALTHY"
143 | parsed_body["pool2"]["backends"][0]["status"].should include "SICK"
144 |
145 | parsed_body["pool2"]["backends"][1]["status"].should include "HEALTHY"
146 | parsed_body["pool2"]["backends"][1]["status"].should_not include "SICK"
147 |
148 | parsed_body["pool2"]["backends"][2]["status"].should_not include "HEALTHY"
149 | parsed_body["pool2"]["backends"][2]["status"].should include "SICK"
150 | end
151 | end
152 |
153 | describe 'unhealthy cluster' do
154 | before (:each) do
155 | VarnishBackendStatus.should_receive(:'`').with("#{CONFIG[:varnishadm]} #{CONFIG[:varnishadm_opts]} backend.list").and_return ("Backend name Refs Admin Probe\nserver1_pool1(1.1.1.1,,80) 1 probe Sick 0/10\nserver2_pool1(2.2.2.2,,80) 1 probe Sick 0/10\nserver3_pool2(3.3.3.3,,80) 1 probe Sick 2/10\nserver4_pool2(4.4.4.4,,80) 1 probe Sick 0/10\nserver5_pool2(5.5.5.5,,80) 1 probe Sick 0/10")
156 | end
157 |
158 | it "shows the start page" do
159 | get '/'
160 |
161 | last_response.should be_ok
162 | last_response.body.should_not include "status-OK"
163 | last_response.body.should include "status-CRITICAL"
164 | last_response.body.should_not include "status-WARNING"
165 |
166 | end
167 |
168 | it "returns the json status" do
169 | get '/internal/status'
170 |
171 | parsed_body = JSON.parse(last_response.body)
172 |
173 | last_response.should be_ok
174 | parsed_body["application"]["status"].should include "CRITICAL"
175 | parsed_body["application"]["statusDetails"]["pool1"]["status"].should include "CRITICAL"
176 | parsed_body["application"]["statusDetails"]["pool2"]["status"].should include "CRITICAL"
177 | end
178 |
179 | it "returns the details for the cluster" do
180 | get '/internal/details'
181 |
182 | parsed_body = JSON.parse(last_response.body)
183 |
184 | last_response.should be_ok
185 | parsed_body["pool1"]["backends"].each do |backend|
186 | backend["status"].should_not include "HEALTHY"
187 | backend["status"].should include "SICK"
188 | end
189 |
190 | parsed_body["pool2"]["backends"].each do |backend|
191 | backend["status"].should_not include "HEALTHY"
192 | backend["status"].should include "SICK"
193 | end
194 | end
195 | end
196 |
197 | describe 'cluster in warning' do
198 | before (:each) do
199 | VarnishBackendStatus.should_receive(:'`').with("#{CONFIG[:varnishadm]} #{CONFIG[:varnishadm_opts]} backend.list").and_return ("Backend name Refs Admin Probe\nserver1_pool1(1.1.1.1,,80) 1 probe Sick 0/10\nserver2_pool1(2.2.2.2,,80) 1 probe Healthy 10/10\nserver3_pool2(3.3.3.3,,80) 1 probe Healthy 10/10\nserver4_pool2(4.4.4.4,,80) 1 probe Healthy 10/10\nserver5_pool2(5.5.5.5,,80) 1 probe Sick 0/10")
200 | end
201 |
202 | it "shows the start page" do
203 | get '/'
204 |
205 | last_response.should be_ok
206 | last_response.body.should_not include "status-OK"
207 | last_response.body.should_not include "status-CRITICAL"
208 | last_response.body.should include "status-WARNING"
209 | end
210 |
211 | it "returns the json status" do
212 | get '/internal/status'
213 |
214 | parsed_body = JSON.parse(last_response.body)
215 |
216 | last_response.should be_ok
217 | parsed_body["application"]["status"].should include "WARNING"
218 | parsed_body["application"]["statusDetails"]["pool1"]["status"].should include "WARNING"
219 | parsed_body["application"]["statusDetails"]["pool2"]["status"].should include "WARNING"
220 | end
221 |
222 | it "returns the details for the cluster" do
223 | get '/internal/details'
224 |
225 | parsed_body = JSON.parse(last_response.body)
226 |
227 | last_response.should be_ok
228 |
229 | parsed_body["pool1"]["backends"][0]["status"].should_not include "HEALTHY"
230 | parsed_body["pool1"]["backends"][0]["status"].should include "SICK"
231 |
232 | parsed_body["pool1"]["backends"][1]["status"].should include "HEALTHY"
233 | parsed_body["pool1"]["backends"][1]["status"].should_not include "SICK"
234 |
235 | parsed_body["pool2"]["backends"][0]["status"].should include "HEALTHY"
236 | parsed_body["pool2"]["backends"][0]["status"].should_not include "SICK"
237 |
238 | parsed_body["pool2"]["backends"][1]["status"].should include "HEALTHY"
239 | parsed_body["pool2"]["backends"][1]["status"].should_not include "SICK"
240 |
241 | parsed_body["pool2"]["backends"][2]["status"].should_not include "HEALTHY"
242 | parsed_body["pool2"]["backends"][2]["status"].should include "SICK"
243 |
244 | end
245 | end
246 |
--------------------------------------------------------------------------------
/license.txt:
--------------------------------------------------------------------------------
1 | Apache License
2 | Version 2.0, January 2004
3 | http://www.apache.org/licenses/
4 |
5 | TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
6 |
7 | 1. Definitions.
8 |
9 | "License" shall mean the terms and conditions for use, reproduction,
10 | and distribution as defined by Sections 1 through 9 of this document.
11 |
12 | "Licensor" shall mean the copyright owner or entity authorized by
13 | the copyright owner that is granting the License.
14 |
15 | "Legal Entity" shall mean the union of the acting entity and all
16 | other entities that control, are controlled by, or are under common
17 | control with that entity. For the purposes of this definition,
18 | "control" means (i) the power, direct or indirect, to cause the
19 | direction or management of such entity, whether by contract or
20 | otherwise, or (ii) ownership of fifty percent (50%) or more of the
21 | outstanding shares, or (iii) beneficial ownership of such entity.
22 |
23 | "You" (or "Your") shall mean an individual or Legal Entity
24 | exercising permissions granted by this License.
25 |
26 | "Source" form shall mean the preferred form for making modifications,
27 | including but not limited to software source code, documentation
28 | source, and configuration files.
29 |
30 | "Object" form shall mean any form resulting from mechanical
31 | transformation or translation of a Source form, including but
32 | not limited to compiled object code, generated documentation,
33 | and conversions to other media types.
34 |
35 | "Work" shall mean the work of authorship, whether in Source or
36 | Object form, made available under the License, as indicated by a
37 | copyright notice that is included in or attached to the work
38 | (an example is provided in the Appendix below).
39 |
40 | "Derivative Works" shall mean any work, whether in Source or Object
41 | form, that is based on (or derived from) the Work and for which the
42 | editorial revisions, annotations, elaborations, or other modifications
43 | represent, as a whole, an original work of authorship. For the purposes
44 | of this License, Derivative Works shall not include works that remain
45 | separable from, or merely link (or bind by name) to the interfaces of,
46 | the Work and Derivative Works thereof.
47 |
48 | "Contribution" shall mean any work of authorship, including
49 | the original version of the Work and any modifications or additions
50 | to that Work or Derivative Works thereof, that is intentionally
51 | submitted to Licensor for inclusion in the Work by the copyright owner
52 | or by an individual or Legal Entity authorized to submit on behalf of
53 | the copyright owner. For the purposes of this definition, "submitted"
54 | means any form of electronic, verbal, or written communication sent
55 | to the Licensor or its representatives, including but not limited to
56 | communication on electronic mailing lists, source code control systems,
57 | and issue tracking systems that are managed by, or on behalf of, the
58 | Licensor for the purpose of discussing and improving the Work, but
59 | excluding communication that is conspicuously marked or otherwise
60 | designated in writing by the copyright owner as "Not a Contribution."
61 |
62 | "Contributor" shall mean Licensor and any individual or Legal Entity
63 | on behalf of whom a Contribution has been received by Licensor and
64 | subsequently incorporated within the Work.
65 |
66 | 2. Grant of Copyright License. Subject to the terms and conditions of
67 | this License, each Contributor hereby grants to You a perpetual,
68 | worldwide, non-exclusive, no-charge, royalty-free, irrevocable
69 | copyright license to reproduce, prepare Derivative Works of,
70 | publicly display, publicly perform, sublicense, and distribute the
71 | Work and such Derivative Works in Source or Object form.
72 |
73 | 3. Grant of Patent License. Subject to the terms and conditions of
74 | this License, each Contributor hereby grants to You a perpetual,
75 | worldwide, non-exclusive, no-charge, royalty-free, irrevocable
76 | (except as stated in this section) patent license to make, have made,
77 | use, offer to sell, sell, import, and otherwise transfer the Work,
78 | where such license applies only to those patent claims licensable
79 | by such Contributor that are necessarily infringed by their
80 | Contribution(s) alone or by combination of their Contribution(s)
81 | with the Work to which such Contribution(s) was submitted. If You
82 | institute patent litigation against any entity (including a
83 | cross-claim or counterclaim in a lawsuit) alleging that the Work
84 | or a Contribution incorporated within the Work constitutes direct
85 | or contributory patent infringement, then any patent licenses
86 | granted to You under this License for that Work shall terminate
87 | as of the date such litigation is filed.
88 |
89 | 4. Redistribution. You may reproduce and distribute copies of the
90 | Work or Derivative Works thereof in any medium, with or without
91 | modifications, and in Source or Object form, provided that You
92 | meet the following conditions:
93 |
94 | (a) You must give any other recipients of the Work or
95 | Derivative Works a copy of this License; and
96 |
97 | (b) You must cause any modified files to carry prominent notices
98 | stating that You changed the files; and
99 |
100 | (c) You must retain, in the Source form of any Derivative Works
101 | that You distribute, all copyright, patent, trademark, and
102 | attribution notices from the Source form of the Work,
103 | excluding those notices that do not pertain to any part of
104 | the Derivative Works; and
105 |
106 | (d) If the Work includes a "NOTICE" text file as part of its
107 | distribution, then any Derivative Works that You distribute must
108 | include a readable copy of the attribution notices contained
109 | within such NOTICE file, excluding those notices that do not
110 | pertain to any part of the Derivative Works, in at least one
111 | of the following places: within a NOTICE text file distributed
112 | as part of the Derivative Works; within the Source form or
113 | documentation, if provided along with the Derivative Works; or,
114 | within a display generated by the Derivative Works, if and
115 | wherever such third-party notices normally appear. The contents
116 | of the NOTICE file are for informational purposes only and
117 | do not modify the License. You may add Your own attribution
118 | notices within Derivative Works that You distribute, alongside
119 | or as an addendum to the NOTICE text from the Work, provided
120 | that such additional attribution notices cannot be construed
121 | as modifying the License.
122 |
123 | You may add Your own copyright statement to Your modifications and
124 | may provide additional or different license terms and conditions
125 | for use, reproduction, or distribution of Your modifications, or
126 | for any such Derivative Works as a whole, provided Your use,
127 | reproduction, and distribution of the Work otherwise complies with
128 | the conditions stated in this License.
129 |
130 | 5. Submission of Contributions. Unless You explicitly state otherwise,
131 | any Contribution intentionally submitted for inclusion in the Work
132 | by You to the Licensor shall be under the terms and conditions of
133 | this License, without any additional terms or conditions.
134 | Notwithstanding the above, nothing herein shall supersede or modify
135 | the terms of any separate license agreement you may have executed
136 | with Licensor regarding such Contributions.
137 |
138 | 6. Trademarks. This License does not grant permission to use the trade
139 | names, trademarks, service marks, or product names of the Licensor,
140 | except as required for reasonable and customary use in describing the
141 | origin of the Work and reproducing the content of the NOTICE file.
142 |
143 | 7. Disclaimer of Warranty. Unless required by applicable law or
144 | agreed to in writing, Licensor provides the Work (and each
145 | Contributor provides its Contributions) on an "AS IS" BASIS,
146 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
147 | implied, including, without limitation, any warranties or conditions
148 | of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
149 | PARTICULAR PURPOSE. You are solely responsible for determining the
150 | appropriateness of using or redistributing the Work and assume any
151 | risks associated with Your exercise of permissions under this License.
152 |
153 | 8. Limitation of Liability. In no event and under no legal theory,
154 | whether in tort (including negligence), contract, or otherwise,
155 | unless required by applicable law (such as deliberate and grossly
156 | negligent acts) or agreed to in writing, shall any Contributor be
157 | liable to You for damages, including any direct, indirect, special,
158 | incidental, or consequential damages of any character arising as a
159 | result of this License or out of the use or inability to use the
160 | Work (including but not limited to damages for loss of goodwill,
161 | work stoppage, computer failure or malfunction, or any and all
162 | other commercial damages or losses), even if such Contributor
163 | has been advised of the possibility of such damages.
164 |
165 | 9. Accepting Warranty or Additional Liability. While redistributing
166 | the Work or Derivative Works thereof, You may choose to offer,
167 | and charge a fee for, acceptance of support, warranty, indemnity,
168 | or other liability obligations and/or rights consistent with this
169 | License. However, in accepting such obligations, You may act only
170 | on Your own behalf and on Your sole responsibility, not on behalf
171 | of any other Contributor, and only if You agree to indemnify,
172 | defend, and hold each Contributor harmless for any liability
173 | incurred by, or claims asserted against, such Contributor by reason
174 | of your accepting any such warranty or additional liability.
175 |
176 | END OF TERMS AND CONDITIONS
177 |
178 | APPENDIX: How to apply the Apache License to your work.
179 |
180 | To apply the Apache License to your work, attach the following
181 | boilerplate notice, with the fields enclosed by brackets "[]"
182 | replaced with your own identifying information. (Don't include
183 | the brackets!) The text should be enclosed in the appropriate
184 | comment syntax for the file format. We also recommend that a
185 | file or class name and description of purpose be included on the
186 | same "printed page" as the copyright notice for easier
187 | identification within third-party archives.
188 |
189 | Copyright [yyyy] [name of copyright owner]
190 |
191 | Licensed under the Apache License, Version 2.0 (the "License");
192 | you may not use this file except in compliance with the License.
193 | You may obtain a copy of the License at
194 |
195 | http://www.apache.org/licenses/LICENSE-2.0
196 |
197 | Unless required by applicable law or agreed to in writing, software
198 | distributed under the License is distributed on an "AS IS" BASIS,
199 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
200 | See the License for the specific language governing permissions and
201 | limitations under the License.
--------------------------------------------------------------------------------