luban-grafana 0.1.0 → 0.2.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 07fe7a5e8e72bf860fcb02fd79a7e2efd441e207
4
- data.tar.gz: dd89ef620d6863c4b3ac6d91670a1afbb0fb63f6
3
+ metadata.gz: f3cdadb053fe1d707901bad2da431f8405c40f32
4
+ data.tar.gz: 309aebf48822d4d6214dec63575b50979ee0b60c
5
5
  SHA512:
6
- metadata.gz: b2acdb78bf4f7313af43d464696c57800718769e9a633fe6d75bbd90931adeff1d09628768afdd1af69ac80e5f326794f2e09007ac4f962acce4d99f1b9fe286
7
- data.tar.gz: '0388b6257efa498dacb58f185a2fbe5fb4755ba6089f68511382c4ebfb6bfaa091fa79a285ea7b0c68ef465f039ef33f8c30f8bf3ea31cb2a6d73aa4a411a868'
6
+ metadata.gz: 607d8930bde2b2cdfd22ede1e32a472e6959df4b9eb5e7d9a5998724bee16ade6d5f94db5d5f0b64c364bfc0eaf465b1d2aa1eb5f47158379965c4fa5dae51d4
7
+ data.tar.gz: ead300ef60d2fbb6abed4e30b0493fc16d5f1ff330b9895cc8ecb97319bb071eb1bbbba21d75a453ace024e0894ab298e8054dccc798c4a7602e21fa50103724
data/CHANGLOG.md CHANGED
@@ -1,5 +1,21 @@
1
1
  # Change log
2
2
 
3
+ ## Version 0.2.0 (Nov 30, 2016)
4
+
5
+ Minor enhancements:
6
+ * Setup appropriate paths for deployment of Grafana
7
+ * Added parameters, #port and #network_host, for basic setup of Grafana
8
+ * Added Controller and Configurator to manage Grafana deployment
9
+ * Added related profile templates for Grafana
10
+ * Bump up gem dependency of luban to version 0.10.10
11
+
12
+ Bug fixes:
13
+ * Corrected parent class for Grafana
14
+ * Corrected parent class for Grafana::Installer
15
+ * Included Paths in Grafana::Installer
16
+ * Handled linked directories properly
17
+ * Cleaned up install path before installation
18
+
3
19
  ## Version 0.1.0 (Nov 25, 2016)
4
20
 
5
21
  New features:
@@ -1,4 +1,6 @@
1
1
  require 'luban'
2
2
  require_relative 'grafana/base'
3
3
  require_relative 'grafana/installer'
4
+ require_relative 'grafana/controller'
5
+ require_relative 'grafana/configurator'
4
6
  require_relative 'grafana/version'
@@ -1,7 +1,29 @@
1
1
  module Luban
2
2
  module Deployment
3
3
  module Packages
4
- class Grafana < Luban::Deployment::Package::Base
4
+ class Grafana < Luban::Deployment::Service::Base
5
+ module Paths
6
+ def control_file_dir; @control_file_dir ||= "conf"; end
7
+
8
+ def control_file_name
9
+ @control_file_name ||= "#{service_name}.ini"
10
+ end
11
+
12
+ def data_path
13
+ @data_path ||= shared_path.join('data')
14
+ end
15
+
16
+ def plugins_path
17
+ @plugins_path ||= data_path.join('plugins')
18
+ end
19
+ end
20
+
21
+ DefaultPort = 3000
22
+ DefaultNetworkHost = `hostname -f`.chomp
23
+
24
+ parameter :port, default: DefaultPort
25
+ parameter :network_host, default: DefaultNetworkHost
26
+
5
27
  protected
6
28
 
7
29
  def setup_provision_tasks
@@ -9,6 +31,10 @@ module Luban
9
31
  provision_tasks[:install].option :iter, "Iteration"
10
32
  provision_tasks[:install].option :dist, "Binary distribution"
11
33
  end
34
+
35
+ def include_default_templates_path
36
+ default_templates_paths.unshift(base_templates_path(__FILE__))
37
+ end
12
38
  end
13
39
  end
14
40
  end
