rcmd 1.5.6
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.bundle/config +1 -0
- data/.gitignore +1 -0
- data/.rspec_status +9 -0
- data/.ruby-gemset +1 -0
- data/.ruby-version +1 -0
- data/Gemfile +4 -0
- data/Gemfile.lock +55 -0
- data/README.md +84 -0
- data/Rakefile +37 -0
- data/bin/console +14 -0
- data/bin/setup +8 -0
- data/doc/rdocs/OptionParser.html +124 -0
- data/doc/rdocs/README_md.html +212 -0
- data/doc/rdocs/Rcmd.html +362 -0
- data/doc/rdocs/created.rid +5 -0
- data/doc/rdocs/images/add.png +0 -0
- data/doc/rdocs/images/arrow_up.png +0 -0
- data/doc/rdocs/images/brick.png +0 -0
- data/doc/rdocs/images/brick_link.png +0 -0
- data/doc/rdocs/images/bug.png +0 -0
- data/doc/rdocs/images/bullet_black.png +0 -0
- data/doc/rdocs/images/bullet_toggle_minus.png +0 -0
- data/doc/rdocs/images/bullet_toggle_plus.png +0 -0
- data/doc/rdocs/images/date.png +0 -0
- data/doc/rdocs/images/delete.png +0 -0
- data/doc/rdocs/images/find.png +0 -0
- data/doc/rdocs/images/loadingAnimation.gif +0 -0
- data/doc/rdocs/images/macFFBgHack.png +0 -0
- data/doc/rdocs/images/package.png +0 -0
- data/doc/rdocs/images/page_green.png +0 -0
- data/doc/rdocs/images/page_white_text.png +0 -0
- data/doc/rdocs/images/page_white_width.png +0 -0
- data/doc/rdocs/images/plugin.png +0 -0
- data/doc/rdocs/images/ruby.png +0 -0
- data/doc/rdocs/images/tag_blue.png +0 -0
- data/doc/rdocs/images/tag_green.png +0 -0
- data/doc/rdocs/images/transparent.png +0 -0
- data/doc/rdocs/images/wrench.png +0 -0
- data/doc/rdocs/images/wrench_orange.png +0 -0
- data/doc/rdocs/images/zoom.png +0 -0
- data/doc/rdocs/index.html +191 -0
- data/doc/rdocs/js/darkfish.js +155 -0
- data/doc/rdocs/js/jquery.js +4 -0
- data/doc/rdocs/js/navigation.js +142 -0
- data/doc/rdocs/js/search.js +94 -0
- data/doc/rdocs/js/search_index.js +1 -0
- data/doc/rdocs/js/searcher.js +228 -0
- data/doc/rdocs/rdoc.css +595 -0
- data/doc/rdocs/table_of_contents.html +71 -0
- data/exe/rcmd +73 -0
- data/lib/rcmd.rb +123 -0
- data/lib/rcmd/version.rb +4 -0
- data/rcmd.gemspec +46 -0
- metadata +204 -0
data/doc/rdocs/Rcmd.html
ADDED
@@ -0,0 +1,362 @@
|
|
1
|
+
<!DOCTYPE html>
|
2
|
+
|
3
|
+
<html>
|
4
|
+
<head>
|
5
|
+
<meta content="text/html; charset=UTF-8" http-equiv="Content-Type">
|
6
|
+
|
7
|
+
<title>module Rcmd - RDoc Documentation</title>
|
8
|
+
|
9
|
+
<link type="text/css" media="screen" href="./rdoc.css" rel="stylesheet">
|
10
|
+
|
11
|
+
<script type="text/javascript">
|
12
|
+
var rdoc_rel_prefix = "./";
|
13
|
+
</script>
|
14
|
+
|
15
|
+
<script type="text/javascript" charset="utf-8" src="./js/jquery.js"></script>
|
16
|
+
<script type="text/javascript" charset="utf-8" src="./js/navigation.js"></script>
|
17
|
+
<script type="text/javascript" charset="utf-8" src="./js/search_index.js"></script>
|
18
|
+
<script type="text/javascript" charset="utf-8" src="./js/search.js"></script>
|
19
|
+
<script type="text/javascript" charset="utf-8" src="./js/searcher.js"></script>
|
20
|
+
<script type="text/javascript" charset="utf-8" src="./js/darkfish.js"></script>
|
21
|
+
|
22
|
+
|
23
|
+
<body id="top" class="module">
|
24
|
+
<nav id="metadata">
|
25
|
+
<nav id="home-section" class="section">
|
26
|
+
<h3 class="section-header">
|
27
|
+
<a href="./index.html">Home</a>
|
28
|
+
<a href="./table_of_contents.html#classes">Classes</a>
|
29
|
+
<a href="./table_of_contents.html#methods">Methods</a>
|
30
|
+
</h3>
|
31
|
+
</nav>
|
32
|
+
|
33
|
+
|
34
|
+
<nav id="search-section" class="section project-section" class="initially-hidden">
|
35
|
+
<form action="#" method="get" accept-charset="utf-8">
|
36
|
+
<h3 class="section-header">
|
37
|
+
<input type="text" name="search" placeholder="Search" id="search-field"
|
38
|
+
title="Type to search, Up and Down to navigate, Enter to load">
|
39
|
+
</h3>
|
40
|
+
</form>
|
41
|
+
|
42
|
+
<ul id="search-results" class="initially-hidden"></ul>
|
43
|
+
</nav>
|
44
|
+
|
45
|
+
|
46
|
+
|
47
|
+
|
48
|
+
<div id="file-metadata">
|
49
|
+
<nav id="file-list-section" class="section">
|
50
|
+
<h3 class="section-header">Defined In</h3>
|
51
|
+
<ul>
|
52
|
+
<li>lib/rcmd.rb
|
53
|
+
<li>lib/rcmd/version.rb
|
54
|
+
</ul>
|
55
|
+
</nav>
|
56
|
+
|
57
|
+
|
58
|
+
</div>
|
59
|
+
|
60
|
+
<div id="class-metadata">
|
61
|
+
|
62
|
+
|
63
|
+
|
64
|
+
|
65
|
+
<!-- Method Quickref -->
|
66
|
+
<nav id="method-list-section" class="section">
|
67
|
+
<h3 class="section-header">Methods</h3>
|
68
|
+
|
69
|
+
<ul class="link-list">
|
70
|
+
|
71
|
+
<li ><a href="#method-c-run_command">::run_command</a>
|
72
|
+
|
73
|
+
</ul>
|
74
|
+
</nav>
|
75
|
+
|
76
|
+
</div>
|
77
|
+
|
78
|
+
<div id="project-metadata">
|
79
|
+
<nav id="fileindex-section" class="section project-section">
|
80
|
+
<h3 class="section-header">Pages</h3>
|
81
|
+
|
82
|
+
<ul>
|
83
|
+
|
84
|
+
<li class="file"><a href="./README_md.html">README</a>
|
85
|
+
|
86
|
+
</ul>
|
87
|
+
</nav>
|
88
|
+
|
89
|
+
<nav id="classindex-section" class="section project-section">
|
90
|
+
<h3 class="section-header">Class and Module Index</h3>
|
91
|
+
|
92
|
+
<ul class="link-list">
|
93
|
+
|
94
|
+
<li><a href="./OptionParser.html">OptionParser</a>
|
95
|
+
|
96
|
+
<li><a href="./Rcmd.html">Rcmd</a>
|
97
|
+
|
98
|
+
</ul>
|
99
|
+
</nav>
|
100
|
+
|
101
|
+
</div>
|
102
|
+
</nav>
|
103
|
+
|
104
|
+
<div id="documentation">
|
105
|
+
<h1 class="module">module Rcmd</h1>
|
106
|
+
|
107
|
+
<div id="description" class="description">
|
108
|
+
|
109
|
+
<p>This module is for parellel remote (SSH) execution of a single command
|
110
|
+
string on Multiple hosts. The module itself consists of one method for
|
111
|
+
execution (Rcmd.run_command) which does not accept any arguments. The
|
112
|
+
required arguments are set as variables through the use of accessors.</p>
|
113
|
+
|
114
|
+
</div><!-- description -->
|
115
|
+
|
116
|
+
|
117
|
+
|
118
|
+
|
119
|
+
<section id="5Buntitled-5D" class="documentation-section">
|
120
|
+
|
121
|
+
|
122
|
+
|
123
|
+
|
124
|
+
|
125
|
+
<!-- Constants -->
|
126
|
+
<section id="constants-list" class="section">
|
127
|
+
<h3 class="section-header">Constants</h3>
|
128
|
+
<dl>
|
129
|
+
|
130
|
+
<dt id="VERSION">VERSION
|
131
|
+
|
132
|
+
<dd class="description"><p><code>VERSION</code> - Version number string</p>
|
133
|
+
|
134
|
+
|
135
|
+
</dl>
|
136
|
+
</section>
|
137
|
+
|
138
|
+
|
139
|
+
|
140
|
+
<!-- Attributes -->
|
141
|
+
<section id="attribute-method-details" class="method-section section">
|
142
|
+
<h3 class="section-header">Attributes</h3>
|
143
|
+
|
144
|
+
|
145
|
+
<div id="attribute-c-command" class="method-detail">
|
146
|
+
<div class="method-heading attribute-method-heading">
|
147
|
+
<span class="method-name">command</span><span
|
148
|
+
class="attribute-access-type">[RW]</span>
|
149
|
+
</div>
|
150
|
+
|
151
|
+
<div class="method-description">
|
152
|
+
|
153
|
+
<p>String containing the command to be used. (Manditory)</p>
|
154
|
+
|
155
|
+
</div>
|
156
|
+
</div>
|
157
|
+
|
158
|
+
<div id="attribute-c-host_list" class="method-detail">
|
159
|
+
<div class="method-heading attribute-method-heading">
|
160
|
+
<span class="method-name">host_list</span><span
|
161
|
+
class="attribute-access-type">[RW]</span>
|
162
|
+
</div>
|
163
|
+
|
164
|
+
<div class="method-description">
|
165
|
+
|
166
|
+
<p>An array of hosts to run the given command on. (Manditory)</p>
|
167
|
+
|
168
|
+
</div>
|
169
|
+
</div>
|
170
|
+
|
171
|
+
<div id="attribute-c-nthreads" class="method-detail">
|
172
|
+
<div class="method-heading attribute-method-heading">
|
173
|
+
<span class="method-name">nthreads</span><span
|
174
|
+
class="attribute-access-type">[RW]</span>
|
175
|
+
</div>
|
176
|
+
|
177
|
+
<div class="method-description">
|
178
|
+
|
179
|
+
<p>Prefered/requested number of threads to be used. (Manditory)</p>
|
180
|
+
|
181
|
+
</div>
|
182
|
+
</div>
|
183
|
+
|
184
|
+
<div id="attribute-c-quiet" class="method-detail">
|
185
|
+
<div class="method-heading attribute-method-heading">
|
186
|
+
<span class="method-name">quiet</span><span
|
187
|
+
class="attribute-access-type">[RW]</span>
|
188
|
+
</div>
|
189
|
+
|
190
|
+
<div class="method-description">
|
191
|
+
|
192
|
+
<p>Boolean for disabling STDOUT output. SDTERR is always displayed.
|
193
|
+
(Optional)</p>
|
194
|
+
|
195
|
+
</div>
|
196
|
+
</div>
|
197
|
+
|
198
|
+
<div id="attribute-c-threads" class="method-detail">
|
199
|
+
<div class="method-heading attribute-method-heading">
|
200
|
+
<span class="method-name">threads</span><span
|
201
|
+
class="attribute-access-type">[RW]</span>
|
202
|
+
</div>
|
203
|
+
|
204
|
+
<div class="method-description">
|
205
|
+
|
206
|
+
<p>Array containing the current iterations thread objects.</p>
|
207
|
+
|
208
|
+
</div>
|
209
|
+
</div>
|
210
|
+
|
211
|
+
<div id="attribute-c-user" class="method-detail">
|
212
|
+
<div class="method-heading attribute-method-heading">
|
213
|
+
<span class="method-name">user</span><span
|
214
|
+
class="attribute-access-type">[RW]</span>
|
215
|
+
</div>
|
216
|
+
|
217
|
+
<div class="method-description">
|
218
|
+
|
219
|
+
<p>What user should we connect as. (Manditory)</p>
|
220
|
+
|
221
|
+
</div>
|
222
|
+
</div>
|
223
|
+
|
224
|
+
</section><!-- attribute-method-details -->
|
225
|
+
|
226
|
+
|
227
|
+
<!-- Methods -->
|
228
|
+
|
229
|
+
<section id="public-class-5Buntitled-5D-method-details" class="method-section section">
|
230
|
+
<h3 class="section-header">Public Class Methods</h3>
|
231
|
+
|
232
|
+
|
233
|
+
<div id="method-c-run_command" class="method-detail ">
|
234
|
+
|
235
|
+
<div class="method-heading">
|
236
|
+
<span class="method-name">run_command</span><span
|
237
|
+
class="method-args">()</span>
|
238
|
+
|
239
|
+
<span class="method-click-advice">click to toggle source</span>
|
240
|
+
|
241
|
+
</div>
|
242
|
+
|
243
|
+
|
244
|
+
<div class="method-description">
|
245
|
+
|
246
|
+
<p>Main method for this module which should be called after the correct
|
247
|
+
variables have been set.</p>
|
248
|
+
|
249
|
+
<p>We iterate over the host list until it is empty, creating all needed
|
250
|
+
threads based upon the prefered number of threads for execution. Before
|
251
|
+
creating the threads, the method first checks if the preferred number of
|
252
|
+
threads is greater then the number of hosts remaining in the host list. If
|
253
|
+
false (threads > num hosts) then the number of remaining hosts becomes
|
254
|
+
the thread count. This prevents spawning of unneeded threads.</p>
|
255
|
+
|
256
|
+
<h4 id="method-c-run_command-label-Manditory+values+to+be+set">Manditory values to be set<span><a href="#method-c-run_command-label-Manditory+values+to+be+set">¶</a> <a href="#documentation">↑</a></span></h4>
|
257
|
+
<ul><li>
|
258
|
+
<p><code>:user</code> - User to run the command as</p>
|
259
|
+
</li><li>
|
260
|
+
<p><code>:command</code> - Command to be executed</p>
|
261
|
+
</li><li>
|
262
|
+
<p><code>:host_list</code> - Array containing the hosts for command execution.</p>
|
263
|
+
</li><li>
|
264
|
+
<p><code>:nthreads</code> - Preferred max number of threads</p>
|
265
|
+
</li></ul>
|
266
|
+
|
267
|
+
<h4 id="method-c-run_command-label-Optional+Values">Optional Values<span><a href="#method-c-run_command-label-Optional+Values">¶</a> <a href="#documentation">↑</a></span></h4>
|
268
|
+
<ul><li>
|
269
|
+
<p><code>:quiet</code> - Do not print to STDOUT. STDERR is always printed</p>
|
270
|
+
</li></ul>
|
271
|
+
|
272
|
+
<h4 id="method-c-run_command-label-Specifically+for+the+method+only">Specifically for the method only<span><a href="#method-c-run_command-label-Specifically+for+the+method+only">¶</a> <a href="#documentation">↑</a></span></h4>
|
273
|
+
<ul><li>
|
274
|
+
<p><code>:threads</code> - Array of the current threads</p>
|
275
|
+
</li></ul>
|
276
|
+
|
277
|
+
<h4 id="method-c-run_command-label-Example">Example<span><a href="#method-c-run_command-label-Example">¶</a> <a href="#documentation">↑</a></span></h4>
|
278
|
+
|
279
|
+
<pre class="ruby"><span class="ruby-identifier">require</span> <span class="ruby-string">'rcmd'</span>
|
280
|
+
<span class="ruby-constant">Rcmd</span>.<span class="ruby-identifier">host_list</span>= [<span class="ruby-string">"host1"</span>, <span class="ruby-string">"host2"</span>, <span class="ruby-string">"host3"</span>, <span class="ruby-string">"host4"</span>, <span class="ruby-string">"host 5"</span>, <span class="ruby-string">"host6"</span>]
|
281
|
+
<span class="ruby-constant">Rcmd</span>.<span class="ruby-identifier">user</span>= <span class="ruby-string">'root'</span>
|
282
|
+
<span class="ruby-constant">Rcmd</span>.<span class="ruby-identifier">command</span>= <span class="ruby-string">'rpm -qa kernel\*'</span>
|
283
|
+
<span class="ruby-constant">Rcmd</span>.<span class="ruby-identifier">nthreads</span>= <span class="ruby-value">6</span>
|
284
|
+
<span class="ruby-constant">Rcmd</span>.<span class="ruby-identifier">run_command</span>
|
285
|
+
</pre>
|
286
|
+
|
287
|
+
|
288
|
+
|
289
|
+
|
290
|
+
<div class="method-source-code" id="run_command-source">
|
291
|
+
<pre><span class="ruby-comment"># File lib/rcmd.rb, line 74</span>
|
292
|
+
<span class="ruby-keyword">def</span> <span class="ruby-constant">Rcmd</span>.<span class="ruby-identifier">run_command</span>()
|
293
|
+
<span class="ruby-keyword">if</span> <span class="ruby-keyword">not</span> <span class="ruby-ivar">@command</span>
|
294
|
+
<span class="ruby-identifier">raise</span> <span class="ruby-constant">ArgumentError</span>.<span class="ruby-identifier">new</span>(<span class="ruby-string">"No command set for execution"</span>)
|
295
|
+
<span class="ruby-keyword">end</span>
|
296
|
+
<span class="ruby-keyword">if</span> <span class="ruby-keyword">not</span> <span class="ruby-ivar">@host_list</span>.<span class="ruby-identifier">count</span> <span class="ruby-operator">>=</span> <span class="ruby-value">1</span>
|
297
|
+
<span class="ruby-identifier">raise</span> <span class="ruby-constant">ArgumentError</span>.<span class="ruby-identifier">new</span>(<span class="ruby-string">"host_list must contain at least one system"</span>)
|
298
|
+
<span class="ruby-keyword">end</span>
|
299
|
+
<span class="ruby-ivar">@host_list</span>.<span class="ruby-identifier">each</span> <span class="ruby-keyword">do</span> <span class="ruby-operator">|</span><span class="ruby-identifier">host</span><span class="ruby-operator">|</span>
|
300
|
+
<span class="ruby-ivar">@queue</span> <span class="ruby-operator"><<</span> <span class="ruby-identifier">host</span>
|
301
|
+
<span class="ruby-keyword">end</span>
|
302
|
+
<span class="ruby-keyword">until</span> <span class="ruby-ivar">@queue</span>.<span class="ruby-identifier">empty?</span>
|
303
|
+
<span class="ruby-comment"># Don't start more threads then hosts.</span>
|
304
|
+
<span class="ruby-identifier">num_threads</span> = <span class="ruby-ivar">@nthreads</span> <span class="ruby-operator"><=</span> <span class="ruby-ivar">@queue</span>.<span class="ruby-identifier">length</span> <span class="ruby-operator">?</span> <span class="ruby-ivar">@nthreads</span> <span class="ruby-operator">:</span> <span class="ruby-ivar">@queue</span>.<span class="ruby-identifier">length</span>
|
305
|
+
<span class="ruby-comment"># Prepare threads</span>
|
306
|
+
<span class="ruby-ivar">@threads</span> = [ ]
|
307
|
+
<span class="ruby-identifier">num_threads</span>.<span class="ruby-identifier">times</span> <span class="ruby-keyword">do</span> <span class="ruby-operator">|</span><span class="ruby-identifier">i</span><span class="ruby-operator">|</span>
|
308
|
+
<span class="ruby-ivar">@threads</span>[<span class="ruby-identifier">i</span>] = <span class="ruby-constant">Thread</span>.<span class="ruby-identifier">new</span> {
|
309
|
+
<span class="ruby-keyword">begin</span>
|
310
|
+
<span class="ruby-identifier">conn_options</span> = { <span class="ruby-value">:user</span> =<span class="ruby-operator">></span> <span class="ruby-ivar">@user</span>, <span class="ruby-value">:host</span> =<span class="ruby-operator">></span> <span class="ruby-ivar">@queue</span>.<span class="ruby-identifier">pop</span>, <span class="ruby-value">:password</span> =<span class="ruby-operator">></span> <span class="ruby-keyword">nil</span>, <span class="ruby-value">:quiet</span> =<span class="ruby-operator">></span> <span class="ruby-ivar">@quiet</span>}
|
311
|
+
<span class="ruby-constant">Net</span><span class="ruby-operator">::</span><span class="ruby-constant">SSH</span>.<span class="ruby-identifier">start</span>(<span class="ruby-identifier">conn_options</span>[<span class="ruby-value">:host</span>], <span class="ruby-identifier">conn_options</span>[<span class="ruby-value">:user</span>], <span class="ruby-value">:password</span> =<span class="ruby-operator">></span> <span class="ruby-identifier">conn_options</span>[<span class="ruby-value">:passwd</span>]) <span class="ruby-keyword">do</span> <span class="ruby-operator">|</span><span class="ruby-identifier">session</span><span class="ruby-operator">|</span>
|
312
|
+
<span class="ruby-comment"># Open channel for input/output control</span>
|
313
|
+
<span class="ruby-identifier">session</span>.<span class="ruby-identifier">open_channel</span> <span class="ruby-keyword">do</span> <span class="ruby-operator">|</span><span class="ruby-identifier">channel</span><span class="ruby-operator">|</span>
|
314
|
+
<span class="ruby-identifier">channel</span>.<span class="ruby-identifier">on_data</span> <span class="ruby-keyword">do</span> <span class="ruby-operator">|</span><span class="ruby-identifier">ch</span>, <span class="ruby-identifier">data</span><span class="ruby-operator">|</span>
|
315
|
+
<span class="ruby-comment"># Print recieved data if quiet is not true</span>
|
316
|
+
<span class="ruby-constant">STDOUT</span>.<span class="ruby-identifier">print</span> <span class="ruby-node">"#{conn_options[:host]} :: #{data}"</span> <span class="ruby-keyword">unless</span> <span class="ruby-identifier">conn_options</span>[<span class="ruby-value">:quiet</span>]
|
317
|
+
<span class="ruby-keyword">end</span>
|
318
|
+
<span class="ruby-identifier">channel</span>.<span class="ruby-identifier">on_extended_data</span> <span class="ruby-keyword">do</span> <span class="ruby-operator">|</span><span class="ruby-identifier">ch</span>,<span class="ruby-identifier">type</span>,<span class="ruby-identifier">data</span><span class="ruby-operator">|</span>
|
319
|
+
<span class="ruby-comment"># Always print stderr data</span>
|
320
|
+
<span class="ruby-constant">STDERR</span>.<span class="ruby-identifier">print</span> <span class="ruby-node">"#{conn_options[:host]} :: ERROR :: #{data}"</span>
|
321
|
+
<span class="ruby-keyword">end</span>
|
322
|
+
<span class="ruby-comment"># Execute command</span>
|
323
|
+
<span class="ruby-identifier">channel</span>.<span class="ruby-identifier">exec</span> <span class="ruby-ivar">@command</span>
|
324
|
+
<span class="ruby-keyword">end</span>
|
325
|
+
<span class="ruby-comment"># Loop until command completes</span>
|
326
|
+
<span class="ruby-identifier">session</span>.<span class="ruby-identifier">loop</span>
|
327
|
+
<span class="ruby-keyword">end</span>
|
328
|
+
<span class="ruby-keyword">rescue</span>
|
329
|
+
<span class="ruby-constant">STDERR</span>.<span class="ruby-identifier">print</span> <span class="ruby-node">"#{conn_options[:host]} :: CONNECT ERROR :: Unable to connect to host!\n"</span>
|
330
|
+
<span class="ruby-keyword">end</span>
|
331
|
+
}
|
332
|
+
<span class="ruby-comment"># Execute threads</span>
|
333
|
+
<span class="ruby-keyword">end</span>
|
334
|
+
<span class="ruby-ivar">@threads</span>.<span class="ruby-identifier">each</span> { <span class="ruby-operator">|</span><span class="ruby-identifier">t</span><span class="ruby-operator">|</span> <span class="ruby-identifier">t</span>.<span class="ruby-identifier">join</span> }
|
335
|
+
<span class="ruby-keyword">end</span>
|
336
|
+
<span class="ruby-keyword">unless</span> <span class="ruby-ivar">@threads</span>.<span class="ruby-identifier">each</span>.<span class="ruby-identifier">map</span> {<span class="ruby-operator">|</span><span class="ruby-identifier">t</span><span class="ruby-operator">|</span> <span class="ruby-identifier">t</span>.<span class="ruby-identifier">alive?</span>}.<span class="ruby-identifier">none?</span>
|
337
|
+
<span class="ruby-identifier">sleep</span> <span class="ruby-value">1</span>
|
338
|
+
<span class="ruby-keyword">end</span>
|
339
|
+
<span class="ruby-keyword">end</span></pre>
|
340
|
+
</div><!-- run_command-source -->
|
341
|
+
|
342
|
+
</div>
|
343
|
+
|
344
|
+
|
345
|
+
|
346
|
+
|
347
|
+
</div><!-- run_command-method -->
|
348
|
+
|
349
|
+
|
350
|
+
</section><!-- public-class-method-details -->
|
351
|
+
|
352
|
+
</section><!-- 5Buntitled-5D -->
|
353
|
+
|
354
|
+
</div><!-- documentation -->
|
355
|
+
|
356
|
+
|
357
|
+
<footer id="validator-badges">
|
358
|
+
<p><a href="http://validator.w3.org/check/referer">[Validate]</a>
|
359
|
+
<p>Generated by <a href="https://github.com/rdoc/rdoc">RDoc</a> 4.0.0.
|
360
|
+
<p>Generated with the <a href="http://deveiate.org/projects/Darkfish-Rdoc/">Darkfish Rdoc Generator</a> 3.
|
361
|
+
</footer>
|
362
|
+
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
@@ -0,0 +1,191 @@
|
|
1
|
+
<!DOCTYPE html>
|
2
|
+
|
3
|
+
<html>
|
4
|
+
<head>
|
5
|
+
<meta content="text/html; charset=UTF-8" http-equiv="Content-Type">
|
6
|
+
|
7
|
+
<title>RDoc Documentation</title>
|
8
|
+
|
9
|
+
<link type="text/css" media="screen" href="./rdoc.css" rel="stylesheet">
|
10
|
+
|
11
|
+
<script type="text/javascript">
|
12
|
+
var rdoc_rel_prefix = "./";
|
13
|
+
</script>
|
14
|
+
|
15
|
+
<script type="text/javascript" charset="utf-8" src="./js/jquery.js"></script>
|
16
|
+
<script type="text/javascript" charset="utf-8" src="./js/navigation.js"></script>
|
17
|
+
<script type="text/javascript" charset="utf-8" src="./js/search_index.js"></script>
|
18
|
+
<script type="text/javascript" charset="utf-8" src="./js/search.js"></script>
|
19
|
+
<script type="text/javascript" charset="utf-8" src="./js/searcher.js"></script>
|
20
|
+
<script type="text/javascript" charset="utf-8" src="./js/darkfish.js"></script>
|
21
|
+
|
22
|
+
|
23
|
+
<body>
|
24
|
+
<nav id="metadata">
|
25
|
+
<nav id="home-section" class="section">
|
26
|
+
<h3 class="section-header">
|
27
|
+
<a href="./index.html">Home</a>
|
28
|
+
<a href="./table_of_contents.html#classes">Classes</a>
|
29
|
+
<a href="./table_of_contents.html#methods">Methods</a>
|
30
|
+
</h3>
|
31
|
+
</nav>
|
32
|
+
|
33
|
+
|
34
|
+
<nav id="search-section" class="section project-section" class="initially-hidden">
|
35
|
+
<form action="#" method="get" accept-charset="utf-8">
|
36
|
+
<h3 class="section-header">
|
37
|
+
<input type="text" name="search" placeholder="Search" id="search-field"
|
38
|
+
title="Type to search, Up and Down to navigate, Enter to load">
|
39
|
+
</h3>
|
40
|
+
</form>
|
41
|
+
|
42
|
+
<ul id="search-results" class="initially-hidden"></ul>
|
43
|
+
</nav>
|
44
|
+
|
45
|
+
|
46
|
+
<div id="project-metadata">
|
47
|
+
<nav id="fileindex-section" class="section project-section">
|
48
|
+
<h3 class="section-header">Pages</h3>
|
49
|
+
|
50
|
+
<ul>
|
51
|
+
|
52
|
+
<li class="file"><a href="./README_md.html">README</a>
|
53
|
+
|
54
|
+
</ul>
|
55
|
+
</nav>
|
56
|
+
|
57
|
+
<nav id="classindex-section" class="section project-section">
|
58
|
+
<h3 class="section-header">Class and Module Index</h3>
|
59
|
+
|
60
|
+
<ul class="link-list">
|
61
|
+
|
62
|
+
<li><a href="./OptionParser.html">OptionParser</a>
|
63
|
+
|
64
|
+
<li><a href="./Rcmd.html">Rcmd</a>
|
65
|
+
|
66
|
+
</ul>
|
67
|
+
</nav>
|
68
|
+
|
69
|
+
</div>
|
70
|
+
</nav>
|
71
|
+
|
72
|
+
<div id="documentation" class="description">
|
73
|
+
|
74
|
+
<h1 id="label-Description">Description<span><a href="#label-Description">¶</a> <a href="#documentation">↑</a></span></h1>
|
75
|
+
|
76
|
+
<p>rcmd (remote command) is a command line utility written in Ruby for
|
77
|
+
executing the same command on
|
78
|
+
multiple systems through ssh. This is done by
|
79
|
+
assigning a host to a
|
80
|
+
thread and creating the ssh sessions in those
|
81
|
+
threads.</p>
|
82
|
+
|
83
|
+
<h2 id="label-Features">Features<span><a href="#label-Features">¶</a> <a href="#documentation">↑</a></span></h2>
|
84
|
+
<ul><li>
|
85
|
+
<p>Command line switch for setting number of threads to be used at a time.
|
86
|
+
(Default is 4)</p>
|
87
|
+
</li><li>
|
88
|
+
<p>A comma seperated list of hosts piped from another command can be used as
|
89
|
+
the node list.</p>
|
90
|
+
</li><li>
|
91
|
+
<p>Username can be specified. (Default is root. Requires valid ssh-key in
|
92
|
+
~/.ssh)</p>
|
93
|
+
</li><li>
|
94
|
+
<p>Output shows which host the output is from</p>
|
95
|
+
</li><li>
|
96
|
+
<p>Stdout can be suppressed, only allowing for stderr to be shown</p>
|
97
|
+
</li></ul>
|
98
|
+
|
99
|
+
<h2 id="label-Installation">Installation<span><a href="#label-Installation">¶</a> <a href="#documentation">↑</a></span></h2>
|
100
|
+
|
101
|
+
<p>rcmd is available as a gem and kan be installed with <code>gem install
|
102
|
+
rcmd</code></p>
|
103
|
+
|
104
|
+
<h1 id="label-Usage+Examples">Usage Examples<span><a href="#label-Usage+Examples">¶</a> <a href="#documentation">↑</a></span></h1>
|
105
|
+
|
106
|
+
<h2 id="label-Help+Screen">Help Screen<span><a href="#label-Help+Screen">¶</a> <a href="#documentation">↑</a></span></h2>
|
107
|
+
|
108
|
+
<pre>daibhidh@darkstar:~/$ rcmd --help
|
109
|
+
Usage: rcmd [options]
|
110
|
+
-u, --username username Username for SSH connections
|
111
|
+
-n, --nodes x,y,z Comma seperated list of nodes. use '-' for a space seperated list piped from another command
|
112
|
+
-t, --threads threads Number of threads to run
|
113
|
+
-c, --command <command> Quoted string containing the command to be run
|
114
|
+
-q, --quiet Suppress stdout of commands. stderr will still be displayed
|
115
|
+
-v, --version Print what version of the command is in use</pre>
|
116
|
+
|
117
|
+
<h2 id="label-Specifying+nodes+manually">Specifying nodes manually<span><a href="#label-Specifying+nodes+manually">¶</a> <a href="#documentation">↑</a></span></h2>
|
118
|
+
|
119
|
+
<p>Specifying a comma seperated list of hosts and timing the total execution
|
120
|
+
time.
|
121
|
+
```bash
|
122
|
+
daibhidh@darkstar:~/$ time rcmd -n node1,node2,node3,node4 -c
|
123
|
+
'cat /etc/redhat-release'
|
124
|
+
node2 :: Red Hat Enterprise Linux
|
125
|
+
ComputeNode release 6.8 (Santiago)
|
126
|
+
node1 :: Red Hat Enterprise Linux
|
127
|
+
ComputeNode release 6.8 (Santiago)
|
128
|
+
node4 :: Red Hat Enterprise Linux
|
129
|
+
ComputeNode release 6.9 (Santiago)
|
130
|
+
node3 :: Red Hat Enterprise Linux
|
131
|
+
ComputeNode release 6.9 (Santiago)</p>
|
132
|
+
|
133
|
+
<p>real 0m2.749s
|
134
|
+
user 0m0.272s
|
135
|
+
sys 0m0.050s
|
136
|
+
```</p>
|
137
|
+
|
138
|
+
<h2 id="label-Piping+list+of+nodes">Piping list of nodes<span><a href="#label-Piping+list+of+nodes">¶</a> <a href="#documentation">↑</a></span></h2>
|
139
|
+
|
140
|
+
<p>Using the hammer cli to get a list of hosts from a RedHat Satellite and
|
141
|
+
providing it to rcmd as the node
|
142
|
+
list.
|
143
|
+
<code>bash
|
144
|
+
daibhidh@darkstar:~/$ hammer --output base host list
|
145
|
+
--organization org | awk '/Name:/ {print $2}' | rcmd -n - -c
|
146
|
+
'cat /etc/redhat-release'
|
147
|
+
node1.example.com :: Red Hat Enterprise
|
148
|
+
Linux ComputeNode release 6.8 (Santiago)
|
149
|
+
node3.example.com :: Red Hat
|
150
|
+
Enterprise Linux ComputeNode release 6.9 (Santiago)
|
151
|
+
node2.example.com ::
|
152
|
+
Red Hat Enterprise Linux ComputeNode release 6.8
|
153
|
+
(Santiago)
|
154
|
+
node4.example.com :: Red Hat Enterprise Linux ComputeNode
|
155
|
+
release 6.9 (Santiago)
|
156
|
+
</code></p>
|
157
|
+
|
158
|
+
<h2 id="label-Using+a+database+for+obtaining+nodes">Using a database for obtaining nodes<span><a href="#label-Using+a+database+for+obtaining+nodes">¶</a> <a href="#documentation">↑</a></span></h2>
|
159
|
+
|
160
|
+
<p>TODO</p>
|
161
|
+
|
162
|
+
<h1 id="label-Development">Development<span><a href="#label-Development">¶</a> <a href="#documentation">↑</a></span></h1>
|
163
|
+
|
164
|
+
<p>If you are wanting to modify the code by all means do so. If you clone this
|
165
|
+
repository you can then run <code>bundle install</code> to install the
|
166
|
+
dependencies needed. Tests are performed with <em>rspec</em> and can be run
|
167
|
+
with <em>rake</em>.</p>
|
168
|
+
|
169
|
+
<p>Available Rake tasks are:</p>
|
170
|
+
|
171
|
+
<pre>rake build # Build rcmd-1.5.5.gem into the pkg directory
|
172
|
+
rake clean # Remove any temporary products
|
173
|
+
rake clobber # Remove any generated files
|
174
|
+
rake clobber_rdoc # Remove RDoc HTML files
|
175
|
+
rake console # Open an IRB console with this gem loaded
|
176
|
+
rake install # Build and install rcmd-1.5.5.gem into system gems
|
177
|
+
rake install:local # Build and install rcmd-1.5.5.gem into system gems without network access
|
178
|
+
rake rdoc # Build RDoc HTML files
|
179
|
+
rake reinstall # Remove, build, and install gem
|
180
|
+
rake release[remote] # Create tag v1.5.5 and build and push rcmd-1.5.5.gem to Rubygems
|
181
|
+
rake rerdoc # Rebuild RDoc HTML files
|
182
|
+
rake spec # Run RSpec code examples</pre>
|
183
|
+
</div>
|
184
|
+
|
185
|
+
|
186
|
+
<footer id="validator-badges">
|
187
|
+
<p><a href="http://validator.w3.org/check/referer">[Validate]</a>
|
188
|
+
<p>Generated by <a href="https://github.com/rdoc/rdoc">RDoc</a> 4.0.0.
|
189
|
+
<p>Generated with the <a href="http://deveiate.org/projects/Darkfish-Rdoc/">Darkfish Rdoc Generator</a> 3.
|
190
|
+
</footer>
|
191
|
+
|