pulse-meter 0.4.9 → 0.4.11
Sign up to get free protection for your applications and to get access to all the features.
- data/Rakefile +1 -48
- data/lib/pulse-meter.rb +1 -68
- data/lib/pulse-meter/visualizer.rb +1 -40
- data/pulse-meter.gemspec +4 -26
- metadata +10 -558
- data/Procfile +0 -3
- data/bin/pulse +0 -6
- data/examples/basic.ru +0 -145
- data/examples/basic_sensor_data.rb +0 -96
- data/examples/udp_benchmark.rb +0 -29
- data/lib/cmd.rb +0 -171
- data/lib/pulse-meter/command_aggregator/async.rb +0 -83
- data/lib/pulse-meter/command_aggregator/sync.rb +0 -18
- data/lib/pulse-meter/command_aggregator/udp.rb +0 -48
- data/lib/pulse-meter/extensions/enumerable.rb +0 -24
- data/lib/pulse-meter/mixins/cmd.rb +0 -46
- data/lib/pulse-meter/mixins/dumper.rb +0 -87
- data/lib/pulse-meter/mixins/utils.rb +0 -155
- data/lib/pulse-meter/observer.rb +0 -120
- data/lib/pulse-meter/observer/extended.rb +0 -34
- data/lib/pulse-meter/sensor.rb +0 -61
- data/lib/pulse-meter/sensor/base.rb +0 -88
- data/lib/pulse-meter/sensor/configuration.rb +0 -106
- data/lib/pulse-meter/sensor/counter.rb +0 -39
- data/lib/pulse-meter/sensor/hashed_counter.rb +0 -36
- data/lib/pulse-meter/sensor/hashed_indicator.rb +0 -24
- data/lib/pulse-meter/sensor/indicator.rb +0 -35
- data/lib/pulse-meter/sensor/multi.rb +0 -97
- data/lib/pulse-meter/sensor/timeline.rb +0 -236
- data/lib/pulse-meter/sensor/timeline_reduce.rb +0 -68
- data/lib/pulse-meter/sensor/timelined/average.rb +0 -32
- data/lib/pulse-meter/sensor/timelined/counter.rb +0 -23
- data/lib/pulse-meter/sensor/timelined/hashed_counter.rb +0 -31
- data/lib/pulse-meter/sensor/timelined/hashed_indicator.rb +0 -30
- data/lib/pulse-meter/sensor/timelined/indicator.rb +0 -23
- data/lib/pulse-meter/sensor/timelined/max.rb +0 -19
- data/lib/pulse-meter/sensor/timelined/median.rb +0 -14
- data/lib/pulse-meter/sensor/timelined/min.rb +0 -19
- data/lib/pulse-meter/sensor/timelined/multi_percentile.rb +0 -34
- data/lib/pulse-meter/sensor/timelined/percentile.rb +0 -22
- data/lib/pulse-meter/sensor/timelined/uniq_counter.rb +0 -22
- data/lib/pulse-meter/sensor/timelined/zset_based.rb +0 -38
- data/lib/pulse-meter/sensor/uniq_counter.rb +0 -24
- data/lib/pulse-meter/server.rb +0 -0
- data/lib/pulse-meter/server/command_line_options.rb +0 -0
- data/lib/pulse-meter/server/config_options.rb +0 -0
- data/lib/pulse-meter/server/sensors.rb +0 -0
- data/lib/pulse-meter/udp_server.rb +0 -45
- data/lib/pulse-meter/version.rb +0 -3
- data/lib/pulse-meter/visualize/app.rb +0 -78
- data/lib/pulse-meter/visualize/base.rb +0 -15
- data/lib/pulse-meter/visualize/coffee/application.coffee +0 -40
- data/lib/pulse-meter/visualize/coffee/collections/page_info_list.coffee +0 -17
- data/lib/pulse-meter/visualize/coffee/collections/sensor_info_list.coffee +0 -4
- data/lib/pulse-meter/visualize/coffee/collections/widget_list.coffee +0 -14
- data/lib/pulse-meter/visualize/coffee/extensions.coffee +0 -26
- data/lib/pulse-meter/visualize/coffee/models/dinamic_widget.coffee +0 -34
- data/lib/pulse-meter/visualize/coffee/models/page_info.coffee +0 -2
- data/lib/pulse-meter/visualize/coffee/models/sensor_info.coffee +0 -2
- data/lib/pulse-meter/visualize/coffee/models/widget.coffee +0 -54
- data/lib/pulse-meter/visualize/coffee/presenters/area.coffee +0 -2
- data/lib/pulse-meter/visualize/coffee/presenters/gauge.coffee +0 -11
- data/lib/pulse-meter/visualize/coffee/presenters/line.coffee +0 -2
- data/lib/pulse-meter/visualize/coffee/presenters/pie.coffee +0 -20
- data/lib/pulse-meter/visualize/coffee/presenters/series.coffee +0 -44
- data/lib/pulse-meter/visualize/coffee/presenters/table.coffee +0 -10
- data/lib/pulse-meter/visualize/coffee/presenters/timeline.coffee +0 -13
- data/lib/pulse-meter/visualize/coffee/presenters/widget.coffee +0 -65
- data/lib/pulse-meter/visualize/coffee/router.coffee +0 -21
- data/lib/pulse-meter/visualize/coffee/views/dynamic_chart.coffee +0 -91
- data/lib/pulse-meter/visualize/coffee/views/dynamic_widget.coffee +0 -58
- data/lib/pulse-meter/visualize/coffee/views/page_title.coffee +0 -17
- data/lib/pulse-meter/visualize/coffee/views/page_titles.coffee +0 -15
- data/lib/pulse-meter/visualize/coffee/views/sensor_info_list.coffee +0 -19
- data/lib/pulse-meter/visualize/coffee/views/widget.coffee +0 -99
- data/lib/pulse-meter/visualize/coffee/views/widget_chart.coffee +0 -13
- data/lib/pulse-meter/visualize/coffee/views/widget_list.coffee +0 -15
- data/lib/pulse-meter/visualize/dsl/base.rb +0 -131
- data/lib/pulse-meter/visualize/dsl/errors.rb +0 -40
- data/lib/pulse-meter/visualize/dsl/layout.rb +0 -27
- data/lib/pulse-meter/visualize/dsl/page.rb +0 -33
- data/lib/pulse-meter/visualize/dsl/sensor.rb +0 -20
- data/lib/pulse-meter/visualize/dsl/widget.rb +0 -37
- data/lib/pulse-meter/visualize/dsl/widgets/area.rb +0 -20
- data/lib/pulse-meter/visualize/dsl/widgets/gauge.rb +0 -12
- data/lib/pulse-meter/visualize/dsl/widgets/line.rb +0 -21
- data/lib/pulse-meter/visualize/dsl/widgets/pie.rb +0 -16
- data/lib/pulse-meter/visualize/dsl/widgets/table.rb +0 -19
- data/lib/pulse-meter/visualize/layout.rb +0 -79
- data/lib/pulse-meter/visualize/page.rb +0 -25
- data/lib/pulse-meter/visualize/public/css/application.css +0 -56
- data/lib/pulse-meter/visualize/public/css/bootstrap.css +0 -4883
- data/lib/pulse-meter/visualize/public/css/bootstrap.min.css +0 -729
- data/lib/pulse-meter/visualize/public/css/images/ui-bg_flat_0_aaaaaa_40x100.png +0 -0
- data/lib/pulse-meter/visualize/public/css/images/ui-bg_glass_55_fbf9ee_1x400.png +0 -0
- data/lib/pulse-meter/visualize/public/css/images/ui-bg_glass_65_ffffff_1x400.png +0 -0
- data/lib/pulse-meter/visualize/public/css/images/ui-bg_glass_75_dadada_1x400.png +0 -0
- data/lib/pulse-meter/visualize/public/css/images/ui-bg_glass_75_e6e6e6_1x400.png +0 -0
- data/lib/pulse-meter/visualize/public/css/images/ui-bg_glass_75_ffffff_1x400.png +0 -0
- data/lib/pulse-meter/visualize/public/css/images/ui-bg_highlight-soft_75_cccccc_1x100.png +0 -0
- data/lib/pulse-meter/visualize/public/css/images/ui-bg_inset-soft_95_fef1ec_1x100.png +0 -0
- data/lib/pulse-meter/visualize/public/css/images/ui-icons_222222_256x240.png +0 -0
- data/lib/pulse-meter/visualize/public/css/images/ui-icons_2e83ff_256x240.png +0 -0
- data/lib/pulse-meter/visualize/public/css/images/ui-icons_454545_256x240.png +0 -0
- data/lib/pulse-meter/visualize/public/css/images/ui-icons_888888_256x240.png +0 -0
- data/lib/pulse-meter/visualize/public/css/images/ui-icons_cd0a0a_256x240.png +0 -0
- data/lib/pulse-meter/visualize/public/css/images/ui-icons_f6cf3b_256x240.png +0 -0
- data/lib/pulse-meter/visualize/public/css/jquery-ui-1.8.16.bootstrap.css +0 -1320
- data/lib/pulse-meter/visualize/public/favicon.ico +0 -208
- data/lib/pulse-meter/visualize/public/img/glyphicons-halflings-white.png +0 -0
- data/lib/pulse-meter/visualize/public/img/glyphicons-halflings.png +0 -0
- data/lib/pulse-meter/visualize/public/js/application.js +0 -973
- data/lib/pulse-meter/visualize/public/js/backbone-min.js +0 -38
- data/lib/pulse-meter/visualize/public/js/bootstrap.js +0 -1835
- data/lib/pulse-meter/visualize/public/js/jquery-1.7.2.min.js +0 -4
- data/lib/pulse-meter/visualize/public/js/jquery-ui-1.8.16.bootstrap.min.js +0 -791
- data/lib/pulse-meter/visualize/public/js/jquery-ui-1.8.23.custom.min.js +0 -21
- data/lib/pulse-meter/visualize/public/js/jquery-ui-timepicker-addon.js +0 -1687
- data/lib/pulse-meter/visualize/public/js/json2.js +0 -487
- data/lib/pulse-meter/visualize/public/js/underscore-min.js +0 -32
- data/lib/pulse-meter/visualize/sensor.rb +0 -63
- data/lib/pulse-meter/visualize/series_extractor.rb +0 -107
- data/lib/pulse-meter/visualize/views/main.haml +0 -30
- data/lib/pulse-meter/visualize/views/sensors.haml +0 -76
- data/lib/pulse-meter/visualize/views/widgets/area.haml +0 -53
- data/lib/pulse-meter/visualize/views/widgets/extend_options.haml +0 -11
- data/lib/pulse-meter/visualize/views/widgets/gauge.haml +0 -13
- data/lib/pulse-meter/visualize/views/widgets/line.haml +0 -54
- data/lib/pulse-meter/visualize/views/widgets/pie.haml +0 -13
- data/lib/pulse-meter/visualize/views/widgets/table.haml +0 -45
- data/lib/pulse-meter/visualize/widget.rb +0 -38
- data/lib/pulse-meter/visualize/widgets/gauge.rb +0 -47
- data/lib/pulse-meter/visualize/widgets/pie.rb +0 -36
- data/lib/pulse-meter/visualize/widgets/timeline.rb +0 -114
- data/spec/pulse_meter/command_aggregator/async_spec.rb +0 -53
- data/spec/pulse_meter/command_aggregator/sync_spec.rb +0 -25
- data/spec/pulse_meter/command_aggregator/udp_spec.rb +0 -45
- data/spec/pulse_meter/extensions/enumerable_spec.rb +0 -58
- data/spec/pulse_meter/mixins/cmd_spec.rb +0 -117
- data/spec/pulse_meter/mixins/dumper_spec.rb +0 -162
- data/spec/pulse_meter/mixins/utils_spec.rb +0 -212
- data/spec/pulse_meter/observer/extended_spec.rb +0 -92
- data/spec/pulse_meter/observer_spec.rb +0 -207
- data/spec/pulse_meter/sensor/base_spec.rb +0 -106
- data/spec/pulse_meter/sensor/configuration_spec.rb +0 -103
- data/spec/pulse_meter/sensor/counter_spec.rb +0 -54
- data/spec/pulse_meter/sensor/hashed_counter_spec.rb +0 -43
- data/spec/pulse_meter/sensor/hashed_indicator_spec.rb +0 -39
- data/spec/pulse_meter/sensor/indicator_spec.rb +0 -43
- data/spec/pulse_meter/sensor/multi_spec.rb +0 -137
- data/spec/pulse_meter/sensor/timeline_spec.rb +0 -88
- data/spec/pulse_meter/sensor/timelined/average_spec.rb +0 -6
- data/spec/pulse_meter/sensor/timelined/counter_spec.rb +0 -6
- data/spec/pulse_meter/sensor/timelined/hashed_counter_spec.rb +0 -8
- data/spec/pulse_meter/sensor/timelined/hashed_indicator_spec.rb +0 -8
- data/spec/pulse_meter/sensor/timelined/indicator_spec.rb +0 -6
- data/spec/pulse_meter/sensor/timelined/max_spec.rb +0 -7
- data/spec/pulse_meter/sensor/timelined/median_spec.rb +0 -7
- data/spec/pulse_meter/sensor/timelined/min_spec.rb +0 -7
- data/spec/pulse_meter/sensor/timelined/multi_percentile_spec.rb +0 -21
- data/spec/pulse_meter/sensor/timelined/percentile_spec.rb +0 -17
- data/spec/pulse_meter/sensor/timelined/uniq_counter_spec.rb +0 -9
- data/spec/pulse_meter/sensor/uniq_counter_spec.rb +0 -28
- data/spec/pulse_meter/udp_server_spec.rb +0 -36
- data/spec/pulse_meter/visualize/app_spec.rb +0 -27
- data/spec/pulse_meter/visualize/dsl/layout_spec.rb +0 -64
- data/spec/pulse_meter/visualize/dsl/page_spec.rb +0 -62
- data/spec/pulse_meter/visualize/dsl/sensor_spec.rb +0 -30
- data/spec/pulse_meter/visualize/dsl/widget_spec.rb +0 -6
- data/spec/pulse_meter/visualize/dsl/widgets/area_spec.rb +0 -44
- data/spec/pulse_meter/visualize/dsl/widgets/gauge_spec.rb +0 -22
- data/spec/pulse_meter/visualize/dsl/widgets/line_spec.rb +0 -44
- data/spec/pulse_meter/visualize/dsl/widgets/pie_spec.rb +0 -35
- data/spec/pulse_meter/visualize/dsl/widgets/table_spec.rb +0 -36
- data/spec/pulse_meter/visualize/layout_spec.rb +0 -54
- data/spec/pulse_meter/visualize/page_spec.rb +0 -153
- data/spec/pulse_meter/visualize/sensor_spec.rb +0 -120
- data/spec/pulse_meter/visualize/series_extractor_spec.rb +0 -80
- data/spec/pulse_meter/visualize/widgets/area_spec.rb +0 -6
- data/spec/pulse_meter/visualize/widgets/gauge_spec.rb +0 -63
- data/spec/pulse_meter/visualize/widgets/line_spec.rb +0 -6
- data/spec/pulse_meter/visualize/widgets/pie_spec.rb +0 -73
- data/spec/pulse_meter/visualize/widgets/table_spec.rb +0 -6
- data/spec/pulse_meter/visualizer_spec.rb +0 -42
- data/spec/pulse_meter_spec.rb +0 -73
- data/spec/shared_examples/dsl_widget.rb +0 -106
- data/spec/shared_examples/timeline_sensor.rb +0 -439
- data/spec/shared_examples/timelined_subclass.rb +0 -23
- data/spec/shared_examples/widget.rb +0 -97
- data/spec/spec_helper.rb +0 -40
- data/spec/support/matchers.rb +0 -34
- data/spec/support/observered.rb +0 -40
data/Procfile
DELETED
data/bin/pulse
DELETED
data/examples/basic.ru
DELETED
@@ -1,145 +0,0 @@
|
|
1
|
-
$: << File.join(File.dirname(__FILE__), '..', 'lib')
|
2
|
-
|
3
|
-
require 'pulse-meter/visualizer'
|
4
|
-
|
5
|
-
PulseMeter.redis = Redis.new
|
6
|
-
|
7
|
-
layout = PulseMeter::Visualizer.draw do |l|
|
8
|
-
|
9
|
-
l.title "WunderZoo Stats"
|
10
|
-
|
11
|
-
l.page "Counts" do |p|
|
12
|
-
|
13
|
-
p.line "Lama count" do |c|
|
14
|
-
c.sensor :lama_count, color: '#CC1155'
|
15
|
-
c.redraw_interval 5
|
16
|
-
c.values_label 'Count'
|
17
|
-
c.width 5
|
18
|
-
c.show_last_point true
|
19
|
-
c.timespan 1200
|
20
|
-
end
|
21
|
-
|
22
|
-
p.line "Lama count 1 min" do |c|
|
23
|
-
c.sensor :lama_count_1min, color: '#FA295C'
|
24
|
-
c.redraw_interval 5
|
25
|
-
c.values_label 'Count'
|
26
|
-
c.width 5
|
27
|
-
c.show_last_point true
|
28
|
-
c.timespan 1200
|
29
|
-
end
|
30
|
-
|
31
|
-
p.area "Rhino count", sensor: :rhino_count do |c|
|
32
|
-
c.redraw_interval 5
|
33
|
-
c.values_label 'Count'
|
34
|
-
c.width 5
|
35
|
-
c.show_last_point true
|
36
|
-
c.timespan 1200
|
37
|
-
end
|
38
|
-
|
39
|
-
p.line "Rhino & Lama & Goose count comparison" do |c|
|
40
|
-
c.redraw_interval 5
|
41
|
-
c.values_label 'Count'
|
42
|
-
c.width 5
|
43
|
-
c.show_last_point true
|
44
|
-
c.timespan 1200
|
45
|
-
|
46
|
-
c.sensor :rhino_count, color: '#AAAAAA'
|
47
|
-
c.sensor :lama_count, color: '#CC1155'
|
48
|
-
c.sensor :goose_count
|
49
|
-
end
|
50
|
-
|
51
|
-
p.pie "Rhino & Lama & Gooze count comparison" do |c|
|
52
|
-
c.redraw_interval 5
|
53
|
-
c.values_label 'Count'
|
54
|
-
c.width 5
|
55
|
-
c.show_last_point false
|
56
|
-
c.timespan 1200
|
57
|
-
|
58
|
-
c.sensor :rhino_count, color: '#AAAAAA'
|
59
|
-
c.sensor :lama_count, color: '#CC1155'
|
60
|
-
c.sensor :goose_count
|
61
|
-
end
|
62
|
-
|
63
|
-
p.gauge "CPU Usage" do |g|
|
64
|
-
g.redraw_interval 5
|
65
|
-
g.values_label '%'
|
66
|
-
g.width 5
|
67
|
-
|
68
|
-
g.red_from 90
|
69
|
-
g.red_to 100
|
70
|
-
g.yellow_from 75
|
71
|
-
g.yellow_to 90
|
72
|
-
g.minor_ticks 5
|
73
|
-
g.height 200
|
74
|
-
|
75
|
-
g.sensor :cpu
|
76
|
-
g.sensor :memory
|
77
|
-
g.sensor :temperature
|
78
|
-
end
|
79
|
-
|
80
|
-
p.table "Rhino & Lama & Goose count comparison" do |c|
|
81
|
-
c.redraw_interval 5
|
82
|
-
c.values_label 'Count'
|
83
|
-
c.width 10
|
84
|
-
c.show_last_point true
|
85
|
-
c.timespan 1200
|
86
|
-
|
87
|
-
c.sensor :rhino_count, color: '#AAAAAA'
|
88
|
-
c.sensor :lama_count, color: '#CC1155'
|
89
|
-
c.sensor :goose_count
|
90
|
-
end
|
91
|
-
|
92
|
-
|
93
|
-
end
|
94
|
-
|
95
|
-
l.page "Ages" do |p|
|
96
|
-
|
97
|
-
p.line "Lama average age", sensor: :lama_average_age do |c|
|
98
|
-
c.redraw_interval 5
|
99
|
-
c.values_label 'Age'
|
100
|
-
c.width 5
|
101
|
-
c.show_last_point true
|
102
|
-
c.timespan 1200
|
103
|
-
end
|
104
|
-
|
105
|
-
p.line "Rhino average age", sensor: :rhino_average_age do |c|
|
106
|
-
c.redraw_interval 5
|
107
|
-
c.values_label 'Age'
|
108
|
-
c.width 5
|
109
|
-
c.show_last_point true
|
110
|
-
c.timespan 1200
|
111
|
-
end
|
112
|
-
|
113
|
-
p.area "Rhino & Lama average age comparison" do |c|
|
114
|
-
c.redraw_interval 5
|
115
|
-
c.values_label 'Age'
|
116
|
-
c.width 5
|
117
|
-
c.show_last_point true
|
118
|
-
c.timespan 1200
|
119
|
-
|
120
|
-
c.sensor :lama_average_age
|
121
|
-
c.sensor :rhino_average_age
|
122
|
-
end
|
123
|
-
|
124
|
-
p.pie "Rhino & Lama average age comparison" do |c|
|
125
|
-
c.redraw_interval 5
|
126
|
-
c.values_label 'Age'
|
127
|
-
c.width 5
|
128
|
-
c.show_last_point false
|
129
|
-
c.timespan 1200
|
130
|
-
|
131
|
-
c.sensor :lama_average_age
|
132
|
-
c.sensor :rhino_average_age
|
133
|
-
end
|
134
|
-
|
135
|
-
p.gchart_options({
|
136
|
-
background_color: '#CCC'
|
137
|
-
})
|
138
|
-
end
|
139
|
-
|
140
|
-
l.gchart_options({
|
141
|
-
height: 300
|
142
|
-
})
|
143
|
-
end
|
144
|
-
|
145
|
-
run layout.to_app
|
@@ -1,96 +0,0 @@
|
|
1
|
-
$: << File.join(File.absolute_path(__FILE__), '..', 'lib')
|
2
|
-
|
3
|
-
require "pulse-meter"
|
4
|
-
|
5
|
-
PulseMeter.redis = Redis.new
|
6
|
-
|
7
|
-
cfg = PulseMeter::Sensor::Configuration.new(
|
8
|
-
lama_count: {
|
9
|
-
sensor_type:'timelined/counter',
|
10
|
-
args: {
|
11
|
-
annotation: 'Lama Count',
|
12
|
-
interval: 10,
|
13
|
-
ttl: 3600
|
14
|
-
}
|
15
|
-
},
|
16
|
-
|
17
|
-
lama_count_1min: {
|
18
|
-
sensor_type:'timelined/counter',
|
19
|
-
args: {
|
20
|
-
annotation: 'Lama Count (1 min)',
|
21
|
-
interval: 60,
|
22
|
-
ttl: 3600
|
23
|
-
}
|
24
|
-
},
|
25
|
-
|
26
|
-
lama_average_age: {
|
27
|
-
sensor_type:'timelined/average',
|
28
|
-
args: {
|
29
|
-
annotation: 'Lama Average Age',
|
30
|
-
interval: 20,
|
31
|
-
ttl: 3600
|
32
|
-
}
|
33
|
-
},
|
34
|
-
|
35
|
-
rhino_count: {
|
36
|
-
sensor_type:'timelined/counter',
|
37
|
-
args: {
|
38
|
-
annotation: 'Rhino Count',
|
39
|
-
interval: 10,
|
40
|
-
ttl: 3600
|
41
|
-
}
|
42
|
-
},
|
43
|
-
|
44
|
-
goose_count: {
|
45
|
-
sensor_type:'timelined/hashed_counter',
|
46
|
-
args: {
|
47
|
-
annotation: 'Goose Count',
|
48
|
-
interval: 10,
|
49
|
-
ttl: 3600
|
50
|
-
}
|
51
|
-
},
|
52
|
-
|
53
|
-
rhino_average_age: {
|
54
|
-
sensor_type:'timelined/average',
|
55
|
-
args: {
|
56
|
-
annotation: 'Rhino average age',
|
57
|
-
interval: 20,
|
58
|
-
ttl: 3600
|
59
|
-
}
|
60
|
-
},
|
61
|
-
|
62
|
-
sensor_without_annotation: {
|
63
|
-
sensor_type:'timelined/average',
|
64
|
-
args: {
|
65
|
-
interval: 20,
|
66
|
-
ttl: 3600
|
67
|
-
}
|
68
|
-
},
|
69
|
-
|
70
|
-
cpu: {sensor_type: 'indicator'},
|
71
|
-
memory: {sensor_type: 'indicator'},
|
72
|
-
temperature: {
|
73
|
-
sensor_type: 'hashed_indicator',
|
74
|
-
args: {
|
75
|
-
annotation: 'T'
|
76
|
-
}
|
77
|
-
}
|
78
|
-
)
|
79
|
-
|
80
|
-
while true
|
81
|
-
sleep(Random.rand)
|
82
|
-
STDERR.puts "tick"
|
83
|
-
cfg.lama_count(100000)
|
84
|
-
cfg.rhino_count(2)
|
85
|
-
cfg.lama_average_age(Random.rand(50))
|
86
|
-
cfg.rhino_average_age(Random.rand(100))
|
87
|
-
|
88
|
-
10.times do
|
89
|
-
goose_n = Random.rand(4)
|
90
|
-
cfg.goose_count("g_#{goose_n}" => 1)
|
91
|
-
cfg.temperature("g_#{goose_n}" => Random.rand(50))
|
92
|
-
end
|
93
|
-
|
94
|
-
cfg.cpu(Random.rand(100))
|
95
|
-
cfg.memory(Random.rand(100))
|
96
|
-
end
|
data/examples/udp_benchmark.rb
DELETED
@@ -1,29 +0,0 @@
|
|
1
|
-
$:.unshift File.expand_path('../../lib/', __FILE__)
|
2
|
-
|
3
|
-
require "pulse-meter"
|
4
|
-
|
5
|
-
PulseMeter.redis = Redis.new
|
6
|
-
PulseMeter.redis.flushdb
|
7
|
-
PulseMeter.command_aggregator = PulseMeter::CommandAggregator::UDP.new([['127.0.0.1', 33333], ['127.0.0.1', 33334], ['127.0.0.1', 33335],])
|
8
|
-
|
9
|
-
ss = PulseMeter::Sensor::Configuration.new(
|
10
|
-
cnt: {sensor_type: 'counter'}
|
11
|
-
)
|
12
|
-
|
13
|
-
start = Time.now.to_f
|
14
|
-
|
15
|
-
i = 0
|
16
|
-
loop do
|
17
|
-
i += 1
|
18
|
-
ss.cnt(1)
|
19
|
-
sleep 0.000005
|
20
|
-
if i % 1000 == 0
|
21
|
-
t = Time.now.to_f
|
22
|
-
passed = t - start
|
23
|
-
required_rps = i.to_f / passed
|
24
|
-
val = ss.sensor(:cnt){|s| s.value}
|
25
|
-
actual_rps = val.to_f / passed
|
26
|
-
p [i, required_rps, val, actual_rps]
|
27
|
-
end
|
28
|
-
end
|
29
|
-
|
data/lib/cmd.rb
DELETED
@@ -1,171 +0,0 @@
|
|
1
|
-
require 'thor'
|
2
|
-
require 'terminal-table'
|
3
|
-
require 'time'
|
4
|
-
require 'json'
|
5
|
-
require 'csv'
|
6
|
-
|
7
|
-
module Cmd
|
8
|
-
class All < Thor
|
9
|
-
include PulseMeter::Mixins::Utils
|
10
|
-
include PulseMeter::Mixins::Cmd
|
11
|
-
no_tasks do
|
12
|
-
def create_redis
|
13
|
-
Redis.new :host => options[:host], :port => options[:port], :db => options[:db]
|
14
|
-
end
|
15
|
-
|
16
|
-
def self.common_options
|
17
|
-
method_option :host, :default => '127.0.0.1', :desc => "Redis host"
|
18
|
-
method_option :port, :default => 6379, :desc => "Redis port"
|
19
|
-
method_option :db, :default => 0, :desc => "Redis db"
|
20
|
-
end
|
21
|
-
|
22
|
-
def self.sensor_options(required = [])
|
23
|
-
[
|
24
|
-
[:interval, :numeric, "Rotation interval"],
|
25
|
-
[:ttl, :numeric, "How long summarized data will be stored"],
|
26
|
-
[:raw_data_ttl, :numeric, "How long unsummarized raw data will be stored"],
|
27
|
-
[:reduce_delay, :numeric, "Delay between end of interval and summarization"],
|
28
|
-
[:annotation, :string, "Sensor annotation"]
|
29
|
-
].each do |name, type, desc = data|
|
30
|
-
method_option name, :required => required.include?(name), :type => type, :desc => desc
|
31
|
-
end
|
32
|
-
end
|
33
|
-
end
|
34
|
-
|
35
|
-
desc "sensors", "List all sensors available"
|
36
|
-
common_options
|
37
|
-
method_option :format, :default => :table, :desc => "Output format: table or csv"
|
38
|
-
def sensors
|
39
|
-
with_redis {puts all_sensors_table(options[:format])}
|
40
|
-
end
|
41
|
-
|
42
|
-
desc "reduce", "Execute reduction for all sensors' raw data"
|
43
|
-
common_options
|
44
|
-
def reduce
|
45
|
-
with_redis do
|
46
|
-
puts 'Registered sensors to be reduced'
|
47
|
-
puts all_sensors_table
|
48
|
-
PulseMeter::Sensor::Timeline.reduce_all_raw
|
49
|
-
puts "DONE"
|
50
|
-
end
|
51
|
-
end
|
52
|
-
|
53
|
-
desc "event NAME VALUE", "Send event VALUE to sensor NAME"
|
54
|
-
common_options
|
55
|
-
method_option :format, :default => :plain, :desc => "Event format: plain or json"
|
56
|
-
def event(name, value)
|
57
|
-
if "json" == options[:format]
|
58
|
-
value = JSON.parse(value)
|
59
|
-
end
|
60
|
-
with_safe_restore_of(name) {|sensor|
|
61
|
-
sensor.event(value)
|
62
|
-
}
|
63
|
-
PulseMeter.command_aggregator.wait_for_pending_events
|
64
|
-
end
|
65
|
-
|
66
|
-
desc "timeline NAME SECONDS", "Get sensor's NAME timeline for last SECONDS"
|
67
|
-
common_options
|
68
|
-
method_option :format, :default => :table, :desc => "Output format: table or csv"
|
69
|
-
def timeline(name, seconds)
|
70
|
-
with_safe_restore_of(name) do |sensor|
|
71
|
-
puts sensor.
|
72
|
-
timeline(seconds).
|
73
|
-
map {|data| [data.start_time, data.value || '']}.
|
74
|
-
to_table(options[:format])
|
75
|
-
end
|
76
|
-
end
|
77
|
-
|
78
|
-
desc "timeline_within NAME FROM TILL", "Get sensor's NAME timeline in interval. Time format: YYYY-MM-DD HH:MM:SS"
|
79
|
-
common_options
|
80
|
-
method_option :format, :default => :table, :desc => "Output format: table or csv"
|
81
|
-
def timeline_within(name, from, till)
|
82
|
-
with_safe_restore_of(name) do |sensor|
|
83
|
-
puts sensor.
|
84
|
-
timeline_within(Time.parse(from), Time.parse(till)).
|
85
|
-
map {|data| [data.start_time, data.value || '']}.
|
86
|
-
to_table(options[:format])
|
87
|
-
end
|
88
|
-
end
|
89
|
-
|
90
|
-
desc "delete NAME", "Delete sensor by name"
|
91
|
-
common_options
|
92
|
-
def delete(name)
|
93
|
-
with_safe_restore_of(name) {|sensor| sensor.cleanup}
|
94
|
-
puts "Sensor #{name} deleted"
|
95
|
-
end
|
96
|
-
|
97
|
-
desc "create NAME TYPE", "Create sensor of given type"
|
98
|
-
common_options
|
99
|
-
sensor_options([:ttl, :interval])
|
100
|
-
def create(name, type)
|
101
|
-
with_redis do
|
102
|
-
klass = constantize("PulseMeter::Sensor::Timelined::#{type}")
|
103
|
-
puts "PulseMeter::Sensor::Timelined::#{type}"
|
104
|
-
fail! "Unknown sensor type #{type}" unless klass
|
105
|
-
sensor = klass.new(name, options.dup)
|
106
|
-
puts "Sensor created"
|
107
|
-
puts all_sensors_table
|
108
|
-
end
|
109
|
-
end
|
110
|
-
|
111
|
-
desc "update NAME", "Update given sensor"
|
112
|
-
common_options
|
113
|
-
sensor_options
|
114
|
-
def update(name)
|
115
|
-
with_safe_restore_of(name) do |sensor|
|
116
|
-
opts = options.dup
|
117
|
-
[:ttl, :interval, :reduce_delay, :raw_data_ttl, :annotation].each do |attr|
|
118
|
-
opts[attr] ||= sensor.send(attr)
|
119
|
-
end
|
120
|
-
klass = sensor.class
|
121
|
-
new_sensor = klass.new(name, opts)
|
122
|
-
new_sensor.dump!(false)
|
123
|
-
puts "Sensor updated"
|
124
|
-
puts all_sensors_table
|
125
|
-
end
|
126
|
-
end
|
127
|
-
|
128
|
-
desc "create_simple NAME TYPE", "Create simple non-timelined sensor of given type"
|
129
|
-
common_options
|
130
|
-
method_option :annotation, :type => :string, :desc => "Sensor annotation"
|
131
|
-
def create_simple(name, type)
|
132
|
-
with_redis do
|
133
|
-
klass = constantize("PulseMeter::Sensor::#{type}")
|
134
|
-
fail! "Unknown sensor type #{type}" unless klass
|
135
|
-
sensor = klass.new(name, options.dup)
|
136
|
-
puts "Sensor created"
|
137
|
-
puts all_sensors_table
|
138
|
-
end
|
139
|
-
end
|
140
|
-
|
141
|
-
desc "value NAME", "Get value of non-timelined sensor"
|
142
|
-
def value(name)
|
143
|
-
with_safe_restore_of(name) do |sensor|
|
144
|
-
fail! "Sensor #{name} has no value method" unless sensor.respond_to?(:value)
|
145
|
-
puts "Value: #{sensor.value}"
|
146
|
-
end
|
147
|
-
end
|
148
|
-
|
149
|
-
desc "drop NAME DATE_FROM(YYYYmmddHHMMSS) DATE_TO(YYYYmmddHHMMSS)", "Drop timeline data of a particular sensor"
|
150
|
-
common_options
|
151
|
-
def drop(name, from, to)
|
152
|
-
time_from = parse_time(from)
|
153
|
-
time_to = parse_time(to)
|
154
|
-
with_safe_restore_of(name) do |sensor|
|
155
|
-
fail! "Sensor #{name} has no drop_within method" unless sensor.respond_to?(:drop_within)
|
156
|
-
sensor.drop_within(time_from, time_to)
|
157
|
-
end
|
158
|
-
end
|
159
|
-
|
160
|
-
desc "udp_proxy HOST PORT", "Start UDP proxy for sensor data"
|
161
|
-
common_options
|
162
|
-
def udp_proxy(host, port)
|
163
|
-
with_redis do
|
164
|
-
puts 'Starting UDP server'
|
165
|
-
server = PulseMeter::UDPServer.new(host, port)
|
166
|
-
server.start
|
167
|
-
end
|
168
|
-
end
|
169
|
-
|
170
|
-
end
|
171
|
-
end
|