ruby版

 #!/usr/bin/ruby -Ke
 #鍵登録
 `ssh-agent` =~ /SSH_AUTH_SOCK=([^;]+);.*SSH_AGENT_PID=([^;]+);/m
 ENV["SSH_AUTH_SOCK"],ENV["SSH_AGENT_PID"]=$1,$2
 `ssh-add ~/.ssh/id_rsa`
 #Signal.trap(2){`ssh-agent -k`} #ruby1.7以上だったとほほ
 at_exit{`ssh-agent -k`;STDERR.puts "#{Time.now.strftime("%Y/%m/%d %H:%m:%M")}に中断しました"}
 ### タイトル等
 command='ps ax|grep smbd|wc -l'
 file=File.open("/home/n9d/public_html/smb.csv","w")
 file.print '"Time"'
 1.upto(16){|i| file.print ",\"filesv#{sprintf("%02d",i)}\""}
 file.print "\n"
 ### 本体
 waittime=60*5
 while true
   timethread = Thread.new {
     sleeptime=(waittime-(Time.now.to_i%waittime))
 #    puts (Time.now.strftime("%Y/%m/%d %H:%M:%S"))
 #    puts (sleeptime)
     sleep(sleeptime)
   }
   mainthread = Thread.new {
     file.print "\"#{Time.now.strftime("%Y/%m/%d %H:%M:%S")}\""
     1.upto(16){|i|
       ans=`ssh filesv#{sprintf("%02d",i)}.oa2004.jjj.co.jp #{command}`
       file.print ",\"#{ans.chop.strip}\""
     }
     file.print "\n"
     file.flush
   }
   mainthread.join
   timethread.join
 end