minicron 0.1.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (97) hide show
  1. checksums.yaml +7 -0
  2. data/LICENSE +674 -0
  3. data/README.md +187 -0
  4. data/Rakefile +17 -0
  5. data/bin/minicron +26 -0
  6. data/lib/minicron.rb +179 -0
  7. data/lib/minicron/alert.rb +115 -0
  8. data/lib/minicron/alert/email.rb +50 -0
  9. data/lib/minicron/alert/pagerduty.rb +39 -0
  10. data/lib/minicron/alert/sms.rb +47 -0
  11. data/lib/minicron/cli.rb +367 -0
  12. data/lib/minicron/constants.rb +7 -0
  13. data/lib/minicron/cron.rb +192 -0
  14. data/lib/minicron/hub/app.rb +132 -0
  15. data/lib/minicron/hub/assets/app/application.js +151 -0
  16. data/lib/minicron/hub/assets/app/components/schedules.js +280 -0
  17. data/lib/minicron/hub/assets/app/controllers/executions.js +35 -0
  18. data/lib/minicron/hub/assets/app/controllers/hosts.js +129 -0
  19. data/lib/minicron/hub/assets/app/controllers/jobs.js +109 -0
  20. data/lib/minicron/hub/assets/app/controllers/schedules.js +80 -0
  21. data/lib/minicron/hub/assets/app/helpers.js +22 -0
  22. data/lib/minicron/hub/assets/app/models/execution.js +13 -0
  23. data/lib/minicron/hub/assets/app/models/host.js +15 -0
  24. data/lib/minicron/hub/assets/app/models/job.js +15 -0
  25. data/lib/minicron/hub/assets/app/models/job_execution_output.js +11 -0
  26. data/lib/minicron/hub/assets/app/models/schedule.js +32 -0
  27. data/lib/minicron/hub/assets/app/router.js +31 -0
  28. data/lib/minicron/hub/assets/app/routes/executions.js +36 -0
  29. data/lib/minicron/hub/assets/app/routes/hosts.js +42 -0
  30. data/lib/minicron/hub/assets/app/routes/index.js +9 -0
  31. data/lib/minicron/hub/assets/app/routes/jobs.js +52 -0
  32. data/lib/minicron/hub/assets/app/routes/schedules.js +37 -0
  33. data/lib/minicron/hub/assets/css/bootswatch.min.css +9 -0
  34. data/lib/minicron/hub/assets/css/main.scss +323 -0
  35. data/lib/minicron/hub/assets/fonts/glyphicons-halflings-regular.eot +0 -0
  36. data/lib/minicron/hub/assets/fonts/glyphicons-halflings-regular.svg +229 -0
  37. data/lib/minicron/hub/assets/fonts/glyphicons-halflings-regular.ttf +0 -0
  38. data/lib/minicron/hub/assets/fonts/glyphicons-halflings-regular.woff +0 -0
  39. data/lib/minicron/hub/assets/fonts/lato-bold-700.woff +0 -0
  40. data/lib/minicron/hub/assets/fonts/lato-italic-400.woff +0 -0
  41. data/lib/minicron/hub/assets/fonts/lato-regular-400.woff +0 -0
  42. data/lib/minicron/hub/assets/js/ansi_up-1.1.1.min.js +6 -0
  43. data/lib/minicron/hub/assets/js/auth/ember-auth-9.0.7.min.js +2 -0
  44. data/lib/minicron/hub/assets/js/auth/ember-auth-request-jquery-1.0.3.min.js +1 -0
  45. data/lib/minicron/hub/assets/js/bootstrap-3.1.1.min.js +6 -0
  46. data/lib/minicron/hub/assets/js/ember-1.4.1.min.js +18 -0
  47. data/lib/minicron/hub/assets/js/ember-data-1.0.0-beta.7.f87cba88.min.js +10 -0
  48. data/lib/minicron/hub/assets/js/faye-browser-1.0.1.min.js +2 -0
  49. data/lib/minicron/hub/assets/js/handlebars-1.3.0.min.js +29 -0
  50. data/lib/minicron/hub/assets/js/jquery-2.1.0.min.js +4 -0
  51. data/lib/minicron/hub/assets/js/moment-2.5.1.min.js +7 -0
  52. data/lib/minicron/hub/controllers/api/executions.rb +34 -0
  53. data/lib/minicron/hub/controllers/api/hosts.rb +150 -0
  54. data/lib/minicron/hub/controllers/api/job_execution_outputs.rb +30 -0
  55. data/lib/minicron/hub/controllers/api/jobs.rb +118 -0
  56. data/lib/minicron/hub/controllers/api/schedule.rb +184 -0
  57. data/lib/minicron/hub/controllers/index.rb +5 -0
  58. data/lib/minicron/hub/db/schema.rb +98 -0
  59. data/lib/minicron/hub/db/schema.sql +158 -0
  60. data/lib/minicron/hub/models/alert.rb +7 -0
  61. data/lib/minicron/hub/models/execution.rb +8 -0
  62. data/lib/minicron/hub/models/host.rb +7 -0
  63. data/lib/minicron/hub/models/job.rb +18 -0
  64. data/lib/minicron/hub/models/job_execution_output.rb +7 -0
  65. data/lib/minicron/hub/models/schedule.rb +25 -0
  66. data/lib/minicron/hub/serializers/execution.rb +75 -0
  67. data/lib/minicron/hub/serializers/host.rb +57 -0
  68. data/lib/minicron/hub/serializers/job.rb +104 -0
  69. data/lib/minicron/hub/serializers/job_execution_output.rb +48 -0
  70. data/lib/minicron/hub/serializers/schedule.rb +68 -0
  71. data/lib/minicron/hub/views/handlebars/application.erb +51 -0
  72. data/lib/minicron/hub/views/handlebars/errors.erb +29 -0
  73. data/lib/minicron/hub/views/handlebars/executions.erb +79 -0
  74. data/lib/minicron/hub/views/handlebars/hosts.erb +205 -0
  75. data/lib/minicron/hub/views/handlebars/jobs.erb +203 -0
  76. data/lib/minicron/hub/views/handlebars/loading.erb +3 -0
  77. data/lib/minicron/hub/views/handlebars/schedules.erb +354 -0
  78. data/lib/minicron/hub/views/index.erb +7 -0
  79. data/lib/minicron/hub/views/layouts/app.erb +15 -0
  80. data/lib/minicron/monitor.rb +116 -0
  81. data/lib/minicron/transport.rb +15 -0
  82. data/lib/minicron/transport/client.rb +80 -0
  83. data/lib/minicron/transport/faye/client.rb +103 -0
  84. data/lib/minicron/transport/faye/extensions/job_handler.rb +184 -0
  85. data/lib/minicron/transport/faye/server.rb +58 -0
  86. data/lib/minicron/transport/server.rb +62 -0
  87. data/lib/minicron/transport/ssh.rb +51 -0
  88. data/spec/invalid_config.toml +2 -0
  89. data/spec/minicron/cli_spec.rb +154 -0
  90. data/spec/minicron/transport/client_spec.rb +8 -0
  91. data/spec/minicron/transport/faye/client_spec.rb +53 -0
  92. data/spec/minicron/transport/server_spec.rb +70 -0
  93. data/spec/minicron/transport_spec.rb +13 -0
  94. data/spec/minicron_spec.rb +133 -0
  95. data/spec/spec_helper.rb +33 -0
  96. data/spec/valid_config.toml +48 -0
  97. metadata +577 -0
