#!/bin/sh

# This shell script uses nmon to gather aix data.
#
# FROM NMON
#
# When you are capturing data to a file, the nmon tool disconnects from
# the shell to ensure that it continues running even if you log out. 
# This means that nmon can appear to crash, but it is still running in
# the background.
# 
# d) If you want to pipe nmon output to other commands use a
#    FIFO:
#    mkfifo /tmp/mypipe
#    nmon -F /tmp/mypipe &
#    grep /tmp/mypipe
#
# nmon parameters
#
#    -f            spreadsheet output format [note: default -s300 -c288]
#                  output file is <hostname>_YYYYMMDD_HHMM.nmon
#    -F <filename> same as -f but user supplied filename
#    -s <seconds>  between snap shots
#    -c <number>   of refreshes
#

# -------------------------------------------------------------
# DEFAULT VALUES ----------------------------------------------
# -------------------------------------------------------------
TMPFILE="/tmp/sga.$$"               # Will write nmon data 
RUNFILE="/usr/local/nmon/nmon"      # Executable nmon file

if ! test -x "$RUNFILE"; then
  echo "Erro: $RUNFILE nao existe." 
  exit
fi

mkfifo $TMPFILE
$RUNFILE -F $TMPFILE -c1 -s0 &
cat $TMPFILE
\rm -f $TMPFILE
