Here’s a simple Ruby script that will parse a remote GC log using Perl for specific date time entries. The scenario in which you might use this script is where you have rather large remote GC logs sitting on another platform like AIX that doesn’t have Ruby installed. It’s useful in the sense you can execute a load test, then just parse the GC log for the entries from the native_stderr.log that represent your test run. YMMV.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 | # notes: make sure you escape slashes and quotes in the regex # libs: you will need to install SSH libraries for Ruby from DOS # set HTTP_PROXY=http://username:password@proxy.local:80 # gem install net-ssh # gem install net-sftp require 'net/ssh' require 'net/sftp' @HOST = "remote.host" @USER = "username" @PASS = "********" @PATH = "/opt/websphere/portalserver/6.0/portalserver/native_stderr.log" @SDATE = "Aug 11 10:0\\d+" @EDATE = "Aug 11 11:0\\d+" Net::SSH.start(@HOST, @USER, :password => @PASS) do |ssh| # parse log ssh.exec "perl -e ' open(I, \"< #{@PATH}\"); open(O, \"> /tmp/native_stderr.log\"); while(<i>) { $found = 1 if /#{@SDATE}/; $found = 0 if /#{@EDATE}/; print O $_ if $found > 0; } close(I); close(O)'" end Net::SFTP.start(@HOST, @USER, :password => @PASS) do |sftp| # download the truncated log sftp.download!("/tmp/native_stderr.log", "C:/native_stderr.log") end |
