perus 0.1.15 → 0.1.16

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: 733c49d83f2675c9e1a47508ca3694f14a946803
4
- data.tar.gz: 93067c4ab61180c3fc09ef70cf1315be28e5eab4
3
+ metadata.gz: 8c4b29dd1042da5633dbfe9fea75bca98cac4514
4
+ data.tar.gz: 7fea3792cac47ccc059e36d2ebd7737132d80b61
5
5
  SHA512:
6
- metadata.gz: f396acf003664d9c11cb6d40aed7ad545f4a683e68895ee8c1a803350d8dc79d954f9d60bc2e282a32d0a10dc702f3a4dbacaf646c31a0815a3a86261336c6cb
7
- data.tar.gz: db0c3585362f6226cb32a523271b980fe82f2932243c474eae216ddf4c522a4336fa09e5d3f3cf736030e9f9f5b44f82c3cd09751991fb44ddb449b7a08e369c
6
+ metadata.gz: a13fbf9079d45005f7ac934791f706987b786281fe8b4a35e701bbfcb6960780f2ceb10f12a7933d17e20e713b48f8b5687b24cdbb5edccf57868fe446f6bc5a
7
+ data.tar.gz: 6b8d5737db4686ad3f6a50ae4b6fd69b34b0daa4343aa78e51f114a141afc4eb5d1a1e65bfc89080a321efba36d24e497d8a735d117efee15661ecffb0c8f5d3
@@ -6,7 +6,7 @@ require 'uri'
6
6
 
7
7
  DEFAULT_PINGER_OPTIONS = {
8
8
  '__anonymous__' => {
9
- 'server' => 'http://127.0.0.1:3000/'
9
+ 'server' => 'http://127.0.0.1:5000/'
10
10
  },
11
11
 
12
12
  # restricted values
@@ -17,7 +17,7 @@ module Perus::Server
17
17
  Sequel.extension :inflector
18
18
 
19
19
  # connect/create the database and run any new migrations
20
- @db = Sequel.postgres('perus', host: 'localhost')
20
+ @db = Sequel.postgres('perus', host: 'localhost', username: Server.options.db['username'], password: Server.options.db['password'])
21
21
  Sequel::Migrator.run(@db, File.join(__dir__, 'migrations'))
22
22
 
23
23
  # load models - these rely on an existing db connection
@@ -3,7 +3,7 @@ Sequel.migration do
3
3
  create_table(:metrics) do
4
4
  primary_key :id
5
5
  String :name, null: false
6
- String :system_id, null: false
6
+ Integer :system_id, null: false
7
7
  String :type, null: false
8
8
  String :file, text: true
9
9
  index [:system_id, :name]
@@ -0,0 +1,13 @@
1
+ Sequel.migration do
2
+ up do
3
+ alter_table(:configs) do
4
+ add_column :maintenance, String
5
+ end
6
+ end
7
+
8
+ down do
9
+ alter_table(:configs) do
10
+ drop_column :maintenance
11
+ end
12
+ end
13
+ end
@@ -2,7 +2,7 @@ module Perus::Server
2
2
  class Config < Sequel::Model
3
3
  plugin :validation_helpers
4
4
  one_to_many :systems
5
- one_to_many :config_metrics, order: 'name asc'
5
+ one_to_many :config_metrics, order: :order
6
6
 
7
7
  def metric_hashes
8
8
  config_metrics.collect(&:config_hash)
@@ -20,6 +20,22 @@ module Perus::Server
20
20
  systems_dataset.empty?
21
21
  end
22
22
 
23
+ def in_maintenance?
24
+ return false unless maintenance.is_a?(String)
25
+ from, to = maintenance.split('-')
26
+ now = Time.now
27
+
28
+ from_hour, from_min = from.split(':').map(&:to_i)
29
+ return false if now.hour < from_hour
30
+ return false if now.hour == from_hour && now.min < from_min
31
+
32
+ to_hour, to_min = to.split(':').map(&:to_i)
33
+ return false if now.hour > to_hour
34
+ return false if now.hour == to_hour && now.min > to_min
35
+
36
+ true
37
+ end
38
+
23
39
  def validate
24
40
  super
25
41
  validates_presence :name
@@ -1,7 +1,7 @@
1
1
  module Perus::Server
2
2
  class Script < Sequel::Model
3
3
  plugin :validation_helpers
4
- one_to_many :script_commands, order: 'name asc'
4
+ one_to_many :script_commands, order: :order
5
5
  one_to_many :actions
6
6
 
7
7
  def code_name
@@ -65,6 +65,8 @@ module Perus::Server
65
65
  # metrics
66
66
  # ---------------------------------------
67
67
  def save_metric_errors(params, timestamp)
68
+ # ignore errors during maintenance window
69
+ return if config.in_maintenance?
68
70
  errors = JSON.parse(params['metric_errors'])
69
71
 
70
72
  errors.each do |module_name, module_errors|
@@ -7,12 +7,16 @@ DEFAULT_SERVER_OPTIONS = {
7
7
  'uploads_url' => 'http://localhost:3000/uploads/',
8
8
  'db_path' => './perus.db',
9
9
  'listen' => '0.0.0.0',
10
- 'port' => 3000,
10
+ 'port' => 5000,
11
11
  'site_name' => 'Perus',
12
12
  'url_prefix' => '/',
13
13
  'keep_hours' => 24,
14
14
  'cache_alerts_secs' => 20,
15
15
  'stats_path' => '/var/perus.stats'
16
+ },
17
+ 'db' => {
18
+ 'username' => '',
19
+ 'password' => ''
16
20
  }
17
21
  }
18
22
 
@@ -1 +1,2 @@
1
1
  <%= @form.field :name %>
2
+ <%= @form.field :maintenance %>
data/lib/perus/version.rb CHANGED
@@ -1,3 +1,3 @@
1
1
  module Perus
2
- VERSION = "0.1.15"
2
+ VERSION = "0.1.16"
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: perus
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.15
4
+ version: 0.1.16
5
5
  platform: ruby
6
6
  authors:
7
7
  - Will Cannings
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2015-07-17 00:00:00.000000000 Z
11
+ date: 2015-07-18 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -266,6 +266,7 @@ files:
266
266
  - lib/perus/server/migrations/012_create_config_metrics.rb
267
267
  - lib/perus/server/migrations/013_create_active_alerts.rb
268
268
  - lib/perus/server/migrations/014_alerts_can_have_errors.rb
269
+ - lib/perus/server/migrations/015_configs_have_maintenance_window.rb
269
270
  - lib/perus/server/models/action.rb
270
271
  - lib/perus/server/models/active_alert.rb
271
272
  - lib/perus/server/models/alert.rb