Work with multiple SSH session by csshX

csshX is a tool to allow simultaneous control of multiple SSH sessions. csshX will attempt to create an SSH session to each remote host in separate Terminal.app windows. A master window will also be created. All keyboard input in the master will be sent to all the slave windows.

Download link: https://code.google.com/p/csshx/

An very simple example:

 csshx --login tester hostname1.com hostname2.com hostname3.com hostname4.com 

monitor CentOS Utility using Sar (may also work on MacOS)

This example is for monitoring the network traffic, for more commands, check “man sar”

  sar -n DEV 1  

This command will monitor the network traffic with time interval “1” second.

  sar -n DEV 1 3  

This command will monitor the network traffic with time interval “1” second and will quite after 3 seconds.

JMeter – Start DISTRIBUTED tests in non-GUI mode.

On the command line of master node of the distributed tests:

  • Use the -r command line and -Jremote_hosts={serverlist}
  • Use the -R command line option to specify the remote host(s) to use. E.g. jmeter -Rhost1,127.0.0.1,host2
e.g. sh jmeter.sh -n -t example.jmx -l xyzlog.log 
     -r -J10.0.0.1, 10.0.0.2

screenshot from official site:

Screen Shot 2013-12-02 at 2.48.26 PM

JMeter commands list:


        -h, --help
                print usage information and exit
        -v, --version
                print the version information and exit
        -p, --propfile 
                the jmeter property file to use
        -q, --addprop 
                additional JMeter property file(s)
        -t, --testfile 
                the jmeter test(.jmx) file to run
        -l, --logfile 
                the file to log samples to
        -j, --jmeterlogfile 
                jmeter run log file (jmeter.log)
        -n, --nongui
                run JMeter in nongui mode
        -s, --server
                run the JMeter server
        -H, --proxyHost 
                Set a proxy server for JMeter to use
        -P, --proxyPort 
                Set proxy server port for JMeter to use
        -N, --nonProxyHosts 
                Set nonproxy host list (e.g. *.apache.org|localhost)
        -u, --username 
                Set username for proxy server that JMeter is to use
        -a, --password 
                Set password for proxy server that JMeter is to use
        -J, --jmeterproperty =
                Define additional JMeter properties
        -G, --globalproperty =
                Define Global properties (sent to servers)
                e.g. -Gport=123
                 or -Gglobal.properties
        -D, --systemproperty =
                Define additional system properties
        -S, --systemPropertyFile 
                additional system property file(s)
        -L, --loglevel =
                [category=]level e.g. jorphan=INFO or jmeter.util=DEBUG
        -r, --runremote
                Start remote servers (as defined in remote_hosts)
        -R, --remotestart 
                Start these remote servers (overrides remote_hosts)
        -d, --homedir 
                the jmeter home directory to use
        -X, --remoteexit
                Exit the remote servers at end of test (non-GUI)

Create user account with JMeter and save the user information to a file(Save the extracted values to a file within JMeter)

Need to use JMeter-Plugins: https://code.google.com/p/jmeter-plugins

  • Step1: Setup normal HttpRequest sample to retrive the response which contains the user name/id/token information
  • Step2: Extract the values by BSF PostProcessor with Javascript(Refer another post for howto)
  • Step3:
    • Create a jp@gc- Dummy Sampler, the configuration should be like this:

Screen Shot 2013-06-10 at 5.07.18 PM

    •  Add a jp@gc – Flexible File Writer as a child, the configuration should be like this:

Screen Shot 2013-06-10 at 5.08.04 PM

    •  The hierarchy should be like this :

Screen Shot 2013-06-10 at 5.10.43 PM

Done! Should get the .csv file(defined in the file writer) like this after the test run:

Screen Shot 2013-06-10 at 5.13.01 PM

Very useful for creating custom log or save the user credentials for further tests.

Monitor tcpFlow log from Java Applicaiton

  • Things to do from Java side, use process to lunch the script/command and listen to the running log.
 public static void main(String args[]) {
   Process process;
 try {
     process = Runtime.getRuntime().exec("tail -f /tmp/moailog");
     InputStreamReader ir = new InputStreamReader(process.getInputStream());
     LineNumberReader input = new LineNumberReader(ir);
     String line;
     while ((line = input.readLine()) != null) {
          // strList.add(line);
           System.out.println("runnig log:" + line);
           }
    } catch (IOException e) {
      // TODO Auto-generated catch block
       e.printStackTrace();
    }
  }
  • Run tcpFlow command with sudo command and redirect the output to a file:
sudo tcpflow -Ce host youhostname > moailog
  • Done.

Objective-C in one page(continuing update)

Detailed Reference

String, Variable, Array and Dictionary

NSLog(@”hello, I am XY”);
NSString *firstName = @”Yan”;
NSLog(firstName);
NSLog(@”Hello there, %@.”, firstName);
NSLog(@”%@ %@”, firstName, firstName);
NSString *lastName = @”Xia”;
NSLog(@”%@ %@”, firstName, lastName);
NSNumber *age = @100
NSLog(@”%@ %@ is %@ years old”, firstName, lastName, age);
NSArray *apps = @[@”example1″, @”example2″, @”example3″];
NSDictionary *person = @{@”First Name”: @”Eric”};
NSDictionary *appRatings = @{@”AngryFowl”: @3, @”Lettertouch”: @5};
NSLog(@”%@”, appRatings[@”AngryFowl”]);
Continue reading