@@ -0,0 +1,12 @@
1
+ module Luban
2
+ module Deployment
3
+ module Packages
4
+ class Grafana
5
+ class Configurator < Luban::Deployment::Service::Configurator
6
+ include Paths
7
+ include Controller::Commands
8
+ end
9
+ end
10
+ end
11
+ end
12
+ end
@@ -0,0 +1,34 @@
1
+ module Luban
2
+ module Deployment
3
+ module Packages
4
+ class Grafana
5
+ class Controller < Luban::Deployment::Service::Controller
6
+ module Commands
7
+ def self.included(base)
8
+ base.define_executable 'grafana-server'
9
+ end
10
+
11
+ def process_pattern
12
+ @process_pattern ||= "#{control_file_path}$"
13
+ end
14
+
15
+ def shell_setup
16
+ @shell_setup ||= super << "cd #{install_path}"
17
+ end
18
+
19
+ def start_command
20
+ @start_command ||= shell_command("#{grafana_server_executable} -pidfile #{pid_file_path} -config #{control_file_path}", output: nil) + ' &'
21
+ end
22
+
23
+ def stop_command
24
+ @stop_command ||= shell_command("kill $(cat #{pid_file_path} 2>/dev/null)")
25
+ end
26
+ end
27
+
28
+ include Paths
29
+ include Commands
30
+ end
31
+ end
32
+ end
33
+ end
34
+ end
@@ -1,8 +1,10 @@
1
1
  module Luban
2
2
  module Deployment
3
3
  module Packages
4
- class Grafana < Luban::Deployment::Package::Base
5
- class Installer < Luban::Deployment::Package::Installer
4
+ class Grafana
5
+ class Installer < Luban::Deployment::Service::Installer
6
+ include Paths
7
+
6
8
  define_executable 'grafana-cli'
7
9
 
8
10
  def package_iter; task.opts.iter; end
@@ -29,9 +31,15 @@ module Luban
29
31
 
30
32
  protected
31
33
 
34
+ def init
35
+ super
36
+ linked_dirs.push('data')
37
+ end
38
+
32
39
  def build_package
33
40
  info "Building #{package_full_name}"
34
41
  within install_path do
42
+ rm('-r', '*') # Clean up install path
35
43
  execute(:mv, build_path.join('*'), '.', ">> #{install_log_file_path} 2>&1")
36
44
  end
37
45
  end
