2 Replies Latest reply on Nov 25, 2014 6:02 AM by Mikhail Tal

    TMART x Linux

    Flavio Bonacordi

      Hi Community,

       

      This can be a silly question... but I would like to know if TMART is capable of run a script that will actually use a Linux session and perform a simple GREP command and read the last digits of the line...

       

      I know how to deal with the reading part.. but my questions is... Can TMART open a Linux session? Can I record this kind of thing?

        • 1. Re: TMART x Linux
          Hal DeVore

          Hi, Flavio.

           

          The answer is: maybe.

           

          Among the types of scripts that TM ART can record and playback are Telnet terminal emulators.  If you can connect to the Linux system via a telnet program from a Windows system running the Workbench and Recorder, then you might have some success.  This will work best if the telnet program is a very old-fashioned line more client.  Programs that emulate any kind of full screen terminal tend to clutter up the datastream making it hard to get just the bits you want.

           

          Note that SSH-based connections cannot be recorded.  Unlike HTTPS, SSH can't be abused to allow a man-in-the-middle so there's no way for the Recorder to grab unencrypted traffic.

           

          --Hal

          • 2. Re: TMART x Linux
            Mikhail Tal

            Hi,

             

            I've done that using the Plink executable, which is part of Putty tools. In the below example, C:\plinkdata.txt contains the commands I want to run. So that is where you'd put your "grep" command etc. For the purpose of the simple test below, the command in my file is just "w", and from the response I verify the string "load average". Note that I'm also using a separate command with "echo y" for the first time the script is run on an Execution Server, which emulates pressing "y" for accepting the server host key. There might be a more eloquent way of handling that, but this method works fine nonetheless.

             

            ***

             

            benchmark SSHLoadtest

            use "kernel.bdh"
            use "MeasureBounds.bdh"

            dclrand

            dcluser
              user
                VUser
              transactions
                TInit           : begin;
                TMain           : 1;
               
            dcltrans

            transaction TInit
              begin
                InitMeasureBounds();
            end TInit;

            transaction TMain

            const
            CONST_TIMEOUT := 120;

            var
            hFile : number;
            hProcessId : number;
            sDataDir : string;
            sResultDir : string;
            sStdout : string;
            sStderr : string;
            sData :string;

            begin
            GetDirectory(DIRECTORY_RESULT, sResultDir, sizeof(sResultDir));

            //Suppress FOpen warnings on using absolute paths
            ErrorAdd(FACILITY_RESERR, 1014, SEVERITY_INFORMATIONAL);

            sStdout := sResultDir+"Stdout.txt";
            sStderr := sResultDir+"Stderr.txt";
            Print(sStdout);
            Print(sStderr);

            FOpen(hFile, sStdout, OPT_FILE_ACCESS_READWRITE, OPT_FILE_CREATE);
            FClose(hFile);

            //The below section is only required for the first time execution server run, can be commented out afterwards
            /*
            hProcessId := ProcessInitialize("cmd /c", PROCESS_ATTACHED, " echo y | C:\\Windows\\plink.exe -ssh *HOST_IP* -l root -pw *PASSWORD* exit", "", sStdout, sStdErr, CONST_TIMEOUT);
            ProcessSetStdInFile(hProcessId, sStdout);
            ProcessStart(hProcessId);
            ProcessFree(hProcessId);
            */

            hProcessId := ProcessInitialize("C:\\Windows\\plink.exe", PROCESS_ATTACHED, " -ssh  -v *HOST_IP* -l root -pw *PASSWORD* -m C:\\plinkdata.txt", "", sStdout, sStdErr, CONST_TIMEOUT);
            ProcessSetStdInFile(hProcessId, sStdout);
            ProcessStart(hProcessId);
            ProcessFree(hProcessId);

            FOpen(hFile, sStdout, OPT_FILE_ACCESS_READWRITE, OPT_FILE_OPENCREATE);
            FRead(hFile, sData, 200);

                if not FFindString(hFile, "load average") then
                  MeasureInc("Av_Application node unavailable");
                end;

            FClose(hFile);
            Print(sData);

            end TMain;

             

            ***