notify-graphite 0.0.1 → 0.0.2

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.
data/bin/notify_graphite CHANGED
@@ -16,7 +16,7 @@ OptionParser.new do |opts|
16
16
  end
17
17
 
18
18
  opts.on("-b", "--basename Basename for events", :OPTIONAL, "Basename for events Default: com.mycompany") do |p|
19
- options[:port] = p.to_i || 2003
19
+ options[:basename] = p.to_s || "com.mycompany"
20
20
  end
21
21
 
22
22
  opts.on("-h", "--help", "Show this help information") do
@@ -30,7 +30,7 @@ unless options[:hostname]
30
30
  abort
31
31
  end
32
32
 
33
- notify = Notify::Graphite.new(options[:hostname], options[:port], 'com.mycompany')
33
+ notify = Notify::Graphite.new(options[:hostname], options[:port], options[:basename])
34
34
 
35
35
  if ARGV.length > 0
36
36
  notify.send_event(ARGV.join('.'))
@@ -1,18 +1,47 @@
1
- require 'bundler/setup'
2
- require 'graphite_client'
1
+ require 'socket'
2
+
3
+ class CarbonClient
4
+ def initialize(hstr)
5
+ @host, @port = hstr.split(":")
6
+ @port = 2003 unless @port
7
+ @port = @port.to_i
8
+ end
9
+
10
+ def getSocket
11
+ STDOUT.puts @host
12
+ @socket = TCPSocket.new(@host.to_s, @port) unless @socket && !@socket.closed?
13
+ return @socket
14
+ end
15
+
16
+ def closeSocket
17
+ @socket.close if @socket
18
+ @socket = nil
19
+ end
20
+
21
+ def sendMetric(key, value, time = Time.now)
22
+ begin
23
+ getSocket.puts("#{key} #{value.to_f} #{time.to_i}")
24
+ rescue Errno::EPIPE, Errno::EHOSTUNREACH, Errno::EHOSTDOWN
25
+ @socket = nil
26
+ return nil
27
+ end
28
+ closeSocket if @socket
29
+ end
30
+
31
+ end
3
32
 
4
33
  module Notify; end
5
34
 
6
35
  class Notify::Graphite < BasicObject
7
- VERSION = "0.0.1"
36
+ VERSION = "0.0.2"
8
37
 
9
38
  def initialize(host, port=2003, basename=nil)
10
39
  @basename = ["events", basename].compact.join('.')
11
- @client = ::GraphiteClient.new(host+":"+port.to_s)
40
+ @client = ::CarbonClient.new(host+":"+port.to_s)
12
41
  end
13
42
 
14
43
  def send_event(event_name)
15
- @client.report(@basename+"."+event_name, 1)
44
+ @client.sendMetric(@basename+"."+event_name, 1)
16
45
  #TODO: we should also send a "normal" graphite event to the json api.
17
46
  end
18
47
 
metadata CHANGED
@@ -1,29 +1,16 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: notify-graphite
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.1
4
+ version: 0.0.2
5
+ prerelease:
5
6
  platform: ruby
6
7
  authors:
7
8
  - Jan Ulferts
8
9
  autorequire:
9
10
  bindir: bin
10
11
  cert_chain: []
11
- date: 2013-04-05 00:00:00.000000000 Z
12
- dependencies:
13
- - !ruby/object:Gem::Dependency
14
- name: graphite_client
15
- requirement: !ruby/object:Gem::Requirement
16
- requirements:
17
- - - ~>
18
- - !ruby/object:Gem::Version
19
- version: '0.4'
20
- type: :runtime
21
- prerelease: false
22
- version_requirements: !ruby/object:Gem::Requirement
23
- requirements:
24
- - - ~>
25
- - !ruby/object:Gem::Version
26
- version: '0.4'
12
+ date: 2013-04-07 00:00:00.000000000Z
13
+ dependencies: []
27
14
  description: Push event notifications to Graphite
28
15
  email:
29
16
  - janu@cpan.org
@@ -38,26 +25,26 @@ files:
38
25
  homepage: https://github.com/fatz/notify-graphite
39
26
  licenses:
40
27
  - MIT
41
- metadata: {}
42
28
  post_install_message:
43
29
  rdoc_options: []
44
30
  require_paths:
45
31
  - lib
46
32
  required_ruby_version: !ruby/object:Gem::Requirement
33
+ none: false
47
34
  requirements:
48
35
  - - ! '>'
49
36
  - !ruby/object:Gem::Version
50
37
  version: '1.9'
51
38
  required_rubygems_version: !ruby/object:Gem::Requirement
39
+ none: false
52
40
  requirements:
53
41
  - - ! '>='
54
42
  - !ruby/object:Gem::Version
55
43
  version: '0'
56
44
  requirements: []
57
45
  rubyforge_project:
58
- rubygems_version: 2.0.3
46
+ rubygems_version: 1.8.10
59
47
  signing_key:
60
- specification_version: 4
48
+ specification_version: 3
61
49
  summary: Push event notifications to Graphite
62
50
  test_files: []
63
- has_rdoc:
checksums.yaml DELETED
@@ -1,15 +0,0 @@
1
- ---
2
- !binary "U0hBMQ==":
3
- metadata.gz: !binary |-
4
- NDQ2MzNhZGY4N2E4MDQ4YWUwMGViYTQ1Y2M2ZmVlNzdjMzBkYWVlMw==
5
- data.tar.gz: !binary |-
6
- ZTYyNjYxZDIwODdhY2U0NzQzZTJiNjFlMTNmMjU0MmUyOTczZjI1Ng==
7
- !binary "U0hBNTEy":
8
- metadata.gz: !binary |-
9
- ZDAyNTA3NTgwZTc2ODExMzllNDc0MjlhMDNhNzVmYWU1NGI5YmUyMjRkZThl
10
- M2NmY2JlNGJjZjIyNzk4YmMxODI3NWE3MTJhYzM5M2IzMzAxYjk0YzljZDJh
11
- NGZiMGYzMjVhMmUzOGQ5ZDVjYjA3MTQ2MTY1Y2QwZWZiZjJkZDE=
12
- data.tar.gz: !binary |-
13
- YmM2YzY0MzBjZjZmOGM3MjI5YzIwZTIzNmYwMDU2YmZmMDZiZGE5YTM3NDk2
14
- NTNhZDkyMmMxZWRkZmVlMmE5YjUxYTEwMGVkMmM2YjYyZWFiM2JkZGQ2Nzkz
15
- YjFmMzc2NWE1ZThmYjRiMzFkNmViZWRlYWMyM2ZjNmNjZjA2MDA=