yam2g 0.0.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (5) hide show
  1. data/LICENSE +17 -0
  2. data/README.md +7 -0
  3. data/Rakefile +8 -0
  4. data/bin/yam2g +55 -0
  5. metadata +115 -0
data/LICENSE ADDED
@@ -0,0 +1,17 @@
1
+ yam2g - Yet Another Munin to Graphite tool
2
+
3
+ Copyright (C) 2005-2012 Puppet Labs Inc
4
+
5
+ Puppet Labs can be contacted at: info@puppetlabs.com
6
+
7
+ Licensed under the Apache License, Version 2.0 (the "License");
8
+ you may not use this file except in compliance with the License.
9
+ You may obtain a copy of the License at
10
+
11
+ http://www.apache.org/licenses/LICENSE-2.0
12
+
13
+ Unless required by applicable law or agreed to in writing, software
14
+ distributed under the License is distributed on an "AS IS" BASIS,
15
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16
+ See the License for the specific language governing permissions and
17
+ limitations under the License.
@@ -0,0 +1,7 @@
1
+ # yam2g
2
+
3
+ Yet Another Munin to Graphite. Provide the excutable with a destination and it will connect to a munin-node process on localhost and zoom your stats off to Graphite.
4
+
5
+ # Example
6
+
7
+ `yam2g -g graphite.example.com`
@@ -0,0 +1,8 @@
1
+ require 'rake'
2
+
3
+ task :default => 'gembuild'
4
+
5
+ desc "build the gem"
6
+ task :gembuild do
7
+ %x(gem build ./yam2g.gemspec)
8
+ end
@@ -0,0 +1,55 @@
1
+ #!/usr/bin/env ruby
2
+ require 'rubygems'
3
+ require 'munin-ruby'
4
+ require 'socket'
5
+ require 'json'
6
+ require 'facter'
7
+ require 'json2graphite'
8
+ require 'optparse'
9
+
10
+ options = { :port => 2003, :munin_node => 'localhost', :export_prefix => 'munin' }
11
+ OptionParser.new do |opts|
12
+ opts.banner = 'Usage: yam2g [options]'
13
+
14
+ opts.on('-g', '--graphite-server SERVER', 'The graphite server you plan to send munin data to') do |v|
15
+ options[:graphite_server] = v
16
+ end
17
+
18
+ opts.on('-p', '--port [PORT]', 'The port of your graphite server') do |v|
19
+ options[:port] = v || 2003
20
+ end
21
+
22
+ opts.on('-m', '--munin-node [NODE]', 'The address to the munin node you want data from') do |v|
23
+ options[:munin_node] = v || 'localhost'
24
+ end
25
+
26
+ opts.on('-e', '--export-prefix [PREFIX]', 'A prefix given to your exported data for Graphite organizational purposes') do |v|
27
+ options[:export_prefix] = v || 'munin'
28
+ end
29
+ end.parse!
30
+
31
+ def send_metric(payload, server, port)
32
+ socket = TCPSocket.new(server, port)
33
+ socket.puts payload
34
+ socket.close
35
+ end
36
+
37
+ node = Munin::Node.new(options[:munin_node])
38
+
39
+ node.connect
40
+
41
+ rfqdn = Facter.value(:fqdn).split('.').reverse.join('.')
42
+
43
+ prefix = "#{options[:export_prefix]}.#{rfqdn}"
44
+
45
+ root = { prefix => { } }
46
+
47
+ node.list.each do |m|
48
+ root[prefix].merge!(node.fetch(m))
49
+ end
50
+
51
+ graphite = root.to_graphite
52
+
53
+ graphite.each do |g|
54
+ send_metric(g, options[:graphite_server], options[:port])
55
+ end
metadata ADDED
@@ -0,0 +1,115 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: yam2g
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.1
5
+ prerelease:
6
+ platform: ruby
7
+ authors:
8
+ - Cody Herriges
9
+ autorequire:
10
+ bindir: bin
11
+ cert_chain: []
12
+ date: 2012-12-12 00:00:00.000000000 Z
13
+ dependencies:
14
+ - !ruby/object:Gem::Dependency
15
+ name: json
16
+ requirement: !ruby/object:Gem::Requirement
17
+ none: false
18
+ requirements:
19
+ - - ! '>='
20
+ - !ruby/object:Gem::Version
21
+ version: '0'
22
+ type: :runtime
23
+ prerelease: false
24
+ version_requirements: !ruby/object:Gem::Requirement
25
+ none: false
26
+ requirements:
27
+ - - ! '>='
28
+ - !ruby/object:Gem::Version
29
+ version: '0'
30
+ - !ruby/object:Gem::Dependency
31
+ name: munin-ruby
32
+ requirement: !ruby/object:Gem::Requirement
33
+ none: false
34
+ requirements:
35
+ - - ! '>='
36
+ - !ruby/object:Gem::Version
37
+ version: '0'
38
+ type: :runtime
39
+ prerelease: false
40
+ version_requirements: !ruby/object:Gem::Requirement
41
+ none: false
42
+ requirements:
43
+ - - ! '>='
44
+ - !ruby/object:Gem::Version
45
+ version: '0'
46
+ - !ruby/object:Gem::Dependency
47
+ name: facter
48
+ requirement: !ruby/object:Gem::Requirement
49
+ none: false
50
+ requirements:
51
+ - - ! '>='
52
+ - !ruby/object:Gem::Version
53
+ version: '0'
54
+ type: :runtime
55
+ prerelease: false
56
+ version_requirements: !ruby/object:Gem::Requirement
57
+ none: false
58
+ requirements:
59
+ - - ! '>='
60
+ - !ruby/object:Gem::Version
61
+ version: '0'
62
+ - !ruby/object:Gem::Dependency
63
+ name: json2graphite
64
+ requirement: !ruby/object:Gem::Requirement
65
+ none: false
66
+ requirements:
67
+ - - ! '>='
68
+ - !ruby/object:Gem::Version
69
+ version: '0'
70
+ type: :runtime
71
+ prerelease: false
72
+ version_requirements: !ruby/object:Gem::Requirement
73
+ none: false
74
+ requirements:
75
+ - - ! '>='
76
+ - !ruby/object:Gem::Version
77
+ version: '0'
78
+ description: Leverages the json2graphite gem to connect to a munin-node process and
79
+ convert all available data to a format that is Graphite friendly. After data has
80
+ been converted it is sent off to the Graphite server of your choice.
81
+ email: cody@puppetlabs.com
82
+ executables:
83
+ - yam2g
84
+ extensions: []
85
+ extra_rdoc_files: []
86
+ files:
87
+ - Rakefile
88
+ - bin/yam2g
89
+ - README.md
90
+ - LICENSE
91
+ homepage: https://github.com/puppetlabs-operations/yam2g
92
+ licenses: []
93
+ post_install_message:
94
+ rdoc_options: []
95
+ require_paths:
96
+ - lib
97
+ required_ruby_version: !ruby/object:Gem::Requirement
98
+ none: false
99
+ requirements:
100
+ - - ! '>='
101
+ - !ruby/object:Gem::Version
102
+ version: '0'
103
+ required_rubygems_version: !ruby/object:Gem::Requirement
104
+ none: false
105
+ requirements:
106
+ - - ! '>='
107
+ - !ruby/object:Gem::Version
108
+ version: '0'
109
+ requirements: []
110
+ rubyforge_project:
111
+ rubygems_version: 1.8.23
112
+ signing_key:
113
+ specification_version: 3
114
+ summary: Converts and sends munin data to Graphite
115
+ test_files: []