@@ -0,0 +1,360 @@
1
+ ##################### Grafana Configuration #####################
2
+
3
+ # possible values : production, development
4
+ # app_mode = production
5
+
6
+ # instance name, defaults to HOSTNAME environment variable value or hostname if HOSTNAME var is empty
7
+ # instance_name = ${HOSTNAME}
8
+
9
+ #################################### Paths ####################################
10
+ [paths]
11
+ # Path to where grafana can store temp files, sessions, and the sqlite3 db (if that is used)
12
+ #
13
+ data = <%= data_path %>
14
+ #
15
+ # Directory where grafana can store logs
16
+ #
17
+ logs = <%= log_path %>
18
+ #
19
+ # Directory where grafana will automatically scan and look for plugins
20
+ #
21
+ plugins = <% plugins_path %>
22
+
23
+ #################################### Server ####################################
24
+ [server]
25
+ # Protocol (http or https)
26
+ # protocol = http
27
+
28
+ # The ip address to bind to, empty will bind to all interfaces
29
+ # http_addr =
30
+
31
+ # The http port to use
32
+ http_port = <%= port %>
33
+
34
+ # The public facing domain name used to access grafana from a browser
35
+ domain = <%= network_host %>
36
+
37
+ # Redirect to correct domain if host header does not match domain
38
+ # Prevents DNS rebinding attacks
39
+ # enforce_domain = false
40
+
41
+ # The full public facing url
42
+ # root_url = %(protocol)s://%(domain)s:%(http_port)s/
43
+
44
+ # Log web requests
45
+ # router_logging = false
46
+
47
+ # the path relative working path
48
+ # static_root_path = public
49
+
50
+ # enable gzip
51
+ # enable_gzip = false
52
+
53
+ # https certs & key file
54
+ # cert_file =
55
+ # cert_key =
56
+
57
+ #################################### Database ####################################
58
+ [database]
59
+ # Either "mysql", "postgres" or "sqlite3", it's your choice
60
+
61
+ # SQLite 3
62
+ type = sqlite3
63
+ name = grafana
64
+ # path relative to data_path setting
65
+ path = <%= application%>_<%= stage %>.db
66
+
67
+ # type = mysql
68
+ # host = 127.0.0.1:3306
69
+ # name = <%= application %>_<%= stage %>
70
+ # user = root
71
+ # password =
72
+
73
+ # For "postgres", use either "disable", "require" or "verify-full"
74
+ # For "mysql", use either "true", "false", or "skip-verify".
75
+ ssl_mode = disable
76
+
77
+ # ca_cert_path =
78
+ # client_key_path =
79
+ # client_cert_path =
80
+ # server_cert_name =
81
+
82
+ #################################### Session ####################################
83
+ [session]
84
+ # Either "memory", "file", "redis", "mysql", "postgres", "memcache", default is "file"
85
+ # provider = file
86
+ # provider_config = sessions
87
+
88
+ # Provider config options
89
+ # memory: not have any config yet
90
+ # file: session dir path, is relative to grafana data_path
91
+ # redis: config like redis server e.g. `addr=127.0.0.1:6379,pool_size=100,db=grafana`
92
+ # postgres: user=a password=b host=localhost port=5432 dbname=c sslmode=disable
93
+ # mysql: go-sql-driver/mysql dsn config string, examples:
94
+ # `user:password@tcp(127.0.0.1:3306)/database_name`
95
+ # `user:password@unix(/var/run/mysqld/mysqld.sock)/database_name`
96
+ # memcache: 127.0.0.1:11211
97
+
98
+ # Session cookie name
99
+ # cookie_name = <%= application %>_<%= stage %>_grafana_sess
100
+
101
+ # If you use session in https only, default is false
102
+ # cookie_secure = false
103
+
104
+ # Session life time, default is 86400
105
+ # session_life_time = 86400
106
+ # gc_interval_time = 86400
107
+
108
+ #################################### Analytics ####################################
109
+ [analytics]
110
+ # Server reporting, sends usage counters to stats.grafana.org every 24 hours.
111
+ # No ip addresses are being tracked, only simple counters to track
112
+ # running instances, dashboard and error counts. It is very helpful to us.
113
+ # Change this option to false to disable reporting.
114
+ reporting_enabled = false
115
+
116
+ # Set to false to disable all checks to https://grafana.net
117
+ # for new vesions (grafana itself and plugins), check is used
118
+ # in some UI views to notify that grafana or plugin update exists
119
+ # This option does not cause any auto updates, nor send any information
120
+ # only a GET request to http://grafana.net to get latest versions
121
+ check_for_updates = true
122
+
123
+ # Google Analytics universal tracking code, only enabled if you specify an id here
124
+ # google_analytics_ua_id =
125
+
126
+ # Google Tag Manager ID, only enabled if you specify an id here
127
+ # google_tag_manager_id =
128
+
129
+ #################################### Security ####################################
130
+ [security]
131
+ # default admin user, created on startup
132
+ # admin_user = admin
133
+
134
+ # default admin password, can be changed before first start of grafana, or in profile settings
135
+ # admin_password = admin
136
+
137
+ # used for signing
138
+ # secret_key = SW2YcwTIb9zpOOhoPsMm
139
+
140
+ # Auto-login remember days
141
+ # login_remember_days = 7
142
+ cookie_username = <%= application %>_<%= stage %>_grafana_user
143
+ cookie_remember_name = <%= application %>_<%= stage %>_grafana_remember
144
+
145
+ # disable gravatar profile images
146
+ # disable_gravatar = false
147
+
148
+ # data source proxy whitelist (ip_or_domain:port separated by spaces)
149
+ # data_source_proxy_whitelist =
150
+
151
+ [snapshots]
152
+ # snapshot sharing options
153
+ external_enabled = false
154
+ # external_snapshot_url = https://snapshots-origin.raintank.io
155
+ # external_snapshot_name = Publish to snapshot.raintank.io
156
+
157
+ #################################### Users ####################################
158
+ [users]
159
+ # disable user signup / registration
160
+ allow_sign_up = false
161
+
162
+ # Allow non admin users to create organizations
163
+ allow_org_create = false
164
+
165
+ # Set to true to automatically assign new users to the default organization (id 1)
166
+ # auto_assign_org = true
167
+
168
+ # Default role new users will be automatically assigned (if auto_assign_org above is set to true)
169
+ # auto_assign_org_role = Viewer
170
+
171
+ # Require email validation before sign up completes
172
+ # verify_email_enabled = false
173
+
174
+ # Background text for the user field on the login page
175
+ # login_hint = email or username
176
+
177
+ # Default UI theme ("dark" or "light")
178
+ # default_theme = dark
179
+
180
+ #################################### Anonymous Auth ##########################
181
+ [auth.anonymous]
182
+ # enable anonymous access
183
+ # enabled = false
184
+
185
+ # specify organization name that should be used for unauthenticated users
186
+ # org_name = Main Org.
187
+
188
+ # specify role for unauthenticated users
189
+ # org_role = Viewer
190
+
191
+ #################################### Github Auth ##########################
192
+ [auth.github]
193
+ enabled = false
194
+ # allow_sign_up = false
195
+ # client_id = some_id
196
+ # client_secret = some_secret
197
+ # scopes = user:email
198
+ # auth_url = https://github.com/login/oauth/authorize
199
+ # token_url = https://github.com/login/oauth/access_token
200
+ # api_url = https://api.github.com/user
201
+ # team_ids =
202
+ # allowed_organizations =
203
+
204
+ #################################### Google Auth ##########################
205
+ [auth.google]
206
+ enabled = false
207
+ # allow_sign_up = false
208
+ # client_id = some_client_id
209
+ # client_secret = some_client_secret
210
+ # scopes = https://www.googleapis.com/auth/userinfo.profile https://www.googleapis.com/auth/userinfo.email
211
+ # auth_url = https://accounts.google.com/o/oauth2/auth
212
+ # token_url = https://accounts.google.com/o/oauth2/token
213
+ # api_url = https://www.googleapis.com/oauth2/v1/userinfo
214
+ # allowed_domains =
215
+
216
+ #################################### Basic Auth ##########################
217
+ [auth.basic]
218
+ enabled = true
219
+
220
+ #################################### Auth Proxy ##########################
221
+ [auth.proxy]
222
+ enabled = false
223
+ # header_name = X-WEBAUTH-USER
224
+ # header_property = username
225
+ # auto_sign_up = true
226
+
227
+ #################################### Auth LDAP ##########################
228
+ [auth.ldap]
229
+ enabled = false
230
+ # config_file = <%= control_path.join('ldap.toml')
231
+
232
+ #################################### SMTP / Emailing ##########################
233
+ [smtp]
234
+ enabled = false
235
+ # host = localhost:25
236
+ # user =
237
+ # password =
238
+ # cert_file =
239
+ # key_file =
240
+ # skip_verify = false
241
+ # from_address = admin@grafana.localhost
242
+
243
+ [emails]
244
+ # welcome_email_on_sign_up = false
245
+ # templates_pattern = emails/*.html
246
+
247
+ #################################### Logging ##########################
248
+ [log]
249
+ # Either "console", "file", "syslog". Default is console and file
250
+ # Use space to separate multiple modes, e.g. "console file"
251
+ mode = console, file
252
+
253
+ # Either "debug", "info", "warn", "error", "critical", default is "info"
254
+ # level = info
255
+
256
+ # For "console" mode only
257
+ [log.console]
258
+ level =
259
+
260
+ # log line format, valid options are text, console and json
261
+ format = console
262
+
263
+ # For "file" mode only
264
+ [log.file]
265
+ level =
266
+
267
+ # log line format, valid options are text, console and json
268
+ format = text
269
+
270
+ # This enables automated log rotate(switch of following options), default is true
271
+ log_rotate = false
272
+
273
+ # Max line number of single file, default is 1000000
274
+ # max_lines = 1000000
275
+
276
+ # Max size shift of single file, default is 28 means 1 << 28, 256MB
277
+ # max_size_shift = 28
278
+
279
+ # Segment log daily, default is true
280
+ # daily_rotate = true
281
+
282
+ # Expired days of log file(delete after max days), default is 7
283
+ # max_days = 7
284
+
285
+ [log.syslog]
286
+ # level =
287
+
288
+ # log line format, valid options are text, console and json
289
+ # format = text
290
+
291
+ # Syslog network type and address. This can be udp, tcp, or unix. If left blank, the default unix endpoints will be used.
292
+ # network =
293
+ # address =
294
+
295
+ # Syslog facility. user, daemon and local0 through local7 are valid.
296
+ # facility =
297
+
298
+ # Syslog tag. By default, the process' argv[0] is used.
299
+ # tag =
300
+
301
+
302
+ #################################### AMQP Event Publisher ##########################
303
+ [event_publisher]
304
+ # enabled = false
305
+ # rabbitmq_url = amqp://localhost/
306
+ # exchange = grafana_events
307
+
308
+ #################################### Dashboard JSON files ##########################
309
+ [dashboards.json]
310
+ # enabled = false
311
+ # path = /var/lib/grafana/dashboards
312
+
313
+ #################################### Usage Quotas ##########################
314
+ [quota]
315
+ # enabled = false
316
+
317
+ #### set quotas to -1 to make unlimited. ####
318
+ # limit number of users per Org.
319
+ org_user = 10
320
+
321
+ # limit number of dashboards per Org.
322
+ org_dashboard = 100
323
+
324
+ # limit number of data_sources per Org.
325
+ org_data_source = 10
326
+
327
+ # limit number of api_keys per Org.
328
+ org_api_key = 10
329
+
330
+ # limit number of orgs a user can create.
331
+ user_org = 10
332
+
333
+ # Global limit of users.
334
+ global_user = -1
335
+
336
+ # global limit of orgs.
337
+ global_org = -1
338
+
339
+ # global limit of dashboards
340
+ global_dashboard = -1
341
+
342
+ # global limit of api_keys
343
+ global_api_key = -1
344
+
345
+ # global limit on number of logged in users.
346
+ global_session = -1
347
+
348
+ #################################### Internal Grafana Metrics ##########################
349
+ # Metrics available at HTTP API Url /api/metrics
350
+ [metrics]
351
+ enabled = false
352
+ # interval_seconds = 60
353
+
354
+ # Send internal Grafana metrics to graphite
355
+ # ; [metrics.graphite]
356
+ # ; address = localhost:2003
357
+ # ; prefix = prod.grafana.%(instance_name)s.
358
+
359
+ [grafana_net]
360
+ # url = https://grafana.net
@@ -0,0 +1,16 @@
1
+ # Grafana logrotate configuration
2
+
3
+ <%= log_file_path %> {
4
+ daily
5
+ maxsize 5M
6
+ maxage <%= logrotate_max_age %>
7
+ rotate <%= logrotate_count %>
8
+ missingok
9
+ compress
10
+ compresscmd <%= `which gzip`.chomp %>
11
+ delaycompress
12
+ dateext
13
+ dateformat -%Y%m%d-%H%M%S
14
+ copytruncate
15
+ olddir archived_logs
16
+ }
@@ -0,0 +1,10 @@
1
+ # Monit control file for Grafana
2
+
3
+ check process <%= service_entry %>
4
+ with pidfile <%= pid_file_path %>
5
+ onreboot laststate
6
+ start program = "/bin/bash -c 'sleep 1; <%= start_command %>'"
7
+ stop program = "/bin/bash -c '<%= stop_command %>'"
8
+ if failed port <%= port %> for 4 times within 8 cycles then restart
9
+ if cpu is greater than 80% for 20 cycles then alert
10
+ if loadavg(5min) greater than 10 for 40 cycles then restart
@@ -1,7 +1,7 @@
1
1
  module Luban
