warcorrespondent 0.2.1 → 0.2.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.
- data/.gitignore +1 -0
- data/VERSION +1 -1
- data/bin/warcorrespondent +14 -3
- data/dev +0 -0
- data/lib/warcorrespondent/installer.rb +74 -0
- data/lib/warcorrespondent/reporter.rb +2 -2
- data/lib/warcorrespondent/reporters/loadavg.rb +5 -5
- data/lib/warcorrespondent.rb +26 -6
- metadata +11 -5
- data/warcorrespondent.gemspec +0 -64
data/.gitignore
CHANGED
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.2.
|
1
|
+
0.2.3
|
data/bin/warcorrespondent
CHANGED
@@ -9,8 +9,19 @@ end
|
|
9
9
|
|
10
10
|
require 'daemons'
|
11
11
|
|
12
|
-
|
13
|
-
WarCorrespondent::
|
14
|
-
|
12
|
+
if !WarCorrespondent::config_file
|
13
|
+
WarCorrespondent::Installer::install
|
14
|
+
exit
|
15
|
+
end
|
16
|
+
|
17
|
+
if WarCorrespondent::config_file
|
18
|
+
Daemons.run_proc('warcorrespondent.rb') do
|
19
|
+
WarCorrespondent::setup
|
20
|
+
WarCorrespondent::run
|
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..."
|
15
26
|
end
|
16
27
|
|
data/dev
ADDED
File without changes
|
@@ -0,0 +1,74 @@
|
|
1
|
+
module WarCorrespondent
|
2
|
+
module Installer
|
3
|
+
|
4
|
+
TEXT_INTRO = <<-EOT
|
5
|
+
warcorrespondent could not find your config file and will now guide you
|
6
|
+
through the setup process.
|
7
|
+
|
8
|
+
Do you want to install system-wide (1) or in your home directory(2)? [1]
|
9
|
+
EOT
|
10
|
+
|
11
|
+
TEXT_TARGET = <<-EOT
|
12
|
+
Where do you want warcorrespondent to report to?
|
13
|
+
If you want to report to warroom, just press enter [http://warroom.tliff.de/reports]
|
14
|
+
EOT
|
15
|
+
|
16
|
+
TEXT_SECRET = <<-EOT
|
17
|
+
What is the secret this warcorrespondent instance will
|
18
|
+
use to authenticate to warroom?
|
19
|
+
EOT
|
20
|
+
|
21
|
+
TEXT_BASIC_SETUP = <<-EOT
|
22
|
+
warcorrespondent can now set up basic reporting for this host.
|
23
|
+
Would you like to have that set up for you(y/n)[y]?
|
24
|
+
EOT
|
25
|
+
|
26
|
+
TEXT_TEMPLATE = <<-EOT
|
27
|
+
WarCorrespondent::Reporters::CPU.new(:identifier => 'hosts:@@HOST@@:stats')
|
28
|
+
WarCorrespondent::Reporters::LoadAvg.new(:identifier => 'hosts::@@HOST@@:stats')
|
29
|
+
WarCorrespondent::Reporters::Memory.new(:identifier => 'hosts::@@HOST@@:stats')
|
30
|
+
WarCorrespondent::Reporters::Net.new(:identifier => 'hosts::@@HOST@@:stats')
|
31
|
+
EOT
|
32
|
+
|
33
|
+
TEXT_DONE = <<-EOT
|
34
|
+
Setup is now complete.
|
35
|
+
EOT
|
36
|
+
|
37
|
+
|
38
|
+
def self.install
|
39
|
+
puts TEXT_INTRO
|
40
|
+
basepath = nil
|
41
|
+
while (cmd = gets.strip) && !['1', '2', ''].member?(cmd) do end
|
42
|
+
if cmd == '1' || cmd == '' then
|
43
|
+
basepath = '/etc/warcorrespondent'
|
44
|
+
elsif cmd == '2'
|
45
|
+
basepath = File.expand_path('~/.warcorrespondent')
|
46
|
+
end
|
47
|
+
#create the directory if necessary
|
48
|
+
if !File.exists?(basepath) then Dir.mkdir(basepath) end
|
49
|
+
if !File.exists?(basepath+"/reporters") then Dir.mkdir(basepath+"/reporters") end
|
50
|
+
config = {}
|
51
|
+
puts TEXT_TARGET
|
52
|
+
url = gets.strip
|
53
|
+
config['url'] = url.empty? ? "http://warroom.tliff.de/reports" : url
|
54
|
+
puts TEXT_SECRET
|
55
|
+
while (config['secret'] = gets.strip) && config['secret'].empty? do end
|
56
|
+
File.open( "#{basepath}/warcorrespondent.yml", 'w+' ) do |f|
|
57
|
+
YAML.dump(config, f)
|
58
|
+
end
|
59
|
+
|
60
|
+
puts TEXT_BASIC_SETUP
|
61
|
+
while (cmd = gets.strip) && !['y', 'n', ''].member?(cmd) do end
|
62
|
+
if cmd == 'y' || cmd == '' then
|
63
|
+
hostname = `hostname`.strip
|
64
|
+
|
65
|
+
File.open("#{basepath}/reporters/basic.rb", "w+") do |f|
|
66
|
+
f.write(TEXT_TEMPLATE.gsub(/@@HOST@@/, hostname))
|
67
|
+
end
|
68
|
+
end
|
69
|
+
|
70
|
+
puts TEXT_DONE
|
71
|
+
|
72
|
+
end
|
73
|
+
end
|
74
|
+
end
|
@@ -5,11 +5,11 @@ module WarCorrespondent
|
|
5
5
|
@block = Proc.new do
|
6
6
|
load = SystemInformation::load
|
7
7
|
[
|
8
|
-
{:identifier => "load:1", :
|
9
|
-
{:identifier => "load:5", :
|
10
|
-
{:identifier => "load:15", :
|
11
|
-
{:identifier => "processes:running", :
|
12
|
-
{:identifier => "processes:total", :
|
8
|
+
{:identifier => "load:1", :value => load[:load_1]},
|
9
|
+
{:identifier => "load:5", :value => load[:load_5]},
|
10
|
+
{:identifier => "load:15", :value => load[:load_15]},
|
11
|
+
{:identifier => "processes:running", :value => load[:procs_running]},
|
12
|
+
{:identifier => "processes:total", :value => load[:procs_total]}
|
13
13
|
]
|
14
14
|
end
|
15
15
|
super(args)
|
data/lib/warcorrespondent.rb
CHANGED
@@ -1,26 +1,46 @@
|
|
1
1
|
require 'warcorrespondent/reporter.rb'
|
2
2
|
require 'warcorrespondent/uplink.rb'
|
3
|
+
require 'warcorrespondent/installer.rb'
|
3
4
|
require 'json'
|
4
5
|
require 'systeminformation'
|
5
6
|
require 'yaml'
|
6
7
|
|
7
8
|
module WarCorrespondent
|
8
|
-
|
9
|
-
|
9
|
+
|
10
|
+
def self.config_base_directory
|
11
|
+
[ '/etc/warcorrespondent', '~/.warcorrespondent'].each do |f|
|
12
|
+
if File.exists?(File.expand_path(f))
|
13
|
+
return File.expand_path(f)
|
14
|
+
end
|
15
|
+
end
|
16
|
+
nil
|
17
|
+
end
|
18
|
+
|
19
|
+
def self.config_file
|
20
|
+
config_base_directory+"/warcorrespondent.yml" if config_base_directory
|
21
|
+
end
|
10
22
|
|
23
|
+
def self.reporters_directory
|
24
|
+
config_base_directory+"/reporters" if config_base_directory
|
25
|
+
end
|
26
|
+
|
11
27
|
def self.setup
|
12
28
|
@@reporters ||= []
|
13
29
|
@@uplink = Uplink.new
|
14
30
|
begin
|
15
|
-
@@config = YAML.load_file(
|
31
|
+
@@config = YAML.load_file(config_file)
|
16
32
|
@@uplink.url = @@config['url']
|
17
33
|
@@uplink.secret = @@config['secret']
|
18
34
|
rescue
|
19
|
-
raise "Could not load config file #{
|
35
|
+
raise "Could not load config file #{config_file}"
|
20
36
|
exit
|
21
37
|
end
|
22
|
-
Dir.glob("#{
|
23
|
-
|
38
|
+
Dir.glob("#{reporters_directory}/*.rb").each do |i|
|
39
|
+
begin
|
40
|
+
require i
|
41
|
+
rescue
|
42
|
+
puts "Parse error in #{i}. Bailing out."
|
43
|
+
end
|
24
44
|
end
|
25
45
|
end
|
26
46
|
|
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
|
+
- 3
|
9
|
+
version: 0.2.3
|
10
10
|
platform: ruby
|
11
11
|
authors:
|
12
12
|
- Stefan Maier
|
@@ -14,13 +14,14 @@ autorequire:
|
|
14
14
|
bindir: bin
|
15
15
|
cert_chain: []
|
16
16
|
|
17
|
-
date: 2010-06-
|
17
|
+
date: 2010-06-14 00:00:00 +02:00
|
18
18
|
default_executable: warcorrespondent
|
19
19
|
dependencies:
|
20
20
|
- !ruby/object:Gem::Dependency
|
21
21
|
name: json
|
22
22
|
prerelease: false
|
23
23
|
requirement: &id001 !ruby/object:Gem::Requirement
|
24
|
+
none: false
|
24
25
|
requirements:
|
25
26
|
- - ">="
|
26
27
|
- !ruby/object:Gem::Version
|
@@ -33,6 +34,7 @@ dependencies:
|
|
33
34
|
name: daemons
|
34
35
|
prerelease: false
|
35
36
|
requirement: &id002 !ruby/object:Gem::Requirement
|
37
|
+
none: false
|
36
38
|
requirements:
|
37
39
|
- - ">="
|
38
40
|
- !ruby/object:Gem::Version
|
@@ -45,6 +47,7 @@ dependencies:
|
|
45
47
|
name: systeminformation
|
46
48
|
prerelease: false
|
47
49
|
requirement: &id003 !ruby/object:Gem::Requirement
|
50
|
+
none: false
|
48
51
|
requirements:
|
49
52
|
- - ">="
|
50
53
|
- !ruby/object:Gem::Version
|
@@ -70,7 +73,9 @@ files:
|
|
70
73
|
- Rakefile
|
71
74
|
- VERSION
|
72
75
|
- bin/warcorrespondent
|
76
|
+
- dev
|
73
77
|
- lib/warcorrespondent.rb
|
78
|
+
- lib/warcorrespondent/installer.rb
|
74
79
|
- lib/warcorrespondent/reporter.rb
|
75
80
|
- lib/warcorrespondent/reporters/cpu.rb
|
76
81
|
- lib/warcorrespondent/reporters/loadavg.rb
|
@@ -78,7 +83,6 @@ files:
|
|
78
83
|
- lib/warcorrespondent/reporters/net.rb
|
79
84
|
- lib/warcorrespondent/reporters/users.rb
|
80
85
|
- lib/warcorrespondent/uplink.rb
|
81
|
-
- warcorrespondent.gemspec
|
82
86
|
has_rdoc: true
|
83
87
|
homepage: http://github.com/tliff/warcorrespondent
|
84
88
|
licenses: []
|
@@ -89,6 +93,7 @@ rdoc_options:
|
|
89
93
|
require_paths:
|
90
94
|
- lib
|
91
95
|
required_ruby_version: !ruby/object:Gem::Requirement
|
96
|
+
none: false
|
92
97
|
requirements:
|
93
98
|
- - ">="
|
94
99
|
- !ruby/object:Gem::Version
|
@@ -96,6 +101,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
96
101
|
- 0
|
97
102
|
version: "0"
|
98
103
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
104
|
+
none: false
|
99
105
|
requirements:
|
100
106
|
- - ">="
|
101
107
|
- !ruby/object:Gem::Version
|
@@ -105,7 +111,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
105
111
|
requirements: []
|
106
112
|
|
107
113
|
rubyforge_project:
|
108
|
-
rubygems_version: 1.3.
|
114
|
+
rubygems_version: 1.3.7
|
109
115
|
signing_key:
|
110
116
|
specification_version: 3
|
111
117
|
summary: warcorrespondent reports to the warroom.
|
data/warcorrespondent.gemspec
DELETED
@@ -1,64 +0,0 @@
|
|
1
|
-
# Generated by jeweler
|
2
|
-
# DO NOT EDIT THIS FILE DIRECTLY
|
3
|
-
# Instead, edit Jeweler::Tasks in Rakefile, and run the gemspec command
|
4
|
-
# -*- encoding: utf-8 -*-
|
5
|
-
|
6
|
-
Gem::Specification.new do |s|
|
7
|
-
s.name = %q{warcorrespondent}
|
8
|
-
s.version = "0.2.1"
|
9
|
-
|
10
|
-
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
|
11
|
-
s.authors = ["Stefan Maier"]
|
12
|
-
s.date = %q{2010-06-10}
|
13
|
-
s.default_executable = %q{warcorrespondent}
|
14
|
-
s.description = %q{warcorrespondent collects data and reports it back to warroom.}
|
15
|
-
s.email = %q{stefanmaier@gmail.com}
|
16
|
-
s.executables = ["warcorrespondent"]
|
17
|
-
s.extra_rdoc_files = [
|
18
|
-
"LICENSE",
|
19
|
-
"README.rdoc"
|
20
|
-
]
|
21
|
-
s.files = [
|
22
|
-
".document",
|
23
|
-
".gitignore",
|
24
|
-
"LICENSE",
|
25
|
-
"README.rdoc",
|
26
|
-
"Rakefile",
|
27
|
-
"VERSION",
|
28
|
-
"bin/warcorrespondent",
|
29
|
-
"lib/warcorrespondent.rb",
|
30
|
-
"lib/warcorrespondent/reporter.rb",
|
31
|
-
"lib/warcorrespondent/reporters/cpu.rb",
|
32
|
-
"lib/warcorrespondent/reporters/loadavg.rb",
|
33
|
-
"lib/warcorrespondent/reporters/memory.rb",
|
34
|
-
"lib/warcorrespondent/reporters/net.rb",
|
35
|
-
"lib/warcorrespondent/reporters/users.rb",
|
36
|
-
"lib/warcorrespondent/uplink.rb",
|
37
|
-
"warcorrespondent.gemspec"
|
38
|
-
]
|
39
|
-
s.homepage = %q{http://github.com/tliff/warcorrespondent}
|
40
|
-
s.rdoc_options = ["--charset=UTF-8"]
|
41
|
-
s.require_paths = ["lib"]
|
42
|
-
s.rubygems_version = %q{1.3.6}
|
43
|
-
s.summary = %q{warcorrespondent reports to the warroom.}
|
44
|
-
|
45
|
-
if s.respond_to? :specification_version then
|
46
|
-
current_version = Gem::Specification::CURRENT_SPECIFICATION_VERSION
|
47
|
-
s.specification_version = 3
|
48
|
-
|
49
|
-
if Gem::Version.new(Gem::RubyGemsVersion) >= Gem::Version.new('1.2.0') then
|
50
|
-
s.add_runtime_dependency(%q<json>, [">= 0"])
|
51
|
-
s.add_runtime_dependency(%q<daemons>, [">= 0"])
|
52
|
-
s.add_runtime_dependency(%q<systeminformation>, [">= 0"])
|
53
|
-
else
|
54
|
-
s.add_dependency(%q<json>, [">= 0"])
|
55
|
-
s.add_dependency(%q<daemons>, [">= 0"])
|
56
|
-
s.add_dependency(%q<systeminformation>, [">= 0"])
|
57
|
-
end
|
58
|
-
else
|
59
|
-
s.add_dependency(%q<json>, [">= 0"])
|
60
|
-
s.add_dependency(%q<daemons>, [">= 0"])
|
61
|
-
s.add_dependency(%q<systeminformation>, [">= 0"])
|
62
|
-
end
|
63
|
-
end
|
64
|
-
|