nysol 3.0.0-universal-darwin-13

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,44 @@
1
+ #!/usr/bin/env ruby
2
+ #/* ////////// LICENSE INFO ////////////////////
3
+ #
4
+ # * Copyright (C) 2013 by NYSOL CORPORATION
5
+ # *
6
+ # * Unless you have received this program directly from NYSOL pursuant
7
+ # * to the terms of a commercial license agreement with NYSOL, then
8
+ # * this program is licensed to you under the terms of the GNU Affero General
9
+ # * Public License (AGPL) as published by the Free Software Foundation,
10
+ # * either version 3 of the License, or (at your option) any later version.
11
+ # *
12
+ # * This program is distributed in the hope that it will be useful, but
13
+ # * WITHOUT ANY EXPRESS OR IMPLIED WARRANTY, INCLUDING THOSE OF
14
+ # * NON-INFRINGEMENT, MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE.
15
+ # *
16
+ # * Please refer to the AGPL (http://www.gnu.org/licenses/agpl-3.0.txt)
17
+ # * for more details.
18
+ #
19
+ # ////////// LICENSE INFO ////////////////////*/
20
+
21
+ #= MCMD ruby拡張ライブラリ
22
+ #Mコマンドruby拡張ライブラリとは、MCMDで提供されている各種データ処理モジュールをrubyから利用できるようにするインターフェースを提供する。
23
+ #
24
+ #mcmd.rbは、以下の6つのクラスライブラリをrequireしている。
25
+ # require "mcsvin" # MCMD::CSVin CSVの行単位読み込みクラス (c++で作成された共有ライブラリ)
26
+ # require "mcsvout" # MCMD::CSVout CSVの出力クラス (c++で作成された共有ライブラリ)
27
+ # require "mtable" # MCMD::Table CSVのメモリ展開クラス (c++で作成された共有ライブラリ)
28
+ # require "margs" # MCMD::Args コマンドライン引数を扱うクラス(rubyスクリプト)
29
+ # require "mtemp" # MCMD::Temp 一時ファイル管理(rubyスクリプト)
30
+
31
+ require "nysol/margs"
32
+ require "nysol/mutils"
33
+ require "nysol/mtemp"
34
+ require "nysol/mmethods"
35
+ require "nysol/mcsvin"
36
+ require "nysol/mcsvout"
37
+ require "nysol/mtable"
38
+ require "nysol/msysteminfo"
39
+ require "nysol/mnettools"
40
+ require "nysol/mparallel"
41
+ require "fileutils"
42
+
43
+
44
+
Binary file
Binary file
Binary file
@@ -0,0 +1,220 @@
1
+ #!/usr/bin/env ruby
2
+ # encoding: utf-8
3
+ #/* ////////// LICENSE INFO ////////////////////
4
+ #
5
+ # * Copyright (C) 2013 by NYSOL CORPORATION
6
+ # *
7
+ # * Unless you have received this program directly from NYSOL pursuant
8
+ # * to the terms of a commercial license agreement with NYSOL, then
9
+ # * this program is licensed to you under the terms of the GNU Affero General
10
+ # * Public License (AGPL) as published by the Free Software Foundation,
11
+ # * either version 3 of the License, or (at your option) any later version.
12
+ # *
13
+ # * This program is distributed in the hope that it will be useful, but
14
+ # * WITHOUT ANY EXPRESS OR IMPLIED WARRANTY, INCLUDING THOSE OF
15
+ # * NON-INFRINGEMENT, MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE.
16
+ # *
17
+ # * Please refer to the AGPL (http://www.gnu.org/licenses/agpl-3.0.txt)
18
+ # * for more details.
19
+ #
20
+ # ////////// LICENSE INFO ////////////////////*/
21
+ require 'rubygems'
22
+ require 'net/ftp'
23
+ require "nysol/mtemp"
24
+
25
+
26
+
27
+ module MCMD
28
+
29
+ module NetTools
30
+ @@ftpUse=true
31
+ @@retry_scp = 5
32
+ if File.exist?("/etc/nysol_netconf") then
33
+ File.open("/etc/nysol_netconf"){|fp|
34
+ while lin = fp.gets do
35
+ sp = lin.chomp!.split()
36
+ if sp[0] == "FtpUse" then
37
+ @@ftpUse=true if sp[1] == "true"
38
+ @@ftpUse=false if sp[1] == "falsed"
39
+ elsif sp[0] == "RetryTimes" then
40
+ @@retry_scp = sp[1].to_i if sp[1]
41
+ end
42
+ end
43
+ }
44
+ end
45
+
46
+ def self.config_info
47
+ puts "R #{@@retry_scp} F #{@@ftpUse}"
48
+ end
49
+
50
+ def self.cmdRun(ip,uid,cmd,secret=nil)
51
+ sts = false
52
+ @@retry_scp.times{|i|
53
+ if secret then
54
+ sts = system("ssh -i #{secret} #{uid}@#{ip} '#{cmd}'")
55
+ else
56
+ sts = system("ssh #{uid}@#{ip} '#{cmd}'")
57
+ end
58
+ break if sts
59
+ sleep 2**i
60
+ MCMD::warningLog("SSH CMDRUN RETRY(#{i+1}/#{@@retry_scp})")
61
+
62
+ }
63
+ MCMD::warningLog("ERROR by SSH ") unless sts
64
+ end
65
+
66
+ # バックグランド実行
67
+ def self.cmdRun_b(ip,uid,cmd,tag="" ,secret=nil)
68
+ sts = false
69
+ if secret then
70
+ sts = system("ssh -i #{secret} #{uid}@#{ip} 'nohup #{cmd}'")
71
+ else
72
+ sts = system("ssh #{uid}@#{ip} 'nohup #{cmd}'")
73
+ end
74
+ MCMD::warningLog("ERROR by SSH(nohub)") unless sts
75
+ end
76
+
77
+
78
+ #SCPファイル送信
79
+ def self.scp(ip,uid,from,to,secret=nil)
80
+ sts =false
81
+ unless File.file?(from) then
82
+ raise "File not found."
83
+ end
84
+ if to =~ /\/$/ then
85
+ cmdRun(ip,uid,"mkdir -p #{to}",secret)
86
+ else
87
+ cmdRun(ip,uid,"mkdir -p #{File.dirname(to)}",secret)
88
+ end
89
+ if secret then
90
+ @@retry_scp.times{|i|
91
+ sts = system("scp -i #{secret} -C #{from} #{uid}@#{ip}:#{to}")
92
+ break if sts
93
+ sleep 2**i
94
+ MCMD::warningLog("SCP SEND RETRY(#{i+1}/#{@@retry_scp})")
95
+ }
96
+ else
97
+ @@retry_scp.times{|i|
98
+ sts = system("scp -C #{from} #{uid}@#{ip}:#{to}")
99
+ break if sts
100
+ sleep 2**i
101
+ MCMD::warningLog("SCP SEND RETRY(#{i+1}/#{@@retry_scp})")
102
+ }
103
+ end
104
+ MCMD::warningLog("send ERROR by scp") unless sts
105
+ end
106
+
107
+
108
+ #Ftpファイル送信
109
+ def self.ftp(ip,uid,from,to,secret)
110
+ sts =false
111
+ unless File.file?(from) then
112
+ raise "File #{from} not found. "
113
+ end
114
+ if to =~ /\/$/ then
115
+ cmdRun(ip,uid,"mkdir -p #{to}")
116
+ else
117
+ cmdRun(ip,uid,"mkdir -p #{File.dirname(to)}")
118
+ end
119
+ temp=MCMD::Mtemp.new
120
+ fn = temp.file
121
+ File.open("#{fn}","w"){|fw|
122
+ fw.puts "open #{ip}"
123
+ fw.puts "user #{uid} #{secret}"
124
+ fw.puts "prompt"
125
+ fw.puts "bi"
126
+ fw.puts "put #{from} #{to}"
127
+ fw.puts "bye"
128
+ }
129
+
130
+ @@retry_scp.times{
131
+ sts = system("ftp -n < #{fn} > /dev/null")
132
+ #sts = system("ftp -n < #{fn} ")
133
+ break if sts
134
+ sleep 2**i
135
+ MCMD::warningLog("FTP SEND RETRY(#{i+1}/#{@@retry_scp})")
136
+ }
137
+ MCMD::warningLog("send ERROR by ftp") unless sts
138
+ end
139
+
140
+ def self.send(ip,uid,from,to,secret)
141
+ if @@ftpUse then
142
+ ftp(ip,uid,from,to,secret)
143
+ else
144
+ scp(ip,uid,from,to)
145
+ end
146
+ end
147
+
148
+
149
+
150
+
151
+
152
+ #SCPファイル受信
153
+ def self.scp_r(ip,uid,from,to,secret=nil)
154
+ if to =~ /\/$/ then
155
+ system("mkdir -p #{to}")
156
+ else
157
+ system("mkdir -p #{File.dirname(to)}")
158
+ end
159
+ from.each{|fn|
160
+ if secret then
161
+ system("scp -i #{secret} -C #{uid}@#{ip}:#{fn} #{to}> /dev/null")
162
+ else
163
+ system("scp -C #{uid}@#{ip}:#{fn} #{to} > /dev/null")
164
+ end
165
+ }
166
+ end
167
+
168
+ #ftpファイル受信
169
+ #
170
+ #MCMD::NetTools.ftp_r(ip,pcinfo[ip][0],path.addSuffix("/#{fn[i]}"),dicName,pcinfo[ip][1])
171
+
172
+ def self.ftp_r(ip,uid,from,to,secret)
173
+ tod = to
174
+ if to =~ /\/$/ then
175
+ system("mkdir -p #{to}")
176
+ else
177
+ system("mkdir -p #{File.dirname(to)}")
178
+ tod = File.dirname(to)
179
+ end
180
+ temp=MCMD::Mtemp.new
181
+ fn = temp.file
182
+ File.open("#{fn}","w"){|fw|
183
+ fw.puts "open #{ip}"
184
+ fw.puts "user #{uid} #{secret}"
185
+ fw.puts "prompt"
186
+ fw.puts "lcd #{tod}"
187
+ fw.puts "bi"
188
+ from.each{|fr|
189
+ fw.puts "cd #{File.dirname(fr)}"
190
+ fw.puts "mget #{File.basename(fr)}"
191
+ }
192
+ fw.puts "bye"
193
+ }
194
+ @@retry_scp.times{|i|
195
+ sts = system("ftp -n < #{fn} > /dev/null")
196
+ break if sts
197
+ sleep 2**i
198
+ MCMD::warningLog("FTP RECV RETRY(#{i+1}/#{@@retry_scp})")
199
+ }
200
+ end
201
+
202
+ def self.recv(ip,uid,from,to,secret)
203
+ if @@ftpUse then
204
+ ftp_r(ip,uid,from,to,secret)
205
+ else
206
+ scp_r(ip,uid,from,to)
207
+ end
208
+ end
209
+
210
+
211
+ end
212
+ end
213
+
214
+
215
+ if __FILE__ == $0 then
216
+
217
+ MCMD::NetTools.scp("192.168.4.212","nysol","mtemp.rb","/tmp/xxxa")
218
+ MCMD::NetTools.cmdRun("192.168.4.212","nysol","cd /tmp; ls -l xxxa")
219
+
220
+ end
@@ -0,0 +1,359 @@
1
+ #!/usr/bin/env ruby
2
+ #/* ////////// LICENSE INFO ////////////////////
3
+ #
4
+ # * Copyright (C) 2013 by NYSOL CORPORATION
5
+ # *
6
+ # * Unless you have received this program directly from NYSOL pursuant
7
+ # * to the terms of a commercial license agreement with NYSOL, then
8
+ # * this program is licensed to you under the terms of the GNU Affero General
9
+ # * Public License (AGPL) as published by the Free Software Foundation,
10
+ # * either version 3 of the License, or (at your option) any later version.
11
+ # *
12
+ # * This program is distributed in the hope that it will be useful, but
13
+ # * WITHOUT ANY EXPRESS OR IMPLIED WARRANTY, INCLUDING THOSE OF
14
+ # * NON-INFRINGEMENT, MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE.
15
+ # *
16
+ # * Please refer to the AGPL (http://www.gnu.org/licenses/agpl-3.0.txt)
17
+ # * for more details.
18
+ #
19
+ # ////////// LICENSE INFO ////////////////////*/
20
+ require "nysol/mtemp"
21
+ require "nysol/mnettools"
22
+ require "nysol/mrubyparse"
23
+ require "nysol/mparallelmanager"
24
+ $FtpUSE=true
25
+
26
+ class Array
27
+
28
+ # データ収集
29
+ # fn 集めるファイル名 out 出力先 nFlg:項目名無しFLG
30
+ # outの最後が"/"でない場合は1ファイルと見なす
31
+ # 配列にはデータがあるip,pathとが含まれている
32
+ # [ [ip1,path1],[ip2,path2] ...,[ipn,pathn]]
33
+ # データ量によっては端末ごとにcat&圧縮した方が高速化できるかも
34
+ def mcollect(fn,out,nFlg=false,pclist="/etc/pclist")
35
+ fn = [fn] if fn.class != Array
36
+ out = [out] if out.class != Array
37
+ raise "no match size in-out " if fn.size != out.size
38
+
39
+ temp=MCMD::Mtemp.new
40
+ params=self.dup
41
+
42
+ # PC_LIST読み込み
43
+ pcM = MCMD::MpcManager.new(pclist)
44
+
45
+ # ip毎に配列集約
46
+ dlist ={}
47
+ params.each{|ip,path|
48
+ raise "unknown ip " unless pcM.has_IP?(ip)
49
+ dlist[ip] = [] unless dlist.has_key?(ip)
50
+ dlist[ip] << path
51
+ }
52
+
53
+ (0...fn.size).each{|i|
54
+ type = out[i] =~ /\/\s*$/ ? 0 : 2
55
+ type += 1 if dlist.size != 0
56
+
57
+ #パラメータセット
58
+ nfr = "/#{fn[i]}"
59
+ nrev = out[i]
60
+ lcin = fn[i]
61
+ to = out[i]
62
+ if type == 3 then
63
+ nrev = "#{temp.file}/"
64
+ lcin = "#{nrev}*"
65
+ end
66
+
67
+ # collet
68
+ dlist.each{|ip,path|
69
+ MCMD::NetTools.recv(ip,pcM.getUIDbyIP(ip),path.maddSuffix(nfr),nrev,pcM.getPWDbyIP(ip))
70
+ }
71
+ case type
72
+ when 0 #出力ディレクトリ(local)
73
+ MCMD::mkDir(to,true)
74
+ system "cp #{lcin} #{to}"
75
+ when 2,3 #出力ファイル (local)
76
+ if nFlg then
77
+ system "mcat i=#{lcin} o=#{to} -nfn"
78
+ else
79
+ system "mcat i=#{lcin} o=#{to}"
80
+ end
81
+ end
82
+ }
83
+ end
84
+
85
+ # 並列処理each
86
+ def meach(mpCount=4,msgcnt=100,tF=false,&block)
87
+ tim = tF ? 5 : -1
88
+ params=self.dup
89
+ ttl = params.size
90
+ nowcnt = 0
91
+ mpm = MCMD::MparallelManager.new(mpCount,tim)
92
+ mpm.runStateCheker
93
+
94
+ while params.size>0
95
+ param=params.delete_at(0)
96
+ nowlane = mpm.getLane
97
+ # blockの実行
98
+ pid=fork {
99
+ case block.arity
100
+ when 1
101
+ yield(param)
102
+ when 2
103
+ yield(param,nowcnt)
104
+ when 3
105
+ yield(param,nowcnt,nowlane)
106
+ else
107
+ raise "unmatch args size."
108
+ end
109
+ }
110
+ nowcnt+=1
111
+ MCMD::msgLog("meach start #{param} (#{nowcnt}/#{ttl})") if msgcnt!=0 and nowcnt%msgcnt == 0
112
+ mpm.addPid(pid,nowlane)
113
+ end
114
+ mpm.waitall
115
+ return []
116
+ end
117
+
118
+ def meachc(mpInfo=[4,4],msgcnt=100,pclist="/etc/pclist",bg=true,&block)
119
+ # -----------------------------------------------------
120
+ # pc情報設定 & 並列数決定
121
+ # -----------------------------------------------------
122
+ pcM = MCMD::MpcManager.new(pclist)
123
+ mpPC = mpLim = 4
124
+ if mpInfo.class == Array then
125
+ mpPC = mpInfo[0] if mpInfo[0]
126
+ mpLim = mpInfo[1] if mpInfo[1]
127
+ else
128
+ mpPC = mpInfo
129
+ end
130
+ mpPC = pcM.pcCount if mpPC > pcM.pcCount
131
+ mpMax = mpPC * mpLim
132
+
133
+ # -----------------------------------------------------
134
+ # 呼び出し元ファイル & ローカル変数取得
135
+ # -----------------------------------------------------
136
+ fn ,lin = block.source_location
137
+ value = block.binding.eval("local_variables")
138
+ valueV=[]
139
+ value.each{|v|
140
+ clsinfo = block.binding.eval("#{v}.class")
141
+ case clsinfo.to_s
142
+ when "String"
143
+ valinfo = block.binding.eval("#{v}")
144
+ valueV << "#{v} = \"#{valinfo}\""
145
+ when "Fixnum","Bignum","Float"
146
+ valinfo = block.binding.eval("#{v}")
147
+ valueV << "#{v} = #{valinfo}"
148
+ when "Array"
149
+ valinfo = block.binding.eval("#{v}")
150
+ valueV << "#{v} = #{valinfo}"
151
+ end
152
+ }
153
+
154
+ # -----------------------------------------------------
155
+ # 並列用プログラム生成
156
+ # -----------------------------------------------------
157
+ tempC=MCMD::Mtemp.new
158
+ runspf=tempC.file
159
+ MCMD::MrubyParse.new(fn,lin,"meachc",valueV).output(runspf)
160
+
161
+ # -----------------------------------------------------
162
+ # 作業ディレクトリ決定
163
+ # -----------------------------------------------------
164
+ local_WkD = tempC.file
165
+ net_WkD = tempC.file
166
+ MCMD::mkDir(local_WkD)
167
+
168
+ # -----------------------------------------------------
169
+ # 並列処理
170
+ # -----------------------------------------------------
171
+ params=self.dup
172
+ mpm = MCMD::MparallelManagerByFile.new(mpMax,local_WkD)
173
+ ttl = params.size
174
+ nowcnt = 0
175
+ rtnlist =[]
176
+
177
+ while params.size>0
178
+
179
+ param=params.delete_at(0)
180
+ nowlane = mpm.getLane
181
+
182
+ # blockの実行
183
+ pid=fork {
184
+
185
+ stNo = nowlane%mpPC
186
+ param = [param] if param.class != Array
187
+ # -----------------------------------------------------
188
+ # 起動スクリプト生成
189
+ # -----------------------------------------------------
190
+ runinit_Scp = "#{local_WkD}/#{File.basename(runspf)}_#{nowlane}.sh"
191
+ net_nowwkD = "#{net_WkD}/#{nowcnt}"
192
+ File.open(runinit_Scp,"w"){|fpw|
193
+ fpw.puts "cd #{net_nowwkD}"
194
+ case block.arity
195
+ when 1
196
+ fpw.puts "ruby #{File.basename(runspf)} #{param.join(",")}"
197
+ when 2
198
+ fpw.puts "ruby #{File.basename(runspf)} #{param.join(",")} #{nowcnt}"
199
+ when 3
200
+ fpw.puts "ruby #{File.basename(runspf)} #{param.join(",")} #{nowcnt} #{nowlane}"
201
+ else
202
+ raise "unmatch args size."
203
+ end
204
+ fpw.puts "echo pgmend #{nowcnt} >> #{net_nowwkD}/endlog"
205
+ fpw.puts "ls -lR >> #{net_nowwkD}/endlog"
206
+ fpw.puts "msend.rb i=#{net_nowwkD}/endlog uid=#{pcM.getUID(stNo)} o=#{pcM.localIP}:#{local_WkD}/#{nowlane}.log"
207
+ }
208
+
209
+ # -----------------------------------------------------
210
+ # スクリプトファイル&データ転送
211
+ # -----------------------------------------------------
212
+ MCMD::msgLog("meachc snddata #{fn}:#{lin} (#{nowcnt}/#{ttl})") if msgcnt!=0 and nowcnt%msgcnt == 0
213
+ distSrc = "#{net_nowwkD}/#{File.basename(runspf)}"
214
+ distSrcI = "#{net_nowwkD}/#{File.basename(runspf)}.sh"
215
+ MCMD::NetTools.send(pcM.getIP(stNo),pcM.getUID(stNo),runinit_Scp,distSrcI,pcM.getPWD(stNo))
216
+ MCMD::NetTools.send(pcM.getIP(stNo),pcM.getUID(stNo),runspf ,distSrc ,pcM.getPWD(stNo))
217
+ param.each{|dt|
218
+ MCMD::NetTools.send(pcM.getIP(stNo),pcM.getUID(stNo),dt,"#{net_nowwkD}/#{dt}",pcM.getPWD(stNo))
219
+ }
220
+
221
+ # -----------------------------------------------------
222
+ # プログラム実行
223
+ # -----------------------------------------------------
224
+ MCMD::msgLog("meachc pgmstart #{fn}:#{lin} (#{nowcnt}/#{ttl})") if msgcnt!=0 and nowcnt%msgcnt == 0
225
+ MCMD::NetTools.cmdRun(pcM.getIP(stNo),pcM.getUID(stNo),"nohup bash #{distSrcI} 1> #{net_nowwkD}/RunLog 2>&1 &")
226
+ }
227
+ rtnlist << [ pcM.getIP(nowlane%mpPC),"#{net_WkD}/#{nowcnt}" ]
228
+ mpm.addNo(nowcnt,nowlane)
229
+ nowcnt+=1
230
+ Process.detach(pid)
231
+
232
+ end
233
+ mpm.waitall
234
+ return rtnlist
235
+ end
236
+
237
+
238
+ def meachcN(mpInfo=[4,4],msgcnt=100,pclist="/etc/pclist",bg=true,&block)
239
+ # -----------------------------------------------------
240
+ # pc情報設定 & 並列数決定
241
+ # -----------------------------------------------------
242
+ pcM = MCMD::MpcManager.new(pclist)
243
+ mpPC = mpLim = 4
244
+ if mpInfo.class == Array then
245
+ mpPC = mpInfo[0] if mpInfo[0]
246
+ mpLim = mpInfo[1] if mpInfo[1]
247
+ else
248
+ mpPC = mpInfo
249
+ end
250
+ mpPC = pcM.pcCount if mpPC > pcM.pcCount
251
+ mpMax = mpPC * mpLim
252
+
253
+ # -----------------------------------------------------
254
+ # 呼び出し元ファイル & ローカル変数取得
255
+ # -----------------------------------------------------
256
+ fn ,lin = block.source_location
257
+ value = block.binding.eval("local_variables")
258
+ valueV=[]
259
+ value.each{|v|
260
+ clsinfo = block.binding.eval("#{v}.class")
261
+ case clsinfo.to_s
262
+ when "String"
263
+ valinfo = block.binding.eval("#{v}")
264
+ valueV << "#{v} = \"#{valinfo}\""
265
+ when "Fixnum","Bignum","Float"
266
+ valinfo = block.binding.eval("#{v}")
267
+ valueV << "#{v} = #{valinfo}"
268
+ when "Array"
269
+ valinfo = block.binding.eval("#{v}")
270
+ valueV << "#{v} = #{valinfo}"
271
+ end
272
+ }
273
+
274
+ # -----------------------------------------------------
275
+ # 並列用プログラム生成
276
+ # -----------------------------------------------------
277
+ tempC=MCMD::Mtemp.new
278
+ runspf=tempC.file
279
+ MCMD::MrubyParse.new(fn,lin,"meachcN",valueV).output(runspf)
280
+
281
+ # -----------------------------------------------------
282
+ # 作業ディレクトリ決定
283
+ # -----------------------------------------------------
284
+ local_WkD = tempC.file
285
+ net_WkD = tempC.file
286
+ net_HMD = ENV['PWD'].sub(/#{ENV['HOME']}\//,"")
287
+ MCMD::mkDir(local_WkD)
288
+
289
+ # -----------------------------------------------------
290
+ # 並列処理
291
+ # -----------------------------------------------------
292
+ params=self.dup
293
+ mpm = MCMD::MparallelManagerByFile.new(mpMax,local_WkD)
294
+ ttl = params.size
295
+ nowcnt = 0
296
+ rtnlist =[]
297
+
298
+ while params.size>0
299
+
300
+ param=params.delete_at(0)
301
+ nowlane = mpm.getLane
302
+
303
+ # blockの実行
304
+ pid=fork {
305
+
306
+ stNo = nowlane%mpPC
307
+ param = [param] if param.class != Array
308
+ # -----------------------------------------------------
309
+ # 起動スクリプト生成
310
+ # -----------------------------------------------------
311
+ runinit_Scp = "#{local_WkD}/#{File.basename(runspf)}_#{nowlane}.sh"
312
+ net_nowwkD = "#{net_WkD}/#{nowcnt}"
313
+ distSrc = "#{net_nowwkD}/#{File.basename(runspf)}"
314
+ distSrcI = "#{net_nowwkD}/#{File.basename(runspf)}.sh"
315
+
316
+
317
+ File.open(runinit_Scp,"w"){|fpw|
318
+ fpw.puts "mkdir -p #{net_HMD}"
319
+ fpw.puts "cd #{net_HMD}"
320
+ case block.arity
321
+ when 1
322
+ fpw.puts "ruby #{distSrc} #{param.join(",")}"
323
+ when 2
324
+ fpw.puts "ruby #{distSrc} #{param.join(",")} #{nowcnt}"
325
+ when 3
326
+ fpw.puts "ruby #{distSrc} #{param.join(",")} #{nowcnt} #{nowlane}"
327
+ else
328
+ raise "unmatch args size."
329
+ end
330
+ fpw.puts "echo pgmend #{nowcnt} >> #{net_nowwkD}/endlog"
331
+ fpw.puts "ls -lR >> #{net_nowwkD}/endlog"
332
+ fpw.puts "msend.rb i=#{net_nowwkD}/endlog uid=#{pcM.getUID(stNo)} o=#{pcM.localIP}:#{local_WkD}/#{nowlane}.log"
333
+ }
334
+
335
+ # -----------------------------------------------------
336
+ # スクリプトファイル&データ転送
337
+ # -----------------------------------------------------
338
+ MCMD::msgLog("meachcN snddata #{fn}:#{lin} (#{nowcnt}/#{ttl})") if msgcnt!=0 and nowcnt%msgcnt == 0
339
+ MCMD::NetTools.send(pcM.getIP(stNo),pcM.getUID(stNo),runinit_Scp,distSrcI,pcM.getPWD(stNo))
340
+ MCMD::NetTools.send(pcM.getIP(stNo),pcM.getUID(stNo),runspf ,distSrc ,pcM.getPWD(stNo))
341
+
342
+ # -----------------------------------------------------
343
+ # プログラム実行
344
+ # -----------------------------------------------------
345
+ MCMD::msgLog("meachcN pgmstart #{fn}:#{lin} (#{nowcnt}/#{ttl})") if msgcnt!=0 and nowcnt%msgcnt == 0
346
+ MCMD::NetTools.cmdRun(pcM.getIP(stNo),pcM.getUID(stNo),"nohup bash #{distSrcI} 1> #{net_nowwkD}/RunLog 2>&1 &")
347
+ }
348
+ rtnlist << [ pcM.getIP(nowlane%mpPC),"#{net_WkD}/#{nowcnt}" ]
349
+ mpm.addNo(nowcnt,nowlane)
350
+ nowcnt+=1
351
+ Process.detach(pid)
352
+
353
+ end
354
+ mpm.waitall
355
+ return rtnlist
356
+ end
357
+
358
+
359
+ end