impulse 0.0.3 → 0.0.4

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/README.rdoc CHANGED
@@ -1,6 +1,6 @@
1
1
  = impulse
2
2
 
3
- * http://github.com/lloydpick/impulse
3
+ * http://github.com/forward/impulse
4
4
 
5
5
  == DESCRIPTION:
6
6
 
@@ -82,17 +82,25 @@ Note that it will attempt to guess as much of the options as it can, as you can
82
82
 
83
83
  == PARAMS:
84
84
 
85
- Default parameters...
85
+ Default graph parameters for draw()...
86
86
 
87
- :filename => 'impuse.png',
87
+ :filename => 'impulse.png',
88
+ :rrd_path => '.',
89
+ :output_path => '.',
88
90
  :height => 200,
89
91
  :width => 600,
90
- :title => 'Impuse Graph',
92
+ :title => 'Impulse Graph',
91
93
  :vertical => '',
92
- :legend => ''
94
+ :legend => '',
95
+ :thickness => 1
93
96
 
94
97
  All can be configured on a per graph basis.
95
98
 
99
+ Default plot parameters for push()...
100
+
101
+ :rrd_path => '.',
102
+
103
+ All can be configured on a per RRD basis.
96
104
 
97
105
  == QUICK NOTE
98
106
 
data/impulse.gemspec CHANGED
@@ -18,4 +18,6 @@ Gem::Specification.new do |s|
18
18
  s.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
19
19
  s.executables = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) }
20
20
  s.require_paths = ["lib"]
21
+
22
+ s.add_development_dependency(%q<rake>)
21
23
  end
@@ -1,3 +1,3 @@
1
1
  module Impulse
2
- VERSION = "0.0.3"
2
+ VERSION = "0.0.4"
3
3
  end
data/lib/impulse.rb CHANGED
@@ -7,29 +7,34 @@ module Impulse
7
7
  end
8
8
 
9
9
  def push(name, datas, params = {})
10
- create_or_find_rrd(name, datas)
11
- push_to_rrd(name, datas)
10
+ params = {
11
+ :rrd_path => '.',
12
+ }.merge(params)
13
+ create_or_find_rrd(name, datas, params)
14
+ push_to_rrd(name, datas, params)
12
15
  end
13
16
 
14
17
  def draw(name, time_scale = :day, params = {})
15
18
  params = {
16
- :filename => 'impuse.png',
19
+ :filename => 'impulse.png',
20
+ :rrd_path => '.',
21
+ :output_path => '.',
17
22
  :height => 200,
18
23
  :width => 600,
19
- :title => 'Impuse Graph',
24
+ :title => 'Impulse Graph',
20
25
  :vertical => '',
21
26
  :legend => '',
22
27
  :thickness => 1
23
28
  }.merge(params)
24
29
 
25
30
  defaults = "-E -W 'Generated at #{Time.at(Time.now)}' -e now -h #{params[:height]} -w #{params[:width]}"
26
- cmd = ["rrdtool graph #{params[:filename]} -s -#{seconds_for(time_scale)} #{defaults} -t '#{params[:title]}' -v '#{params[:vertical]}'"]
31
+ cmd = ["rrdtool graph #{params[:output_path]}/#{params[:filename]} -s -#{seconds_for(time_scale)} #{defaults} -t '#{params[:title]}' -v '#{params[:vertical]}'"]
27
32
 
28
33
  if name.is_a?(Hash)
29
34
  c = 0
30
35
  name.each do |k,v|
31
36
  v = { :color => '#FF0000', :data => :data }.merge(v)
32
- cmd << "DEF:d#{c}=#{v[:name]}.rrd:#{v[:data].to_s}:MAX"
37
+ cmd << "DEF:d#{c}=#{params[:rrd_path]}/#{v[:name]}.rrd:#{v[:data].to_s}:MAX"
33
38
  cmd << "LINE#{params[:thickness]}:d#{c}#{v[:color]}:'#{k}' GPRINT:d#{c}:LAST:\"Last\\:%8.0lf\" GPRINT:d#{c}:MIN:\" Min\\:%8.0lf\" GPRINT:d#{c}:AVERAGE:\" Avg\\:%8.0lf\" GPRINT:d#{c}:MAX:\" Max\\:%8.0lf\\n\""
34
39
  c += 1
35
40
  end
@@ -42,26 +47,26 @@ module Impulse
42
47
  end
43
48
 
