sensu-checks-varnish 0.1.8

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: a32cf71c19fd29c50bfe5c5958394a6aa26dd053
4
+ data.tar.gz: d05b6310ff01964493175edf2cd29e72904d82a8
5
+ SHA512:
6
+ metadata.gz: 8fe847e40977fd488bc70b04b0c404267a3b757dd294e050c42aca0ad75769c2fe85a39334d1742a7f41df4c3028c179a0032d4c1eedeb124e68c0b13bdc90d1
7
+ data.tar.gz: c6a98fc345c207e4f73372e6b299a6c25fd787d57883dcf7daacfdefbcbdfa595319f2177668de7c3ef8cb364c233fb362f340309e146014198bdc26eb4b3879
data/LICENSE ADDED
@@ -0,0 +1,16 @@
1
+ A modified MIT License (MIT)
2
+
3
+ Copyright (c) 2016 Dirk Gustke
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
6
+
7
+ The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
8
+
9
+ Neither the Software, nor any derivative product, shall be used to operate weapons
10
+
11
+ Neither the Software, nor any derivative product, shall be used for any military use
12
+
13
+ Neither the Software, nor any derivative product, shall be used for any use by intelligence agencies
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
16
+
data/README.md ADDED
@@ -0,0 +1,71 @@
1
+ # sensu-checks-varnish
2
+
3
+ Sensu gem to get varnish metrics. Uses plain data out of varnish.
4
+ Supports sudo for better access rights management.
5
+ Supports more than one varnish instance per host by letting you define an append string (ie: "hostname.appendstring.varnish.MAIN.cache_hits 1").
6
+
7
+
8
+ ## DEPENDENCIES
9
+
10
+ none
11
+
12
+
13
+ ## INSTALLATION
14
+
15
+ This gem will give an actual installation explanation, as the default sensu plugins miss it and the sensu documentation lacks any detailed explanation.
16
+
17
+ If this gem is listed in rubygems.org, you can just go ahead and do
18
+ ~~sensu-install -p sensu-check-varnish~~
19
+
20
+
21
+ Updated:
22
+ As Sensu expects the naming to be "sensu-plugins-FOO", you need to do it another way:
23
+ ```
24
+ /opt/sensu/embedded/bin/gem install --no-ri --no-rdoc sensu-checks-varnish
25
+ ```
26
+
27
+ If this does not work for you, you can still install it; the hard way.
28
+ ```
29
+ git clone git@github.com:vmpublishing/sensu-checks-varnish [SOME_PATH]
30
+ cd [SOME_PATH]
31
+ /opt/sensu/embedded/bin/gem build *.gemspec
32
+ /opt/sensu/embedded/bin/gem install *.gem
33
+ ```
34
+
35
+ Alter `/opt/sensu/embedded/bin/gem` to the path to the gem-file sensu uses on your machine.
36
+
37
+
38
+ ## USAGE
39
+
40
+ ### metrics
41
+
42
+ #### Parameters
43
+
44
+ | name | parameter_name | default value | required | description |
45
+ |------|----------------|---------------|----------|-------------|
46
+ | sudo | -s, --sudo | false | no | boolean, turns sudo usage on. (ie: `sudo varnishstat -1`) |
47
+ | varnish_name | -n, --name | '' | no | custom varnish instance name. Varnish defaults to node name, so this is not required. |
48
+ | fields | -f, --fields | '' | no | a comma separated list of fields to get, instead of everything. ie: `varnishstat -1 -f field1 -f field2` |
49
+ | scheme | -C, --scheme | [hostname].varnish | no | Metric naming scheme, text to prepend to metric and scheme_append |
50
+ | scheme_append | -S, --scheme_append | nil | no | Set a string that will be placed right after the host identification and the script identification but before the measurements (ie. hostname.varnish.scheme_append.slow_requests) |
51
+
52
+ #### sample json config file for sockets
53
+ ```
54
+ {
55
+ "metrics": {
56
+ "metric_varnish": {
57
+ "type": "metric",
58
+ "command": "metric-varnish.rb -s",
59
+ "standalone": true,
60
+ "interval": 10,
61
+ "timeout": 120,
62
+ "ttl": 180
63
+ }
64
+ }
65
+ }
66
+ ```
67
+
68
+
69
+ ## CONTRIBUTING
70
+
71
+ Bug reports and pull requests are welcome on GitHub at https://github.com/vmpublishing/sensu-checks-varnish.
@@ -0,0 +1,70 @@
1
+ #!/usr/bin/env ruby
2
+
3
+
4
+ require 'sensu-plugin/metric/cli'
5
+ require 'socket'
6
+
7
+
8
+ class MetricVarnish < Sensu::Plugin::Metric::CLI::Graphite
9
+
10
+ option :sudo,
11
+ short: '-s',
12
+ long: '--sudo',
13
+ description: 'run varnishstat as sudo (and possibly avoid running sensu as root)',
14
+ boolean: true,
15
+ default: false
16
+
17
+ option :varnish_name,
18
+ short: '-n VARNISH_NAME',
19
+ long: '--name VARNISH_NAME',
20
+ description: 'The varnishd instance to get data from'
21
+
22
+ option :fields,
23
+ short: '-f fieldlist',
24
+ long: '--fields fieldlist',
25
+ description: 'The stats fields to get from varnish, comma sepparated. See varnishstat -f',
26
+ default: ''
27
+
28
+ option :scheme,
29
+ short: '-C SCHEME',
30
+ long: '--scheme SCHEME',
31
+ description: 'Metric naming scheme, text to prepend to metric and scheme_append',
32
+ default: "#{Socket.gethostname}"
33
+
34
+ option :scheme_append,
35
+ short: '-S APPEND_STRING',
36
+ long: '--scheme-append APPEND_STRING',
37
+ description: 'Set a string that will be placed right after the host identification and the script identification but before the measurements',
38
+ default: nil
39
+
40
+ def run
41
+
42
+ # init variable
43
+ command = ""
44
+
45
+ # enable sudo use if requested
46
+ command += "sudo " if config[:sudo]
47
+
48
+ # basic command
49
+ command += "varnishstat -1"
50
+
51
+ # added requested fields (or nothing)
52
+ command += config[:fields].split(',').map{|field| " -f #{field}"}.join(' ')
53
+
54
+ # fetch stats
55
+ stats_string = `#{command}`
56
+
57
+ # send them along
58
+ base_path = config[:scheme]
59
+ base_path += ".#{config[:scheme_append]}" if config[:scheme_append]
60
+ base_path += ".varnish"
61
+ stats_string.split("\n").each do |stat_line|
62
+ stats = stat_line.split(' ').compact
63
+ output "#{base_path}.#{stats[0].gsub(/[^a-zA-Z0-9_\.]/, '_')}", stats[1]
64
+ end
65
+
66
+ ok
67
+ end
68
+
69
+ end
70
+
@@ -0,0 +1,2 @@
1
+ require 'sensu-checks-varnish/version.rb'
2
+
@@ -0,0 +1,10 @@
1
+ module SensuChecksVarnish
2
+ module Version
3
+ MAJOR = 0
4
+ MINOR = 1
5
+ PATCH = 8
6
+
7
+ VER_STRING = [MAJOR, MINOR, PATCH].compact.join('.')
8
+ end
9
+ end
10
+
metadata ADDED
@@ -0,0 +1,93 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: sensu-checks-varnish
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.8
5
+ platform: ruby
6
+ authors:
7
+ - vmpublishing development
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2016-08-23 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: sensu-plugin
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - "~>"
18
+ - !ruby/object:Gem::Version
19
+ version: '1.2'
20
+ type: :runtime
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - "~>"
25
+ - !ruby/object:Gem::Version
26
+ version: '1.2'
27
+ - !ruby/object:Gem::Dependency
28
+ name: bundler
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - "~>"
32
+ - !ruby/object:Gem::Version
33
+ version: '1.11'
34
+ type: :development
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - "~>"
39
+ - !ruby/object:Gem::Version
40
+ version: '1.11'
41
+ - !ruby/object:Gem::Dependency
42
+ name: rake
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - "~>"
46
+ - !ruby/object:Gem::Version
47
+ version: '10.0'
48
+ type: :development
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - "~>"
53
+ - !ruby/object:Gem::Version
54
+ version: '10.0'
55
+ description: sensu gem to get varnish metrics. Uses plain data out of varnish. Supports
56
+ sudo. Supports more than one varnish instance per host.
57
+ email:
58
+ - dev@vmpublishing.com
59
+ executables:
60
+ - metric-varnish.rb
61
+ extensions: []
62
+ extra_rdoc_files: []
63
+ files:
64
+ - LICENSE
65
+ - README.md
66
+ - bin/metric-varnish.rb
67
+ - lib/sensu-checks-varnish.rb
68
+ - lib/sensu-checks-varnish/version.rb
69
+ homepage: https://github.com/vmpublishing/sensu-checks-varnish
70
+ licenses:
71
+ - Nonstandard
72
+ metadata: {}
73
+ post_install_message:
74
+ rdoc_options: []
75
+ require_paths:
76
+ - lib
77
+ required_ruby_version: !ruby/object:Gem::Requirement
78
+ requirements:
79
+ - - ">="
80
+ - !ruby/object:Gem::Version
81
+ version: '0'
82
+ required_rubygems_version: !ruby/object:Gem::Requirement
83
+ requirements:
84
+ - - ">="
85
+ - !ruby/object:Gem::Version
86
+ version: '0'
87
+ requirements: []
88
+ rubyforge_project:
89
+ rubygems_version: 2.5.1
90
+ signing_key:
91
+ specification_version: 4
92
+ summary: sensu gem to get varnish metrics.
93
+ test_files: []