sr-scripts 0.1.2 → 0.1.3
Sign up to get free protection for your applications and to get access to all the features.
- data/bin/sr-log-monitor +31 -0
- data/lib/sr-scripts/version.rb +1 -1
- metadata +6 -4
data/bin/sr-log-monitor
ADDED
@@ -0,0 +1,31 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
|
3
|
+
require 'yaml'
|
4
|
+
|
5
|
+
files = ARGV[0].split(',')
|
6
|
+
|
7
|
+
position_file = "/var/log/sr-log-monitor.pos"
|
8
|
+
|
9
|
+
File.open(position_file, 'w') { } unless File.exists?(position_file)
|
10
|
+
|
11
|
+
positions = YAML.load_file(position_file) || Hash.new
|
12
|
+
|
13
|
+
file_changes = false
|
14
|
+
files.each do |file|
|
15
|
+
p "File Not Found: #{file}" && break unless File.exists?(file)
|
16
|
+
last_position = positions[file] || 0
|
17
|
+
if last_position != File.size?(file)
|
18
|
+
f = File.open(file, 'rb')
|
19
|
+
f.seek last_position
|
20
|
+
p "#### #{file} #####"
|
21
|
+
p f.read
|
22
|
+
file_changes = true
|
23
|
+
end
|
24
|
+
positions[file] = File.size?(file)
|
25
|
+
end
|
26
|
+
|
27
|
+
File.open(position_file, 'w') do |f|
|
28
|
+
f.write positions.to_yaml
|
29
|
+
end
|
30
|
+
|
31
|
+
exit(1) if file_changes # exit with error code 1 if there are changes
|
data/lib/sr-scripts/version.rb
CHANGED
metadata
CHANGED
@@ -1,13 +1,13 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: sr-scripts
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
hash:
|
4
|
+
hash: 29
|
5
5
|
prerelease: false
|
6
6
|
segments:
|
7
7
|
- 0
|
8
8
|
- 1
|
9
|
-
-
|
10
|
-
version: 0.1.
|
9
|
+
- 3
|
10
|
+
version: 0.1.3
|
11
11
|
platform: ruby
|
12
12
|
authors:
|
13
13
|
- Davy Campano
|
@@ -15,7 +15,7 @@ autorequire:
|
|
15
15
|
bindir: bin
|
16
16
|
cert_chain: []
|
17
17
|
|
18
|
-
date: 2011-03
|
18
|
+
date: 2011-04-03 00:00:00 -04:00
|
19
19
|
default_executable:
|
20
20
|
dependencies: []
|
21
21
|
|
@@ -26,6 +26,7 @@ executables:
|
|
26
26
|
- sr-backup-mysql
|
27
27
|
- sr-check-slave
|
28
28
|
- sr-ec2-consistent-snapshot
|
29
|
+
- sr-log-monitor
|
29
30
|
- sr-promote-to-master
|
30
31
|
- sr-send-email
|
31
32
|
- sr-start-slave
|
@@ -42,6 +43,7 @@ files:
|
|
42
43
|
- bin/sr-backup-mysql
|
43
44
|
- bin/sr-check-slave
|
44
45
|
- bin/sr-ec2-consistent-snapshot
|
46
|
+
- bin/sr-log-monitor
|
45
47
|
- bin/sr-promote-to-master
|
46
48
|
- bin/sr-send-email
|
47
49
|
- bin/sr-start-slave
|