@@ -0,0 +1,30 @@
1
+ class Minicron::Hub::App
2
+ # Get all job execution outputs
3
+ # TODO: Add offset/limit
4
+ get '/api/jobExecutionOutputs' do
5
+ content_type :json
6
+
7
+ if params[:ids]
8
+ output = Minicron::Hub::JobExecutionOutput.includes(:execution)
9
+ .where(:id => params[:ids])
10
+ .order(:id => :asc)
11
+ elsif params[:execution_id]
12
+ output = Minicron::Hub::JobExecutionOutput.includes(:execution)
13
+ .where(:execution_id => params[:execution_id])
14
+ .order(:id => :asc)
15
+ else
16
+ output = Minicron::Hub::JobExecutionOutput.all.order(:id => :asc)
17
+ end
18
+
19
+ JobExecutionOutputSerializer.new(output).serialize.to_json
20
+ end
21
+
22
+ # Get a single job execution output by it ID
23
+ get '/api/jobExecutionOutputs/:id' do
24
+ content_type :json
25
+ output = Minicron::Hub::JobExecutionOutput.includes(:execution)
26
+ .order(:id => :asc)
27
+ .find(params[:id])
28
+ JobExecutionOutputSerializer.new(output).serialize.to_json
29
+ end
30
+ end
@@ -0,0 +1,118 @@
1
+ require 'minicron/transport'
2
+
3
+ class Minicron::Hub::App
4
+ # Get all jobs
5
+ # TODO: Add offset/limit
6
+ get '/api/jobs' do
7
+ content_type :json
8
+
9
+ if params[:job_hash]
10
+ jobs = Minicron::Hub::Job.includes(:host, :schedules, { :executions => :job_execution_outputs })
11
+ .where(:job_hash => params[:job_hash])
12
+ else
13
+ jobs = Minicron::Hub::Job.all.order(:created_at => :desc)
14
+ .includes(:host, :schedules, { :executions => :job_execution_outputs })
15
+ end
16
+
17
+ JobSerializer.new(jobs).serialize.to_json
18
+ end
19
+
20
+ # Get a single job by it ID
21
+ get '/api/jobs/:id' do
22
+ content_type :json
23
+ job = Minicron::Hub::Job.includes(:host, :schedules, { :executions => :job_execution_outputs })
24
+ .find(params[:id])
25
+ JobSerializer.new(job).serialize.to_json
26
+ end
27
+
28
+ # Create a new job
29
+ post '/api/jobs' do
30
+ content_type :json
31
+ begin
32
+ # Load the JSON body
33
+ request_body = Oj.load(request.body)
34
+
35
+ # First we need to look up the host
36
+ host = Minicron::Hub::Host.find(request_body['job']['host'])
37
+
38
+ # Try and save the new job
39
+ job = Minicron::Hub::Job.create(
40
+ :job_hash => Minicron::Transport.get_job_hash(request_body['job']['command'], host.fqdn),
41
+ :name => request_body['job']['name'],
42
+ :command => request_body['job']['command'],
43
+ :host_id => host.id
44
+ )
45
+
46
+ job.save!
47
+
48
+ # Return the new job
49
+ JobSerializer.new(job).serialize.to_json
50
+ # TODO: nicer error handling here with proper validation before hand
51
+ rescue Exception => e
52
+ status 422
53
+ { :error => e.message }.to_json
54
+ end
55
+ end
56
+
57
+ # Update an existing job
58
+ put '/api/jobs/:id' do
59
+ content_type :json
60
+ begin
61
+ # Load the JSON body
62
+ request_body = Oj.load(request.body)
63
+
64
+ # Find the job
65
+ job = Minicron::Hub::Job.includes(:host, :schedules, { :executions => :job_execution_outputs })
66
+ .find(params[:id])
67
+
68
+ # Update the name
69
+ job.name = request_body['job']['name']
70
+
71
+ job.save!
72
+
73
+ # Return the new job
74
+ JobSerializer.new(job).serialize.to_json
75
+ # TODO: nicer error handling here with proper validation before hand
76
+ rescue Exception => e
77
+ status 422
78
+ { :error => e.message }.to_json
79
+ end
80
+ end
81
+
82
+ # Delete an existing job
83
+ delete '/api/jobs/:id' do
84
+ content_type :json
85
+ begin
86
+ Minicron::Hub::Job.transaction do
87
+ # Look up the job
88
+ job = Minicron::Hub::Job.includes(:schedules).find(params[:id])
89
+
90
+ # Try and delete the job
91
+ Minicron::Hub::Job.destroy(params[:id])
92
+
93
+ # Get an ssh instance
94
+ ssh = Minicron::Transport::SSH.new(
95
+ :host => job.host.host,
96
+ :port => job.host.port,
97
+ :private_key => "~/.ssh/minicron_host_#{job.host.id}_rsa"
98
+ )
99
+
100
+ # Get an instance of the cron class
101
+ cron = Minicron::Cron.new(ssh)
102
+
103
+ # Delete the job from the crontab
104
+ cron.delete_job(job)
105
+
106
+ # Tidy up
107
+ ssh.close
108
+
109
+ # This is what ember expects as the response
110
+ status 204
111
+ end
112
+ # TODO: nicer error handling here with proper validation before hand
113
+ rescue Exception => e
114
+ status 422
115
+ { :error => e.message }.to_json
116
+ end
117
+ end
118
+ end
@@ -0,0 +1,184 @@
1
+ require 'minicron/transport/ssh'
2
+ require 'minicron/cron'
3
+
4
+ class Minicron::Hub::App
5
+ # Get all schedules
6
+ # TODO: Add offset/limit
7
+ get '/api/schedules' do
8
+ content_type :json
9
+
10
+ if params[:ids]
11
+ schedules = Minicron::Hub::Schedule.where(:id => params[:ids])
12
+ .order(:id => :asc)
13
+ .includes({ :job => [:executions, :schedules] })
14
+ else
15
+ schedules = Minicron::Hub::Schedule.all.order(:id => :asc)
16
+ .includes({ :job => [:executions, :schedules] })
17
+ end
18
+
19
+ ScheduleSerializer.new(schedules).serialize.to_json
20
+ end
21
+
22
+ # Get a single schedule by it ID
23
+ get '/api/schedules/:id' do
24
+ content_type :json
25
+ schedule = Minicron::Hub::Schedule.includes({ :job => [:executions, :schedules] }).find(params[:id])
26
+ ScheduleSerializer.new(schedule).serialize.to_json
27
+ end
28
+
29
+ # Create a new schedule
30
+ post '/api/schedules' do
31
+ content_type :json
32
+ begin
33
+ # Load the JSON body
34
+ request_body = Oj.load(request.body)
35
+
36
+ # First we need to check a schedule like this doesn't already exist
37
+ exists = Minicron::Hub::Schedule.exists?(
38
+ :minute => request_body['schedule']['minute'],
39
+ :hour => request_body['schedule']['hour'],
40
+ :day_of_the_month => request_body['schedule']['day_of_the_month'],
41
+ :month => request_body['schedule']['month'],
42
+ :day_of_the_week => request_body['schedule']['day_of_the_week'],
43
+ :special => request_body['schedule']['special'],
44
+ :job_id => request_body['schedule']['job']
45
+ )
46
+
47
+ if exists
48
+ raise Exception, "That schedule already exists for this job"
49
+ end
50
+
51
+ Minicron::Hub::Schedule.transaction do
52
+ # Create the new schedule
53
+ schedule = Minicron::Hub::Schedule.create(
54
+ :minute => request_body['schedule']['minute'],
55
+ :hour => request_body['schedule']['hour'],
56
+ :day_of_the_month => request_body['schedule']['day_of_the_month'],
57
+ :month => request_body['schedule']['month'],
58
+ :day_of_the_week => request_body['schedule']['day_of_the_week'],
59
+ :special => request_body['schedule']['special'],
60
+ :job_id => request_body['schedule']['job']
61
+ )
62
+
63
+ # Get the job and host for the schedule
64
+ job = Minicron::Hub::Job.includes(:host).find(schedule.job_id)
65
+
66
+ # Get an ssh instance
67
+ ssh = Minicron::Transport::SSH.new(
68
+ :host => job.host.host,
69
+ :port => job.host.port,
70
+ :private_key => "~/.ssh/minicron_host_#{job.host.id}_rsa"
71
+ )
72
+
73
+ # Get an instance of the cron class
74
+ cron = Minicron::Cron.new(ssh)
75
+
76
+ # Add the schedule to the crontab
77
+ cron.add_schedule(job, schedule.formatted)
78
+
79
+ # Tidy up
80
+ ssh.close
81
+
82
+ # And finally save it
83
+ schedule.save!
84
+
85
+ # Return the new schedule
86
+ ScheduleSerializer.new(schedule).serialize.to_json
87
+ end
88
+ # TODO: nicer error handling here with proper validation before hand
89
+ rescue Exception => e
90
+ status 422
91
+ { :error => e.message }.to_json
92
+ end
93
+ end
94
+
95
+ # Update an existing schedule
96
+ put '/api/schedules/:id' do
97
+ content_type :json
98
+ begin
99
+ # Load the JSON body
100
+ request_body = Oj.load(request.body)
101
+
102
+ Minicron::Hub::Schedule.transaction do
103
+ # Find the schedule
104
+ schedule = Minicron::Hub::Schedule.includes({ :job => [:executions, :schedules] }).find(params[:id])
105
+ old_schedule = schedule.formatted
106
+
107
+ # Get an ssh instance
108
+ ssh = Minicron::Transport::SSH.new(
109
+ :host => schedule.job.host.host,
110
+ :port => schedule.job.host.port,
111
+ :private_key => "~/.ssh/minicron_host_#{schedule.job.host.id}_rsa"
112
+ )
113
+
114
+ # Get an instance of the cron class
115
+ cron = Minicron::Cron.new(ssh)
116
+
117
+ # Update the instance of the new schedule
118
+ schedule.minute = request_body['schedule']['minute']
119
+ schedule.hour = request_body['schedule']['hour']
120
+ schedule.day_of_the_month = request_body['schedule']['day_of_the_month']
121
+ schedule.month = request_body['schedule']['month']
122
+ schedule.day_of_the_week = request_body['schedule']['day_of_the_week']
123
+ schedule.special = request_body['schedule']['special']
124
+
125
+ # Update the schedule
126
+ cron.update_schedule(
127
+ schedule.job,
128
+ old_schedule,
129
+ schedule.formatted
130
+ )
131
+
132
+ # Tidy up
133
+ ssh.close
134
+
135
+ # And finally save it
136
+ schedule.save!
137
+
138
+ # Return the new schedule
139
+ ScheduleSerializer.new(schedule).serialize.to_json
140
+ end
141
+ # TODO: nicer error handling here with proper validation before hand
142
+ rescue Exception => e
143
+ status 422
144
+ { :error => e.message }.to_json
145
+ end
146
+ end
147
+
148
+ # Delete an existing schedule
149
+ delete '/api/schedules/:id' do
150
+ content_type :json
151
+ begin
152
+ Minicron::Hub::Schedule.transaction do
153
+ # Find the schedule
154
+ schedule = Minicron::Hub::Schedule.includes({ :job => :host }).find(params[:id])
155
+
156
+ # Try and delete the schedule
157
+ Minicron::Hub::Schedule.destroy(params[:id])
158
+
159
+ # Get an ssh instance
160
+ ssh = Minicron::Transport::SSH.new(
161
+ :host => schedule.job.host.host,
162
+ :port => schedule.job.host.port,
163
+ :private_key => "~/.ssh/minicron_host_#{schedule.job.host.id}_rsa"
164
+ )
165
+
166
+ # Get an instance of the cron class
167
+ cron = Minicron::Cron.new(ssh)
168
+
169
+ # Delete the schedule from the crontab
170
+ cron.delete_schedule(schedule.job, schedule.formatted)
171
+
172
+ # Tidy up
173
+ ssh.close
174
+
175
+ # This is what ember expects as the response
176
+ status 204
177
+ end
178
+ # TODO: nicer error handling here with proper validation before hand
179
+ rescue Exception => e
180
+ status 422
181
+ { :error => e.message }.to_json
182
+ end
183
+ end
184
+ end
@@ -0,0 +1,5 @@
1
+ class Minicron::Hub::App
2
+ get '/' do
3
+ erb :index, :layout => :'layouts/app'
4
+ end
5
+ end
@@ -0,0 +1,98 @@
1
+ # This file is auto-generated from the current state of the database. Instead
2
+ # of editing this file, please use the migrations feature of Active Record to
3
+ # incrementally modify your database, and then regenerate this schema definition.
4
+ #
5
+ # Note that this schema.rb definition is the authoritative source for your
6
+ # database schema. If you need to create the application database on another
7
+ # system, you should be using db:schema:load, not running all the migrations
8
+ # from scratch. The latter is a flawed and unsustainable approach (the more migrations
9
+ # you'll amass, the slower it'll run and the greater likelihood for issues).
10
+ #
11
+ # It's strongly recommended that you check this file into your version control system.
12
+
13
+ ActiveRecord::Schema.define(version: 0) do
14
+
15
+ create_table "alerts", force: true do |t|
16
+ t.integer "schedule_id"
17
+ t.integer "execution_id"
18
+ t.string "kind", limit: 4, default: "", null: false
19
+ t.datetime "expected_at"
20
+ t.string "medium", limit: 9, default: "", null: false
21
+ t.datetime "sent_at", null: false
22
+ end
23
+
24
+ add_index "alerts", ["execution_id"], name: "execution_id", using: :btree
25
+ add_index "alerts", ["expected_at"], name: "expected_at", using: :btree
26
+ add_index "alerts", ["kind"], name: "kind", using: :btree
27
+ add_index "alerts", ["medium"], name: "medium", using: :btree
28
+ add_index "alerts", ["schedule_id"], name: "schedule_id", using: :btree
29
+
30
+ create_table "executions", force: true do |t|
31
+ t.integer "job_id", null: false
32
+ t.datetime "created_at", null: false
33
+ t.datetime "started_at"
34
+ t.datetime "finished_at"
35
+ t.integer "exit_status"
36
+ end
37
+
38
+ add_index "executions", ["created_at"], name: "created_at", using: :btree
39
+ add_index "executions", ["finished_at"], name: "finished_at", using: :btree
40
+ add_index "executions", ["job_id"], name: "job_id", using: :btree
41
+ add_index "executions", ["started_at"], name: "started_at", using: :btree
42
+
43
+ create_table "hosts", force: true do |t|
44
+ t.string "name"
45
+ t.string "fqdn", default: "", null: false
46
+ t.string "host", default: "", null: false
47
+ t.integer "port", default: 22, null: false
48
+ t.text "public_key"
49
+ t.datetime "created_at", null: false
50
+ t.datetime "updated_at", null: false
51
+ end
52
+
53
+ add_index "hosts", ["fqdn"], name: "hostname", using: :btree
54
+
55
+ create_table "job_execution_outputs", force: true do |t|
56
+ t.integer "execution_id", null: false
57
+ t.integer "seq", null: false
58
+ t.text "output", null: false
59
+ t.datetime "timestamp", null: false
60
+ end
61
+
62
+ add_index "job_execution_outputs", ["execution_id"], name: "execution_id", using: :btree
63
+ add_index "job_execution_outputs", ["seq"], name: "seq", using: :btree
64
+
65
+ create_table "jobs", force: true do |t|
66
+ t.string "job_hash", limit: 32, default: "", null: false
67
+ t.string "name"
68
+ t.text "command", null: false
69
+ t.integer "host_id", null: false
70
+ t.datetime "created_at", null: false
71
+ t.datetime "updated_at", null: false
72
+ end
73
+
74
+ add_index "jobs", ["created_at"], name: "created_at", using: :btree
75
+ add_index "jobs", ["host_id"], name: "host_id", using: :btree
76
+ add_index "jobs", ["job_hash"], name: "job_hash", unique: true, using: :btree
77
+
78
+ create_table "schedules", force: true do |t|
79
+ t.integer "job_id", null: false
80
+ t.string "minute", limit: 179
81
+ t.string "hour", limit: 71
82
+ t.string "day_of_the_month", limit: 92
83
+ t.string "month", limit: 25
84
+ t.string "day_of_the_week", limit: 20
85
+ t.string "special", limit: 9
86
+ t.datetime "created_at", null: false
87
+ t.datetime "updated_at", null: false
88
+ end
89
+
90
+ add_index "schedules", ["day_of_the_month"], name: "day_of_the_month", using: :btree
91
+ add_index "schedules", ["day_of_the_week"], name: "day_of_the_week", using: :btree
92
+ add_index "schedules", ["hour"], name: "hour", using: :btree
93
+ add_index "schedules", ["job_id"], name: "job_id", using: :btree
94
+ add_index "schedules", ["minute"], name: "minute", using: :btree
95
+ add_index "schedules", ["month"], name: "month", using: :btree
96
+ add_index "schedules", ["special"], name: "special", using: :btree
97
+
98
+ end
@@ -0,0 +1,158 @@
1
+ # ************************************************************
2
+ # Sequel Pro SQL dump
3
+ # Version 4096
4
+ #
5
+ # http://www.sequelpro.com/
6
+ # http://code.google.com/p/sequel-pro/
7
+ #
8
+ # Host: 127.0.0.1 (MySQL 5.6.16)
9
+ # Database: minicron
10
+ # Generation Time: 2014-03-29 07:06:21 +0000
11
+ # ************************************************************
12
+
13
+
14
+ /*!40101 SET @OLD_CHARACTER_SET_CLIENT=@@CHARACTER_SET_CLIENT */;
15
+ /*!40101 SET @OLD_CHARACTER_SET_RESULTS=@@CHARACTER_SET_RESULTS */;
16
+ /*!40101 SET @OLD_COLLATION_CONNECTION=@@COLLATION_CONNECTION */;
17
+ /*!40101 SET NAMES utf8 */;
18
+ /*!40014 SET @OLD_FOREIGN_KEY_CHECKS=@@FOREIGN_KEY_CHECKS, FOREIGN_KEY_CHECKS=0 */;
19
+ /*!40101 SET @OLD_SQL_MODE=@@SQL_MODE, SQL_MODE='NO_AUTO_VALUE_ON_ZERO' */;
20
+ /*!40111 SET @OLD_SQL_NOTES=@@SQL_NOTES, SQL_NOTES=0 */;
21
+
22
+
23
+ # Dump of table alerts
24
+ # ------------------------------------------------------------
25
+
26
+ CREATE TABLE `alerts` (
27
+ `id` int(11) unsigned NOT NULL AUTO_INCREMENT,
28
+ `schedule_id` int(11) DEFAULT NULL,
29
+ `execution_id` int(11) DEFAULT NULL,
30
+ `kind` varchar(4) NOT NULL DEFAULT '',
31
+ `expected_at` datetime DEFAULT NULL,
32
+ `medium` varchar(9) NOT NULL DEFAULT '',
33
+ `sent_at` datetime NOT NULL,
34
+ PRIMARY KEY (`id`),
35
+ KEY `schedule_id` (`schedule_id`),
36
+ KEY `execution_id` (`execution_id`),
37
+ KEY `kind` (`kind`),
38
+ KEY `expected_at` (`expected_at`),
39
+ KEY `medium` (`medium`)
40
+ ) ENGINE=InnoDB DEFAULT CHARSET=utf8;
41
+
42
+
43
+
44
+ # Dump of table executions
45
+ # ------------------------------------------------------------
46
+
47
+ CREATE TABLE `executions` (
48
+ `id` int(11) NOT NULL AUTO_INCREMENT,
49
+ `job_id` int(11) NOT NULL,
50
+ `created_at` datetime NOT NULL,
51
+ `started_at` datetime DEFAULT NULL,
52
+ `finished_at` datetime DEFAULT NULL,
53
+ `exit_status` int(11) DEFAULT NULL,
54
+ PRIMARY KEY (`id`),
55
+ KEY `created_at` (`created_at`),
56
+ KEY `finished_at` (`finished_at`),
57
+ KEY `job_id` (`job_id`),
58
+ KEY `started_at` (`started_at`)
59
+ ) ENGINE=InnoDB DEFAULT CHARSET=utf8;
60
+
61
+
62
+
63
+ # Dump of table hosts
64
+ # ------------------------------------------------------------
65
+
66
+ CREATE TABLE `hosts` (
67
+ `id` int(11) NOT NULL AUTO_INCREMENT,
68
+ `name` varchar(255) DEFAULT NULL,
69
+ `fqdn` varchar(255) NOT NULL DEFAULT '',
70
+ `host` varchar(255) NOT NULL DEFAULT '',
71
+ `port` int(11) NOT NULL DEFAULT '22',
72
+ `public_key` text,
73
+ `created_at` datetime NOT NULL,
74
+ `updated_at` datetime NOT NULL,
75
+ PRIMARY KEY (`id`),
76
+ KEY `hostname` (`fqdn`)
77
+ ) ENGINE=InnoDB DEFAULT CHARSET=utf8;
78
+
79
+
80
+
81
+ # Dump of table job_execution_outputs
82
+ # ------------------------------------------------------------
83
+
84
+ CREATE TABLE `job_execution_outputs` (
85
+ `id` int(11) NOT NULL AUTO_INCREMENT,
86
+ `execution_id` int(11) NOT NULL,
87
+ `seq` int(11) NOT NULL,
88
+ `output` text NOT NULL,
89
+ `timestamp` datetime NOT NULL,
90
+ PRIMARY KEY (`id`),
91
+ KEY `execution_id` (`execution_id`),
92
+ KEY `seq` (`seq`)
93
+ ) ENGINE=InnoDB DEFAULT CHARSET=utf8;
94
+
95
+
96
+
97
+ # Dump of table jobs
98
+ # ------------------------------------------------------------
99
+
100
+ CREATE TABLE `jobs` (
101
+ `id` int(11) NOT NULL AUTO_INCREMENT,
102
+ `job_hash` varchar(32) NOT NULL DEFAULT '',
103
+ `name` varchar(255) DEFAULT NULL,
104
+ `command` text NOT NULL,
105
+ `host_id` int(11) NOT NULL,
106
+ `created_at` datetime NOT NULL,
107
+ `updated_at` datetime NOT NULL,
108
+ PRIMARY KEY (`id`),
109
+ UNIQUE KEY `job_hash` (`job_hash`),
110
+ KEY `created_at` (`created_at`),
111
+ KEY `host_id` (`host_id`)
112
+ ) ENGINE=InnoDB DEFAULT CHARSET=utf8;
113
+
114
+
115
+
116
+ # Dump of table schedules
117
+ # ------------------------------------------------------------
118
+
119
+ CREATE TABLE `schedules` (
120
+ `id` int(11) NOT NULL AUTO_INCREMENT,
121
+ `job_id` int(11) NOT NULL,
122
+ `minute` varchar(179) DEFAULT NULL,
123
+ `hour` varchar(71) DEFAULT NULL,
124
+ `day_of_the_month` varchar(92) DEFAULT NULL,
125
+ `month` varchar(25) DEFAULT NULL,
126
+ `day_of_the_week` varchar(20) DEFAULT NULL,
127
+ `special` varchar(9) DEFAULT NULL,
128
+ `created_at` datetime NOT NULL,
129
+ `updated_at` datetime NOT NULL,
130
+ PRIMARY KEY (`id`),
131
+ KEY `day_of_the_month` (`day_of_the_month`),
132
+ KEY `day_of_the_week` (`day_of_the_week`),
133
+ KEY `hour` (`hour`),
134
+ KEY `job_id` (`job_id`),
135
+ KEY `minute` (`minute`),
136
+ KEY `month` (`month`),
137
+ KEY `special` (`special`)
138
+ ) ENGINE=InnoDB DEFAULT CHARSET=utf8;
139
+
140
+
141
+
142
+ # Dump of table schema_migrations
143
+ # ------------------------------------------------------------
144
+
145
+ CREATE TABLE `schema_migrations` (
146
+ `version` varchar(255) NOT NULL,
147
+ UNIQUE KEY `unique_schema_migrations` (`version`)
148
+ ) ENGINE=InnoDB DEFAULT CHARSET=utf8;
149
+
150
+
151
+
152
+
153
+ /*!40111 SET SQL_NOTES=@OLD_SQL_NOTES */;
154
+ /*!40101 SET SQL_MODE=@OLD_SQL_MODE */;
155
+ /*!40014 SET FOREIGN_KEY_CHECKS=@OLD_FOREIGN_KEY_CHECKS */;
156
+ /*!40101 SET CHARACTER_SET_CLIENT=@OLD_CHARACTER_SET_CLIENT */;
157
+ /*!40101 SET CHARACTER_SET_RESULTS=@OLD_CHARACTER_SET_RESULTS */;
158
+ /*!40101 SET COLLATION_CONNECTION=@OLD_COLLATION_CONNECTION */;