warcorrespondent 0.2.6 → 0.2.7
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/.gitignore +1 -0
- data/VERSION +1 -1
- data/bin/warcorrespondent +4 -10
- data/lib/warcorrespondent/logging.rb +20 -0
- data/lib/warcorrespondent/reporter.rb +3 -0
- data/lib/warcorrespondent.rb +12 -3
- metadata +4 -3
data/.gitignore
CHANGED
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.2.
|
1
|
+
0.2.7
|
data/bin/warcorrespondent
CHANGED
@@ -14,14 +14,8 @@ if !WarCorrespondent::config_file
|
|
14
14
|
exit
|
15
15
|
end
|
16
16
|
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
end
|
22
|
-
else
|
23
|
-
puts "Could not find config file although it should have been installed."
|
24
|
-
puts "Maybe you should try it manually, see documentation."
|
25
|
-
puts "I'm bailing out now..."
|
17
|
+
Daemons.run_proc('warcorrespondent', {
|
18
|
+
:dir_mode => :system
|
19
|
+
}) do
|
20
|
+
WarCorrespondent::run
|
26
21
|
end
|
27
|
-
|
@@ -0,0 +1,20 @@
|
|
1
|
+
require 'logger'
|
2
|
+
require 'singleton'
|
3
|
+
module WarCorrespondent
|
4
|
+
class WLogger < Logger
|
5
|
+
include Singleton
|
6
|
+
def initialize
|
7
|
+
super(WarCorrespondent::log_file,10, 10_000_000)
|
8
|
+
end
|
9
|
+
end
|
10
|
+
|
11
|
+
module Logging
|
12
|
+
def self.logger
|
13
|
+
@logger_instance ||= WLogger.instance
|
14
|
+
end
|
15
|
+
def logger
|
16
|
+
self.logger
|
17
|
+
end
|
18
|
+
end
|
19
|
+
|
20
|
+
end
|
@@ -17,6 +17,7 @@ module WarCorrespondent
|
|
17
17
|
|
18
18
|
def update
|
19
19
|
data = instance_eval(&@block)
|
20
|
+
return if data == nil
|
20
21
|
data = [data] if data.class == Hash
|
21
22
|
data.map! do |e|
|
22
23
|
e = {:timestamp => Time.now.to_i}.merge(e)
|
@@ -25,6 +26,8 @@ module WarCorrespondent
|
|
25
26
|
e
|
26
27
|
end
|
27
28
|
WarCorrespondent::update(data)
|
29
|
+
rescue e
|
30
|
+
Logging::logger.warn{e}
|
28
31
|
end
|
29
32
|
|
30
33
|
def run
|
data/lib/warcorrespondent.rb
CHANGED
@@ -1,3 +1,4 @@
|
|
1
|
+
require 'warcorrespondent/logging.rb'
|
1
2
|
require 'warcorrespondent/reporter.rb'
|
2
3
|
require 'warcorrespondent/uplink.rb'
|
3
4
|
require 'warcorrespondent/installer.rb'
|
@@ -6,7 +7,6 @@ require 'systeminformation'
|
|
6
7
|
require 'yaml'
|
7
8
|
|
8
9
|
module WarCorrespondent
|
9
|
-
|
10
10
|
def self.config_base_directory
|
11
11
|
[ '/etc/warcorrespondent', '~/.warcorrespondent'].each do |f|
|
12
12
|
if File.exists?(File.expand_path(f))
|
@@ -23,6 +23,10 @@ module WarCorrespondent
|
|
23
23
|
def self.reporters_directory
|
24
24
|
config_base_directory+"/reporters" if config_base_directory
|
25
25
|
end
|
26
|
+
|
27
|
+
def self.log_file
|
28
|
+
'/var/log/warcorrespondent'
|
29
|
+
end
|
26
30
|
|
27
31
|
def self.setup
|
28
32
|
@@reporters ||= []
|
@@ -32,19 +36,24 @@ module WarCorrespondent
|
|
32
36
|
@@uplink.url = @@config['url']
|
33
37
|
@@uplink.secret = @@config['secret']
|
34
38
|
rescue
|
35
|
-
|
39
|
+
Logging::logger.fatal "Could not load config file #{config_file}. Bailing out."
|
36
40
|
exit
|
37
41
|
end
|
38
42
|
Dir.glob("#{reporters_directory}/*.rb").each do |i|
|
39
43
|
begin
|
44
|
+
Logging::logger.info "including #{i}"
|
40
45
|
require i
|
41
46
|
rescue
|
42
|
-
|
47
|
+
Logging::logger.fatal "Parse error in #{i}. Bailing out."
|
43
48
|
end
|
44
49
|
end
|
45
50
|
end
|
46
51
|
|
47
52
|
def self.run
|
53
|
+
pp self.methods
|
54
|
+
Logging::logger.info{'warcorrespondent starting up'}
|
55
|
+
setup
|
56
|
+
Logging::logger.debug "config loaded..."
|
48
57
|
Thread.new do
|
49
58
|
@@uplink.run
|
50
59
|
end
|
metadata
CHANGED
@@ -5,8 +5,8 @@ version: !ruby/object:Gem::Version
|
|
5
5
|
segments:
|
6
6
|
- 0
|
7
7
|
- 2
|
8
|
-
-
|
9
|
-
version: 0.2.
|
8
|
+
- 7
|
9
|
+
version: 0.2.7
|
10
10
|
platform: ruby
|
11
11
|
authors:
|
12
12
|
- Stefan Maier
|
@@ -14,7 +14,7 @@ autorequire:
|
|
14
14
|
bindir: bin
|
15
15
|
cert_chain: []
|
16
16
|
|
17
|
-
date: 2010-06-
|
17
|
+
date: 2010-06-21 00:00:00 +02:00
|
18
18
|
default_executable: warcorrespondent
|
19
19
|
dependencies:
|
20
20
|
- !ruby/object:Gem::Dependency
|
@@ -76,6 +76,7 @@ files:
|
|
76
76
|
- dev
|
77
77
|
- lib/warcorrespondent.rb
|
78
78
|
- lib/warcorrespondent/installer.rb
|
79
|
+
- lib/warcorrespondent/logging.rb
|
79
80
|
- lib/warcorrespondent/reporter.rb
|
80
81
|
- lib/warcorrespondent/reporters/cpu.rb
|
81
82
|
- lib/warcorrespondent/reporters/loadavg.rb
|