Logging Console Output

Edit: Some links no longer work.

Originally posted November 27, 2013 on AIXchange

If you want to log your console output so you have a record of the commands you’re running, I can think of a few ways to accomplish this. One is to login and use the script command:

            “The script command makes a typescript of everything displayed on your terminal. The typescript is written to the file specified by the File parameter. The typescript can later be sent to the line printer. If no file name is given, the typescript is saved in the current directory with the file name typescript.

            “The script ends when the forked shell exits.

            “This command is useful for producing hard-copy records when hard-copy terminals are in short supply. For example, use the script command when you are working on a CRT display and need a hard-copy record of the dialog.”

Another option is to set up logging in PuTTY, connect to the HMC over ssh and run vtmenu or run mkvterm:

            “Being someone who does implementation services, I want to always be sure about what I do, what I did and what affect it had. So keeping logs of every time I connect to any device is very important to me. I want to be able to go back in time to any point at any client I have ever worked with (and here are some other putty tricks to try)…”

And here’s a review of 10 native PuTTY tips.

Perhaps though you’re just using the vanilla Java console session on the HMC. In that case, this method should work:

            “Command line access to the HMC through SSH is required. You can enable this from the HMC console or through remote WebSM.

            “Once you are logged in:

            Click HMC Maintenance -> System Configuration -> Enable/Disable Remote Command *Execution, check the SSH box.

            Next, click Enable/Disable Remote Virtual Terminals, check the box for Enable.

            1. Open a vterm window to the LPAR. Look at the left side of the title bar to get the vterm string, which will be in the form:

                        Partition number*Machine type-Model*Serial number

            2. From an SSH session on the HMC, create an empty file in /tmp with the vterm string as the filename. In this example:

            3. $ touch /tmp/004*7040-681*020153A (Note: The serial number in the filename is case sensitive. It must match the string from the vterm title bar exactly.)

            4. Close the vterm, then open it back up and proceed with troubleshooting (activate the LPAR, etc.).

            5. As soon as the LPAR outputs information to the vterm window, check the size of the file in /tmp on the HMC and verify that it has been written to.

            6. If it has not been written to, double check the name of the file against the title bar. If they match, try performing a Close Terminal Connection operation to force it closed, then open it again. This should cause it to start logging to the file.

            7. When logging is no longer needed, close the vterm. Send the output of the file in /tmp on the HMC to your remote Support Center. Next, remove the file from /tmp, if you fail to do so, it will log everything written to the vterm whenever a vterm window is opened. And you will inadvertently fill up /var on the HMC at some point in the future.

            (Note: In an SP environment, use s1term <frame#> <slot#> | tee <logfile> instead. )

            “This is documented in the “HMC Installation and Operations Guide: Appendix D:Using scripts to connect remotely.”

Do you use one of these methods to log console output when you are working on machines, or do you prefer another way?

More Twitter discussion from @robmcnelly:

@mr_nmon After RHEL6.4 install on Power, only took 5 mins as root to get #PowerVC running. Any good #AIX admin user can do it. Writing my hints now.

@sql_handle #IBMPower #AIX sql.sasquatch track – Things Fall Apart: Again my Turn to Win Some or Learn Some http://bit.ly/IhdimK

@LindaGrigoleit #powersystems Academic Initiative is going strong and growing http://bit.ly/1ffbE3r #ibmi #aix #powerlinux #ibmacademicinitiative

RT @cgibbo PowerHA & mountguard via @wmduszyk http://www.wmduszyk.com/?p=10643&langswitch_lang=en … #AIX #PowerHA

@cgibbo LPM and viosecure.

 https://www.ibm.com/developerworks/community/blogs/cgaix/entry/lpm_and_viosecure?lang=en … #AIX #PowerVM

@brian_smi Little Known Feature in #SMIT Install Software Screen on #AIX https://www.ibm.com/developerworks/community/blogs/brian/entry/little_known_feature_in_smit_install_software_screen …

@mr_nmon #PowerVC 1.2 hands-on demo video by Greg Hintermeister showing the new wave of #PowerSystems LPAR management http://www.youtube.com/watch?v=RFTbC6JW7YE&feature=em-uploademail