Hi All - I need your help with a AIX script
The outpour of this script will then need to pulled into a HPUX server (I have a for loop here to pull the data for many servers) and further emailed to me.
Oslevel AIX 6.1
I wrote a script in AIX. To output the topas –M (top in HPUX) into a flat file.
But when I more or vi or view the file; it outputs which junk characters like below:
filetopasx (73%)
servername | TOPAS -M MEMORY USAGE
^[[0;10m^[(B^[[H^[[JTopas Monitor for host: servername Interval: 2 Sun
Aug 4 10:51:54 2013============================================================
====================REF1 SRAD TOTALMEM INUSE FREE FILECACHE HOMETHRD
S CPUS
--------------------------------------------------------------------------------
^[[2A^[[H^[[JTopas Monitor for host: cjdbo2c2 Interval: 2 Sun Aug 4
10:51:54 2013===================================================================
=============REF1 SRAD TOTALMEM INUSE FREE FILECACHE HOMETHRDS CPUS
--------------------------------------------------------------------------------
^[[2A^[[1;75H6
0 0 35.4G 34.5G 947.2 4315.0^[[7C289^[[6C12-15 20-23
^M 1 1 3486.0 3388.2 97.8 35.0^[[8C858^[[6C8-11 16-19
^M 2 2^[[7C0.0^[[6C0.0^[[6C0.0^[[6C0.0^[[10C2
cjdbo2c2 | TOPAS CPU USAGE
When I cat it, no issues.
Topas Monitor for host: servername Interval: 2 Sun Aug 4 10:51:56 2013================================================================================REF1 SRAD TOTALMEM INUSE FREE FILECACHE HOMETHRDS CPUS
--------------------------------------------------------------------------------
0 0 40.1G 34.5G 947.2 4315.0 289 12-15 20-23
1 1 4000.0 3388.2 97.8 35.0 858 8-11 16-19
The following is more or less my script
stty erase ^h intr '^?' -ixany ixoff ixon echoe
export TERM=aixterm
# export TERM=vt100
FILE=/tmp/filetopas
FILEX=/tmp/filetopasx
rm -f $FILE
rm -f $FILEX
touch $FILE
touch $FILEX
chmod 777 $FILE
chmod 777 $FILEX
(sleep 5; echo q)|topas -mM >> $FILE
sleep 2
echo `hostname` "| TOPAS -M MEMORY USAGE" >> $FILEX
cat $FILE | head -`cat $FILE | awk '/CPU/{print NR - 1}' | tail -1` >> $FILEX
sleep 2
Other things I have tried.
1. I have a feeling its an issue with the term. Current term=xterm. I have tried changing it to VT100 and aixterm but to no avail.
2. Or if there are any alternatives to topas-M. I have tried lssrad –av ; but it doesn’t come up with same exact values in topas-M
3. I even tried to use capture – which produced the output that I desired. But I am unable to write a script to parse the “any key” to continue and ^P to capture the screenshot. If there’s a way I wud appreciate it.
servername:/root:>capture
Capture command is started. The file is screen.out.
Use ^P to dump screen to file screen.out.
Press any key to continue
You are now emulating a vt100 terminal.
Press Any Key to continue.
4. Also tried to tee the output to a file same output
Appreciate if you have any ideas.
Thanks and Regards.,