sr-scripts 0.1.2 → 0.1.3

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.
@@ -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
@@ -1,5 +1,5 @@
1
1
  module Sr
2
2
  module Scripts
3
- VERSION = "0.1.2"
3
+ VERSION = "0.1.3"
4
4
  end
5
5
  end
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: 31
4
+ hash: 29
5
5
  prerelease: false
6
6
  segments:
7
7
  - 0
8
8
  - 1
9
- - 2
10
- version: 0.1.2
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-27 00:00:00 -04:00
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