jah 0.0.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/.document +5 -0
- data/.gitignore +7 -0
- data/LICENSE +20 -0
- data/README.md +115 -0
- data/Rakefile +75 -0
- data/VERSION +1 -0
- data/bin/jah +9 -0
- data/jah.gemspec +89 -0
- data/lib/jah/agent.rb +128 -0
- data/lib/jah/agents/dump.rb +5 -0
- data/lib/jah/agents/post.rb +18 -0
- data/lib/jah/agents/xmpp.rb +194 -0
- data/lib/jah/cli.rb +124 -0
- data/lib/jah/collector.rb +12 -0
- data/lib/jah/collectors/cpu.rb +35 -0
- data/lib/jah/collectors/disk.rb +14 -0
- data/lib/jah/collectors/mem.rb +51 -0
- data/lib/jah/collectors/net.rb +27 -0
- data/lib/jah/collectors/prok.rb +88 -0
- data/lib/jah/collectors/services.rb +13 -0
- data/lib/jah/collectors/who.rb +20 -0
- data/lib/jah/command.rb +23 -0
- data/lib/jah/commands/admin.rb +40 -0
- data/lib/jah/commands/extra.rb +14 -0
- data/lib/jah/commands/pub.rb +34 -0
- data/lib/jah/commands/status.rb +61 -0
- data/lib/jah/god.rb +24 -0
- data/lib/jah/install.rb +336 -0
- data/lib/jah.rb +26 -0
- data/lib/jah.yaml.template +26 -0
- data/lib/locales/en_us.yml +2 -0
- data/lib/locales/pt_br.yml +2 -0
- data/lib/locales/pt_br_gostosa.yml +10 -0
- data/lib/locales/pt_br_mano.yml +10 -0
- data/lib/locales/pt_br_mineiro.yml +10 -0
- data/spec/console +12 -0
- data/spec/jah_spec.rb +7 -0
- data/spec/spec_helper.rb +9 -0
- metadata +123 -0
data/lib/jah/install.rb
ADDED
@@ -0,0 +1,336 @@
|
|
1
|
+
#
|
2
|
+
# Jah Install Wizard
|
3
|
+
#
|
4
|
+
# TODO: i18n and/to remove <<FOO FOO from ALL THIS !!!!!!!
|
5
|
+
#
|
6
|
+
module Jah
|
7
|
+
class Install < Cli
|
8
|
+
|
9
|
+
#
|
10
|
+
# MODE
|
11
|
+
#
|
12
|
+
#
|
13
|
+
def get_mode
|
14
|
+
puts <<-END_MODE.gsub(/^ {8}/, "")
|
15
|
+
=== Jah Gem Install ===
|
16
|
+
|
17
|
+
Hello, thanks for trying Jah!
|
18
|
+
|
19
|
+
Looks like #{Jah.hostname} doesn`t have a config file, shall we create one?
|
20
|
+
|
21
|
+
Jah needs to know how it will run: xmpp, post or dump.
|
22
|
+
|
23
|
+
END_MODE
|
24
|
+
mode = nil
|
25
|
+
print "Enter mode: "
|
26
|
+
while mode.nil?
|
27
|
+
mode = case gets.to_s.strip
|
28
|
+
when /xmpp/i then :xmpp
|
29
|
+
when /post/i then :post
|
30
|
+
when /dumpp/i then :dump
|
31
|
+
else print "Valid: xmpp, post or dump: "; nil
|
32
|
+
end
|
33
|
+
end
|
34
|
+
@config[:mode] = mode
|
35
|
+
end
|
36
|
+
|
37
|
+
#
|
38
|
+
# JID
|
39
|
+
#
|
40
|
+
#
|
41
|
+
def get_jid
|
42
|
+
|
43
|
+
puts <<-END_INTRO.gsub(/^ {8}/, "")
|
44
|
+
|
45
|
+
== XMPP JID ==
|
46
|
+
|
47
|
+
Good choice! Now we need this server JID.
|
48
|
+
Tip: You can create it on God Web.
|
49
|
+
It looks like:
|
50
|
+
|
51
|
+
niceserver@cooldomain.com
|
52
|
+
|
53
|
+
END_INTRO
|
54
|
+
print "Enter the Client JID: "
|
55
|
+
@config[:jid] = gets.to_s.strip
|
56
|
+
end
|
57
|
+
|
58
|
+
#
|
59
|
+
# PASS
|
60
|
+
#
|
61
|
+
#
|
62
|
+
def get_pass
|
63
|
+
puts <<-END_INTRO.gsub(/^ {8}/, "")
|
64
|
+
|
65
|
+
== XMPP Password ==
|
66
|
+
|
67
|
+
END_INTRO
|
68
|
+
print "Your XMPP client password: "
|
69
|
+
@config[:key] = gets.to_s.strip
|
70
|
+
end
|
71
|
+
|
72
|
+
#
|
73
|
+
# KEY
|
74
|
+
#
|
75
|
+
#
|
76
|
+
def get_key
|
77
|
+
puts <<-END_INTRO.gsub(/^ {8}/, "")
|
78
|
+
|
79
|
+
== Jah Web Key ==
|
80
|
+
|
81
|
+
You need the Key displayed in the server page.
|
82
|
+
It looks like:
|
83
|
+
|
84
|
+
5e89c3c3035c8c1ee1b52dce81eee6
|
85
|
+
|
86
|
+
END_INTRO
|
87
|
+
print "Enter the Client Key: "
|
88
|
+
@config[:key] = gets.to_s.strip
|
89
|
+
end
|
90
|
+
|
91
|
+
#
|
92
|
+
# HOST
|
93
|
+
#
|
94
|
+
#
|
95
|
+
def get_host
|
96
|
+
puts <<-END_INTRO.gsub(/^ {8}/, "")
|
97
|
+
|
98
|
+
== Domain ==
|
99
|
+
|
100
|
+
Enter the domain Jah will use for XMPP connect and conference search.
|
101
|
+
|
102
|
+
END_INTRO
|
103
|
+
|
104
|
+
d = @config[:jid].split("@")[1]
|
105
|
+
print "Your host address"
|
106
|
+
print d ? " (#{d}): " : ": "
|
107
|
+
@config[:host] = gets.strip
|
108
|
+
@config[:host] = d if @config[:host] == ""
|
109
|
+
end
|
110
|
+
|
111
|
+
#
|
112
|
+
# ACL
|
113
|
+
#
|
114
|
+
#
|
115
|
+
def get_acl
|
116
|
+
puts <<-END_INTRO.gsub(/^ {8}/, "")
|
117
|
+
|
118
|
+
== Access Control List ==
|
119
|
+
|
120
|
+
Please enter the JIDs you want Jah to talk to.
|
121
|
+
Use commas to separate multiple ones.
|
122
|
+
|
123
|
+
END_INTRO
|
124
|
+
print "ACL: "
|
125
|
+
@config[:acl] = gets.strip
|
126
|
+
end
|
127
|
+
|
128
|
+
#
|
129
|
+
# GROUPS
|
130
|
+
#
|
131
|
+
#
|
132
|
+
def get_groups
|
133
|
+
puts <<-END_INTRO.gsub(/^ {8}/, "")
|
134
|
+
|
135
|
+
== Groups (Chats) ==
|
136
|
+
|
137
|
+
Please enter the conference room(s) Jah should log in.
|
138
|
+
Use commas to separate multiple ones.
|
139
|
+
|
140
|
+
END_INTRO
|
141
|
+
print "Groups: "
|
142
|
+
@config[:groups] = gets.strip
|
143
|
+
end
|
144
|
+
|
145
|
+
|
146
|
+
#
|
147
|
+
# GOD
|
148
|
+
#
|
149
|
+
#
|
150
|
+
def use_god?
|
151
|
+
puts <<-END_INTRO.gsub(/^ {8}/, "")
|
152
|
+
|
153
|
+
== God Config ==
|
154
|
+
|
155
|
+
END_INTRO
|
156
|
+
print "Use God? (Y/n): "
|
157
|
+
@config[:god] = gets.to_s.strip == "n" ? false : true
|
158
|
+
end
|
159
|
+
|
160
|
+
#
|
161
|
+
# EVAL
|
162
|
+
#
|
163
|
+
#
|
164
|
+
def use_eval?
|
165
|
+
puts <<-END_INTRO.gsub(/^ {8}/, "")
|
166
|
+
|
167
|
+
== Eval Ruby ==
|
168
|
+
|
169
|
+
Do you want to eval ruby code, using an ! in front of a command?
|
170
|
+
|
171
|
+
END_INTRO
|
172
|
+
print "Use Eval? (Y/n): "
|
173
|
+
@config[:eval] = gets.to_s.strip == "n" ? false : true
|
174
|
+
end
|
175
|
+
|
176
|
+
#
|
177
|
+
# REPORTS
|
178
|
+
#
|
179
|
+
#
|
180
|
+
def do_reports?
|
181
|
+
puts <<-END_INTRO.gsub(/^ {8}/, "")
|
182
|
+
|
183
|
+
== Reports ==
|
184
|
+
|
185
|
+
Report my status from time to time to ppl on the roster?
|
186
|
+
|
187
|
+
END_INTRO
|
188
|
+
|
189
|
+
print "Report interval in seconds (0 to disable): "
|
190
|
+
@config[:report] = gets.to_s.strip.to_i
|
191
|
+
end
|
192
|
+
|
193
|
+
|
194
|
+
#
|
195
|
+
# CRONTAB
|
196
|
+
#
|
197
|
+
#
|
198
|
+
def show_crontab
|
199
|
+
puts <<-CRON
|
200
|
+
|
201
|
+
If you are using the system crontab
|
202
|
+
(usually located at /etc/crontab):
|
203
|
+
|
204
|
+
****** START CRONTAB SAMPLE ******
|
205
|
+
*/30 * * * * #{user} #{program_path} #{key}
|
206
|
+
****** END CRONTAB SAMPLE ******
|
207
|
+
|
208
|
+
If you are using this current user's crontab
|
209
|
+
(using crontab -e to edit):
|
210
|
+
|
211
|
+
****** START CRONTAB SAMPLE ******
|
212
|
+
*/30 * * * * #{program_path} #{key}
|
213
|
+
****** END CRONTAB SAMPLE ******
|
214
|
+
|
215
|
+
For help setting up Scout with crontab, please visit:
|
216
|
+
|
217
|
+
http://scoutapp.com/help#cron
|
218
|
+
|
219
|
+
CRON
|
220
|
+
|
221
|
+
end
|
222
|
+
|
223
|
+
|
224
|
+
#
|
225
|
+
# DUCK TALK
|
226
|
+
#
|
227
|
+
#
|
228
|
+
def duck_talk
|
229
|
+
locs = I18n.available_locales.map { |l| l.to_s.downcase }
|
230
|
+
puts <<-END_I18N.gsub(/^ {10}/, "")
|
231
|
+
|
232
|
+
== Machine Personality ==
|
233
|
+
|
234
|
+
Jah goes a lil further than localization, you can make your machine talk to
|
235
|
+
you like a lady, R2D2, el chespirito, who knows... fork me and add one!
|
236
|
+
|
237
|
+
Available options:
|
238
|
+
|
239
|
+
* #{locs.join("\n* ")}
|
240
|
+
|
241
|
+
END_I18N
|
242
|
+
print "Choose one (#{Jah.locale}): "
|
243
|
+
@config[:i18n] = gets.to_s.strip.downcase
|
244
|
+
@config[:i18n] = Jah.locale if @config[:i18n] == ""
|
245
|
+
end
|
246
|
+
|
247
|
+
#
|
248
|
+
# SUCCESS!
|
249
|
+
#
|
250
|
+
#
|
251
|
+
def success!
|
252
|
+
puts <<-END_SUCCESS.gsub(/^ {10}/, "")
|
253
|
+
|
254
|
+
== Success! ==
|
255
|
+
|
256
|
+
Jah config file was written to #{@outfile}.
|
257
|
+
|
258
|
+
Just run `jah` to start it!
|
259
|
+
|
260
|
+
END_SUCCESS
|
261
|
+
|
262
|
+
daemon = gets.to_s.strip
|
263
|
+
end
|
264
|
+
|
265
|
+
#
|
266
|
+
# FAIL
|
267
|
+
#
|
268
|
+
#
|
269
|
+
def fail!
|
270
|
+
puts <<-END_ERROR.gsub(/^ {10}/, "")
|
271
|
+
|
272
|
+
Could not contact server. The client key may be incorrect.
|
273
|
+
For more help, please visit:
|
274
|
+
|
275
|
+
http://jahurl.com/help
|
276
|
+
|
277
|
+
END_ERROR
|
278
|
+
end
|
279
|
+
|
280
|
+
def write_down
|
281
|
+
outfile = "jah.yaml"
|
282
|
+
template = File.read(File.join(File.dirname(__FILE__), '..', 'jah.yaml.template'))
|
283
|
+
@outfile = File.writable?("/etc/") ? "/etc/" + outfile : HOME + outfile
|
284
|
+
puts "Writing config to #{@outfile}.."
|
285
|
+
@config.keys.each { |k| template.gsub!(/#{k.to_s.upcase}/, @config[k].to_s) }
|
286
|
+
File.open(@outfile, "w") { |f| f.write template }
|
287
|
+
end
|
288
|
+
|
289
|
+
def initialize
|
290
|
+
abort usage unless $stdin.tty?
|
291
|
+
puts "No config file found.. running install.."
|
292
|
+
|
293
|
+
@config = {}
|
294
|
+
@config[:host] = Jah.hostname
|
295
|
+
get_mode
|
296
|
+
if @config[:mode] == :xmpp
|
297
|
+
@config[:host] = ''
|
298
|
+
get_jid
|
299
|
+
get_pass
|
300
|
+
end
|
301
|
+
if @config[:mode] == :post
|
302
|
+
@config[:jid] = ''
|
303
|
+
get_key
|
304
|
+
end
|
305
|
+
|
306
|
+
# FIXME: when god support happens
|
307
|
+
@config[:god] = false
|
308
|
+
|
309
|
+
# unless use_god?
|
310
|
+
# unless daemonize?
|
311
|
+
# show_crontab
|
312
|
+
# end
|
313
|
+
# end
|
314
|
+
get_host
|
315
|
+
get_acl
|
316
|
+
get_groups
|
317
|
+
use_eval?
|
318
|
+
duck_talk
|
319
|
+
do_reports?
|
320
|
+
@config[:debug] = :info
|
321
|
+
puts ""
|
322
|
+
puts "== Writing Config File =="
|
323
|
+
puts ""
|
324
|
+
write_down
|
325
|
+
|
326
|
+
success!
|
327
|
+
exit
|
328
|
+
|
329
|
+
#puts "\nAttempting to contact the server..."
|
330
|
+
#begin
|
331
|
+
# Jah::Server.new
|
332
|
+
# rescue SystemExit
|
333
|
+
# end
|
334
|
+
end
|
335
|
+
end
|
336
|
+
end
|
data/lib/jah.rb
ADDED
@@ -0,0 +1,26 @@
|
|
1
|
+
require 'rubygems'
|
2
|
+
require 'optparse'
|
3
|
+
require 'i18n'
|
4
|
+
#autoload :Drb, 'drb'
|
5
|
+
autoload :God, 'god'
|
6
|
+
require 'jah/cli'
|
7
|
+
require 'jah/install'
|
8
|
+
require 'jah/agent'
|
9
|
+
require 'jah/collector'
|
10
|
+
require "jah/collectors/mem"
|
11
|
+
require "jah/collectors/cpu"
|
12
|
+
require "jah/collectors/net"
|
13
|
+
require "jah/collectors/disk"
|
14
|
+
require "jah/collectors/prok"
|
15
|
+
require "jah/collectors/net"
|
16
|
+
require "jah/collectors/who"
|
17
|
+
require 'jah/command'
|
18
|
+
require "jah/commands/admin"
|
19
|
+
require "jah/commands/status"
|
20
|
+
require "jah/commands/extra"
|
21
|
+
require "jah/commands/pub"
|
22
|
+
|
23
|
+
module Jah
|
24
|
+
VERSION = "0.0.1"
|
25
|
+
|
26
|
+
end
|
@@ -0,0 +1,26 @@
|
|
1
|
+
# Jah Config file for 'HOST'
|
2
|
+
---
|
3
|
+
:mode: MODE
|
4
|
+
:i18n: I18N
|
5
|
+
|
6
|
+
# Auth
|
7
|
+
:jid: JID
|
8
|
+
:host: HOST
|
9
|
+
:key: KEY
|
10
|
+
|
11
|
+
# Access
|
12
|
+
:acl: ACL
|
13
|
+
:groups: GROUPS
|
14
|
+
|
15
|
+
# Opts
|
16
|
+
:eval: EVAL
|
17
|
+
:god: GOD
|
18
|
+
:debug: DEBUG
|
19
|
+
:report: REPORT
|
20
|
+
:daemon: true
|
21
|
+
|
22
|
+
# Alerts
|
23
|
+
alerts:
|
24
|
+
:max_cpu:
|
25
|
+
:max_mem:
|
26
|
+
:max_swp:
|
@@ -0,0 +1,10 @@
|
|
1
|
+
pt_br_gostosa:
|
2
|
+
fail: Morzinho, isso acontece...
|
3
|
+
exit_code: Faz com jeitinho, vai...
|
4
|
+
access_fail: Não abro pra você!
|
5
|
+
ok: Põe tuuuuudo!
|
6
|
+
no_sudo: Atrás não amor!
|
7
|
+
states:
|
8
|
+
green: To pronta pro que der e vier...
|
9
|
+
yellow: Não estou dando conta...
|
10
|
+
red: To fodida e mal paga!
|
@@ -0,0 +1,10 @@
|
|
1
|
+
pt_br_mineiro:
|
2
|
+
fail: Faiô..
|
3
|
+
exit_code: Num prestô..
|
4
|
+
access_fail: Tá achano que é o dono da casa pra levá a chave?
|
5
|
+
ok: É nóis!
|
6
|
+
no_sudo: Sem cachaça procê!
|
7
|
+
states:
|
8
|
+
green: Uai, to bão sô! E ocê?
|
9
|
+
yellow: Tá mai pra lá do que pra cá..
|
10
|
+
red: Vége que a vaca tá no brejo!
|
data/spec/console
ADDED
@@ -0,0 +1,12 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
# Jah
|
3
|
+
$LOAD_PATH.unshift(File.dirname(__FILE__))
|
4
|
+
$LOAD_PATH.unshift(File.join(File.dirname(__FILE__), '..', 'lib'))
|
5
|
+
['irb', 'jah', 'readline', 'rubygems'].each {|e| require e }
|
6
|
+
|
7
|
+
#history_file = File.join(ENV["HOME"], '.myrb_history')
|
8
|
+
#IO.readlines(history_file).each {|e| Readline::HISTORY << e.chomp } if File.exists?(history_file)
|
9
|
+
while (input = Readline.readline('>> ', true)) != 'exit'
|
10
|
+
begin puts "=> #{eval(input).inspect}"; rescue Exception; puts "Error: #{$!}" end
|
11
|
+
end
|
12
|
+
#File.open(history_file, 'w') {|f| f.write Readline::HISTORY.to_a.join("\n") }
|
data/spec/jah_spec.rb
ADDED
data/spec/spec_helper.rb
ADDED
metadata
ADDED
@@ -0,0 +1,123 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: jah
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.0.3
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Marcos Piccinini
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
|
12
|
+
date: 2009-09-29 00:00:00 -03:00
|
13
|
+
default_executable: jah
|
14
|
+
dependencies:
|
15
|
+
- !ruby/object:Gem::Dependency
|
16
|
+
name: blather
|
17
|
+
type: :runtime
|
18
|
+
version_requirement:
|
19
|
+
version_requirements: !ruby/object:Gem::Requirement
|
20
|
+
requirements:
|
21
|
+
- - ">="
|
22
|
+
- !ruby/object:Gem::Version
|
23
|
+
version: "0"
|
24
|
+
version:
|
25
|
+
- !ruby/object:Gem::Dependency
|
26
|
+
name: i18n
|
27
|
+
type: :runtime
|
28
|
+
version_requirement:
|
29
|
+
version_requirements: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - ">="
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: "0"
|
34
|
+
version:
|
35
|
+
- !ruby/object:Gem::Dependency
|
36
|
+
name: rspec
|
37
|
+
type: :development
|
38
|
+
version_requirement:
|
39
|
+
version_requirements: !ruby/object:Gem::Requirement
|
40
|
+
requirements:
|
41
|
+
- - ">="
|
42
|
+
- !ruby/object:Gem::Version
|
43
|
+
version: "0"
|
44
|
+
version:
|
45
|
+
description: talk to your machines
|
46
|
+
email: x@nofxx.com
|
47
|
+
executables:
|
48
|
+
- jah
|
49
|
+
extensions: []
|
50
|
+
|
51
|
+
extra_rdoc_files:
|
52
|
+
- LICENSE
|
53
|
+
- README.md
|
54
|
+
files:
|
55
|
+
- .document
|
56
|
+
- .gitignore
|
57
|
+
- LICENSE
|
58
|
+
- README.md
|
59
|
+
- Rakefile
|
60
|
+
- VERSION
|
61
|
+
- bin/jah
|
62
|
+
- jah.gemspec
|
63
|
+
- lib/jah.rb
|
64
|
+
- lib/jah.yaml.template
|
65
|
+
- lib/jah/agent.rb
|
66
|
+
- lib/jah/agents/dump.rb
|
67
|
+
- lib/jah/agents/post.rb
|
68
|
+
- lib/jah/agents/xmpp.rb
|
69
|
+
- lib/jah/cli.rb
|
70
|
+
- lib/jah/collector.rb
|
71
|
+
- lib/jah/collectors/cpu.rb
|
72
|
+
- lib/jah/collectors/disk.rb
|
73
|
+
- lib/jah/collectors/mem.rb
|
74
|
+
- lib/jah/collectors/net.rb
|
75
|
+
- lib/jah/collectors/prok.rb
|
76
|
+
- lib/jah/collectors/services.rb
|
77
|
+
- lib/jah/collectors/who.rb
|
78
|
+
- lib/jah/command.rb
|
79
|
+
- lib/jah/commands/admin.rb
|
80
|
+
- lib/jah/commands/extra.rb
|
81
|
+
- lib/jah/commands/pub.rb
|
82
|
+
- lib/jah/commands/status.rb
|
83
|
+
- lib/jah/god.rb
|
84
|
+
- lib/jah/install.rb
|
85
|
+
- lib/locales/en_us.yml
|
86
|
+
- lib/locales/pt_br.yml
|
87
|
+
- lib/locales/pt_br_gostosa.yml
|
88
|
+
- lib/locales/pt_br_mano.yml
|
89
|
+
- lib/locales/pt_br_mineiro.yml
|
90
|
+
- spec/console
|
91
|
+
- spec/jah_spec.rb
|
92
|
+
- spec/spec_helper.rb
|
93
|
+
has_rdoc: true
|
94
|
+
homepage: http://github.com/nofxx/jah
|
95
|
+
licenses: []
|
96
|
+
|
97
|
+
post_install_message:
|
98
|
+
rdoc_options:
|
99
|
+
- --charset=UTF-8
|
100
|
+
require_paths:
|
101
|
+
- lib
|
102
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
103
|
+
requirements:
|
104
|
+
- - ">="
|
105
|
+
- !ruby/object:Gem::Version
|
106
|
+
version: "0"
|
107
|
+
version:
|
108
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
109
|
+
requirements:
|
110
|
+
- - ">="
|
111
|
+
- !ruby/object:Gem::Version
|
112
|
+
version: "0"
|
113
|
+
version:
|
114
|
+
requirements: []
|
115
|
+
|
116
|
+
rubyforge_project:
|
117
|
+
rubygems_version: 1.3.5
|
118
|
+
signing_key:
|
119
|
+
specification_version: 3
|
120
|
+
summary: be omnipresent...
|
121
|
+
test_files:
|
122
|
+
- spec/jah_spec.rb
|
123
|
+
- spec/spec_helper.rb
|