reptile 0.1.0 → 0.1.1

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/Gemfile.lock CHANGED
@@ -4,7 +4,6 @@ PATH
4
4
  reptile (0.1.0)
5
5
  activerecord
6
6
  mixlib-log (>= 1.2.0)
7
- tlsmail (>= 0.0.1)
8
7
 
9
8
  GEM
10
9
  remote: http://rubygems.org/
@@ -23,7 +22,6 @@ GEM
23
22
  builder (2.1.2)
24
23
  i18n (0.5.0)
25
24
  mixlib-log (1.2.0)
26
- tlsmail (0.0.1)
27
25
  tzinfo (0.3.24)
28
26
 
29
27
  PLATFORMS
@@ -34,4 +32,3 @@ DEPENDENCIES
34
32
  bundler (>= 1.0.0)
35
33
  mixlib-log (>= 1.2.0)
36
34
  reptile!
37
- tlsmail (>= 0.0.1)
data/README.rdoc CHANGED
@@ -1,10 +1,15 @@
1
1
  = reptile
2
2
 
3
- Reptile is an easy to use utility that will monitor your MySQL replication, so you can forget about it and focus on the good stuff. It provides a utility for generate replication reports.
3
+ Reptile is an easy to use utility that will monitor your MySQL replication, so you can forget about it and focus on the good stuff.
4
4
 
5
5
  == STATUS DISCLAIMER:
6
6
 
7
- I'm not sure if anybody uses this. I PROBABLY WON'T fix a patch you submit. This, as it is, has been used successfully in production environments. It's a good idea, but might not work for your particular case, and I make no guarantee that it will. I certainly hope it does. Drop me a line, and I'll answer any questions you have. NCS 8/2010
7
+ I'm not sure if anybody else uses this. I use it to monitor production MySQL database replication.
8
+
9
+ I am planning to simplify this significantly, but I won't likely get to them soon.
10
+ I MIGHT fix a patch you submit. Drop me a line, and I'll answer any questions you have.
11
+
12
+ NCS 3/2011
8
13
 
9
14
  The --diff check can cause problems on large tables, as it does a lot of SELECT COUNT(*) FROM..'s .
10
15
 
@@ -28,7 +33,7 @@ Put a config file at /etc/reptile.yml, /etc/reptile/reptile.yml, ./reptile.yml,
28
33
  --start-slaves Starts all slaves
29
34
  -l, --log-level [LEVEL] Specify log level (debug,info,warn,error,fatal)
30
35
 
31
- [nick@s34 ~]$ replication_status -s
36
+ [nick@s34 ~]$ replication_status --status
32
37
  * a_database slave is up and running
33
38
  * b_database slave is up and running
34
39
  * c_database slave is up and running
@@ -56,13 +56,9 @@ module Reptile
56
56
  return nil;
57
57
  end
58
58
 
59
- # Not sure why we have both, (one is easier to read?).
60
- # Use one or the other to calculate delay...
61
59
  delay = (Time.now - Time.at(heartbeat.unix_time)).round
62
- #delay = (Time.now - heartbeat.db_time)
63
60
 
64
- Log.debug "Read heartbeat from #{name} at #{Time.at(heartbeat.unix_time)}."
65
- Log.info "The delay is #{strfdelay(delay)}"
61
+ Log.info "The slave delay for '#{name}' is #{strfdelay(delay)}"
66
62
 
67
63
  delay
68
64
  end
@@ -1,27 +1,25 @@
1
- require 'tlsmail'
2
-
3
1
  module Reptile
4
- # The Status class is responsible for asking a slave database for its status is,
2
+ # The Status class is responsible for asking a slave database for its status is,
5
3
  # parsing the result, and returning the appropiate status code.
6
4
  #
7
5
  # This class also allows you to convert a status code to a friendly message the corresponds to that status.
8
-
6
+
9
7
  class Status
10
8
 
11
9
  @@errors = []
12
-
10
+
13
11
  # Status code indicating the SQL thread has stopped running.
14
12
  SQL_THREAD_DOWN = 'sql_thread_down'
15
-
13
+
16
14
  # Status code indicating the IO thread has stopped running.
17
15
  IO_THREAD_DOWN = 'io_thread_down'
18
-
16
+
19
17
  # Status code indicating that the slave has stopped replicating.
20
18
  SLAVE_DOWN = 'slave_down'
21
-
19
+
22
20
  # Status code indicating that the slave is up and running.
23
21
  RUNNING = 'running'
24
-
22
+
25
23
  # Set the user settings for a user that has global SELECT privilidgess
26
24
  def self.user=(user_settings)
27
25
  @user = user_settings
@@ -31,14 +29,14 @@ module Reptile
31
29
  def self.user
32
30
  @user ||= {}
33
31
  end
34
-
32
+
35
33
  # Checks the value of the MySQL command "SHOW SLAVE STATUS".
36
34
  # Returns a status code.
37
35
  def self.check_slave_status(name, configs)
38
36
  # TODO: Do this in Databases
39
37
  configs.delete("port")
40
38
  Databases.connect(configs.merge(user).merge('database' => 'information_schema')).execute('SHOW SLAVE STATUS').each_hash do |hash|
41
-
39
+
42
40
  if hash['Slave_SQL_Running'] == "No"
43
41
  return SQL_THREAD_DOWN
44
42
  elsif hash['Slave_IO_Running'] == "No"
@@ -49,8 +47,8 @@ module Reptile
49
47
  return RUNNING
50
48
  end
51
49
  end
52
- end
53
-
50
+ end
51
+
54
52
  # Returns a nice error message for the given status code
55
53
  def self.get_error_message(status)
56
54
  case status
@@ -64,7 +62,7 @@ module Reptile
64
62
  raise "Invalid status code. Must be one of #{status_codes.keys.inspect}"
65
63
  end
66
64
  end
67
-
65
+
68
66
  # A hash containing the names of the constants that represent status codes,
69
67
  # and the strings they represent
70
68
  def self.status_codes
@@ -1,3 +1,3 @@
1
1
  module Reptile
2
- VERSION = "0.1.0"
2
+ VERSION = "0.1.1"
3
3
  end
data/lib/reptile.rb CHANGED
@@ -3,8 +3,6 @@ $:.unshift(File.dirname(__FILE__)) unless $:.include?(File.dirname(__FILE__)) ||
3
3
  require 'ostruct'
4
4
  require 'openssl'
5
5
  require 'rubygems'
6
- require 'tlsmail'
7
- require 'net/smtp'
8
6
 
9
7
  require 'reptile/log'
10
8
  require 'reptile/heartbeat'
File without changes
metadata CHANGED
@@ -1,13 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: reptile
3
3
  version: !ruby/object:Gem::Version
4
- hash: 27
4
+ hash: 25
5
5
  prerelease: false
6
6
  segments:
7
7
  - 0
8
8
  - 1
9
- - 0
10
- version: 0.1.0
9
+ - 1
10
+ version: 0.1.1
11
11
  platform: ruby
12
12
  authors:
13
13
  - nick.stielau@gmail.com
@@ -90,8 +90,8 @@ files:
90
90
  - lib/reptile/status.rb
91
91
  - lib/reptile/users.rb
92
92
  - lib/reptile/version.rb
93
- - replication.yml.sample
94
93
  - reptile.gemspec
94
+ - reptile.yml.sample
95
95
  - reptile_setup.sql
96
96
  - script/console
97
97
  - script/destroy