2
2
  module Deployment
3
3
  module Packages
4
- GRAFANA_VERSION = '0.1.0'
4
+ GRAFANA_VERSION = '0.2.0'
5
5
  end
6
6
  end
7
7
  end
@@ -20,7 +20,7 @@ Gem::Specification.new do |spec|
20
20
  spec.require_paths = ["lib"]
21
21
 
22
22
  spec.required_ruby_version = ">= 2.1.0"
23
- spec.add_dependency 'luban', ">= 0.10.6"
23
+ spec.add_dependency 'luban', ">= 0.10.10"
24
24
 
25
25
  spec.add_development_dependency "bundler", "~> 1.12"
26
26
  spec.add_development_dependency "rake", "~> 10.0"
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: luban-grafana
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.0
4
+ version: 0.2.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Rubyist Chi
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2016-11-25 00:00:00.000000000 Z
11
+ date: 2016-11-30 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: luban
@@ -16,14 +16,14 @@ dependencies:
16
16
  requirements:
17
17
  - - ">="
18
18
  - !ruby/object:Gem::Version
19
- version: 0.10.6
19
+ version: 0.10.10
20
20
  type: :runtime
21
21
  prerelease: false
22
22
  version_requirements: !ruby/object:Gem::Requirement
23
23
  requirements:
24
24
  - - ">="
25
25
  - !ruby/object:Gem::Version
26
- version: 0.10.6
26
+ version: 0.10.10
27
27
  - !ruby/object:Gem::Dependency
28
28
  name: bundler
29
29
  requirement: !ruby/object:Gem::Requirement
@@ -84,7 +84,12 @@ files:
84
84
  - lib/luban-grafana.rb
85
85
  - lib/luban/deployment/packages/grafana.rb
86
86
  - lib/luban/deployment/packages/grafana/base.rb
87
+ - lib/luban/deployment/packages/grafana/configurator.rb
88
+ - lib/luban/deployment/packages/grafana/controller.rb
87
89
  - lib/luban/deployment/packages/grafana/installer.rb
90
+ - lib/luban/deployment/packages/grafana/templates/conf/grafana.ini.erb
91
+ - lib/luban/deployment/packages/grafana/templates/grafana.logrotate.erb
92
+ - lib/luban/deployment/packages/grafana/templates/grafana.monitrc.erb
88
93
  - lib/luban/deployment/packages/grafana/version.rb
89
94
  - lib/luban/grafana.rb
90
95
  - luban-grafana.gemspec