44
49
  private
45
- def create_or_find_rrd(name, datas)
50
+ def create_or_find_rrd(name, datas , params)
46
51
  averages = "RRA:AVERAGE:0.5:1:576 RRA:MIN:0.5:1:576 RRA:MAX:0.5:1:576 RRA:AVERAGE:0.5:6:432 RRA:MIN:0.5:6:432 RRA:MAX:0.5:6:432 RRA:AVERAGE:0.5:24:540 RRA:MIN:0.5:24:540 RRA:MAX:0.5:24:540 RRA:AVERAGE:0.5:288:450 RRA:MIN:0.5:288:450 RRA:MAX:0.5:288:450"
47
- unless File.exist?(name + ".rrd")
52
+ unless File.exist?(params[:rrd_path] + "/" + name + ".rrd")
48
53
  puts 'Creating RRD' if @debug
49
54
  if datas.is_a?(Hash)
50
55
  entries = []
51
56
  datas.each do |k,v|
52
57
  entries << "DS:#{k.to_s}:GAUGE:600:0:U"
53
58
  end
54
- system "rrdtool create #{name}.rrd --step 300 --start #{Time.now.to_i - 1} #{entries.join(' ')} #{averages}"
59
+ system "rrdtool create #{params[:rrd_path]}/#{name}.rrd --step 300 --start #{Time.now.to_i - 1} #{entries.join(' ')} #{averages}"
55
60
  else
56
- system "rrdtool create #{name}.rrd --step 300 --start #{Time.now.to_i - 1} DS:data:GAUGE:600:0:U #{averages}"
61
+ system "rrdtool create #{params[:rrd_path]}/#{name}.rrd --step 300 --start #{Time.now.to_i - 1} DS:data:GAUGE:600:0:U #{averages}"
57
62
  end
58
63
  end
59
64
  end
60
65
 
61
- def push_to_rrd(name, data)
62
- if File.exist?(name + ".rrd")
66
+ def push_to_rrd(name, data, params)
67
+ if File.exist?(params[:rrd_path] + "/" + name + ".rrd")
63
68
  puts 'Updating RRD' if @debug
64
- system "rrdtool update #{name}.rrd #{Time.now.to_i}:#{data}"
69
+ system "rrdtool update #{params[:rrd_path]}/#{name}.rrd #{Time.now.to_i}:#{data}"
65
70
  end
66
71
  end
67
72
 
metadata CHANGED
@@ -1,13 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: impulse
3
3
  version: !ruby/object:Gem::Version
4
- hash: 25
4
+ hash: 23
5
5
  prerelease:
6
6
  segments:
7
7
  - 0
8
8
  - 0
9
- - 3
10
- version: 0.0.3
9
+ - 4
10
+ version: 0.0.4
11
11
  platform: ruby
12
12
  authors:
13
13
  - Lloyd Pick
@@ -15,9 +15,23 @@ autorequire:
15
15
  bindir: bin
16
16
  cert_chain: []
17
17
 
18
- date: 2011-05-11 00:00:00 Z
19
- dependencies: []
20
-
18
+ date: 2011-09-05 00:00:00 +01:00
19
+ default_executable:
20
+ dependencies:
21
+ - !ruby/object:Gem::Dependency
22
+ type: :development
23
+ requirement: &id001 !ruby/object:Gem::Requirement
24
+ none: false
25
+ requirements:
26
+ - - ">="
27
+ - !ruby/object:Gem::Version
28
+ hash: 3
29
+ segments:
30
+ - 0
31
+ version: "0"
32
+ version_requirements: *id001
33
+ name: rake
34
+ prerelease: false
21
35
  description: Ability to make RRDTool graphs with zero thought
22
36
  email:
23
37
  - lloydpick+impulse@gmail.com
@@ -35,6 +49,7 @@ files:
35
49
  - impulse.gemspec
36
50
  - lib/impulse.rb
37
51
  - lib/impulse/version.rb
52
+ has_rdoc: true
38
53
  homepage: https://github.com/lloydpick/impulse
39
54
  licenses: []
40
55
 
@@ -64,7 +79,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
64
79
  requirements: []
65
80
 
66
81
  rubyforge_project: impulse
67
- rubygems_version: 1.8.1
82
+ rubygems_version: 1.6.2
68
83
  signing_key:
69
84
  specification_version: 3
70
85
  summary: RubyGem to help make very quick RRDTool graphs