1) Download the correct binary
1.1) Find out your S.O. and CPU processor version
1.2) Download Nmon Analyzer SpreadSheet
- http://www.ibm.com/developerworks/aix/library/au-nmon_analyser/
- http://www.ibm.com/developerworks/wikis/download/attachments/53871868/nmon_analyser.zip?version=16
- MyPersonalRepository (freezed on version 3.4.a )
1.3) Donwload
$ cd /opt$ mkdir /opt
$ mkdir /opt/nmon
$ cd /opt/nmon
$ wget http://nmon.sourceforge.net/docs/nmon_x86_12a.zip #RedHat
$ wget http://sourceforge.net/projects/nmon/files/nmon_x86_ubuntu1004 #Ubuntu
$ unzip nmon_x86_12a.zip
$ chmod 777 nmon_x86*
1.4) Build a symbolic link to appropriated SO version of nmon in system path
$ echo $PATH$ ln -s /opt/nmon/nmon_x86_rhel45 /usr/sbin/nmon # RedHat
$ ln -s /opt/nmon/nmon_x86_ubuntu810 /usr/sbin/nmon # Ubuntu
1.5) Test if nmon is working properly
$ nmon2) Create and configure nmon script to capture SpreadSheet format
2.1) Create nmon scripts
$ vim /root/nmon_spreadsheet.sh# file : nmon_spreadsheet.sh
# author: Josemar Silva
# obs : run nmon in background and capture output to spreadsheet
#
#
echo $0 $1 $CURRENT_DATETIME
#
# Chechking parameters ...
#
MODE=weekly #default
if [ "$1" = "-d" ]; then
MODE=dayly
elif [ "$1" = "-w" ]; then
MODE=weekly
elif [ "$1" = "-m" ]; then
MODE=monthly
else
echo "usage: $0 \<mode\>"
echo -e "mode:"
echo -e "\t -d: dayly - refresh every 5 min until end of current day (process)"
echo -e "\t -w: weekly - refresh every 15 min until end of current week"
echo -e "\t -m: montly - refresh every 60 min until end of current month"
exit 1
fi
#
# Setting up options ...
#
echo "Setting Up options - Mode($MODE)..."
PATH=$PATH:/usr/sbin:/usr/bin
CURRENT_DATETIME=`date +"%D %R"`
DAY_OF_WEEK_TODAY=$(date +%u)
DAYS_REMAINING_WEEK=$(expr 7 - $DAY_OF_WEEK_TODAY)
CURRENT_HOUR=$(date +%H)
CURRENT_DAY=$(date +%d)
CURRENT_MONTH=$(date +%m)
CURRENT_LASTDAYOFMONTH=31
if [ $CURRENT_MONTH -eq 2 ]; then
CURRENT_LASTDAYOFMONTH=28
elif [ $CURRENT_MONTH -eq 4 ] || [ $CURRENT_MONTH -eq 6 ] || [ $CURRENT_MONTH -eq 9 ] || [ $CURRENT_MONTH -eq 11 ] ; then
CURRENT_LASTDAYOFMONTH=30
else
CURRENT_LASTDAYOFMONTH=31
fi
HOURS_REMAINING_DAY=$(expr 24 - $CURRENT_HOUR)
DAYS_REMAINING_MONTH=$(expr $CURRENT_LASTDAYOFMONTH - $CURRENT_DAY)
REMAINING_DAYLY=$(expr $HOURS_REMAINING_DAY)
REMAINING_WEEKLY=$(expr 24 \* $DAYS_REMAINING_WEEK + $HOURS_REMAINING_DAY )
REMAINING_MONTHLY=$(expr 24 \* $DAYS_REMAINING_MONTH + $HOURS_REMAINING_DAY )
NMON_LOG_ROOT_PATH=/var/log/nmon/
#
# Create log directory ...
#
echo "Checking log directory ..."
if [ ! -d "$NMON_LOG_ROOT_PATH" ]; then
mkdir $NMON_LOG_ROOT_PATH
fi
if [ ! -d "$NMON_LOG_ROOT_PATH$MODE" ]; then
mkdir $NMON_LOG_ROOT_PATH$MODE
fi
#
# Changing Current Directory to Log ...
#
NMON_LOG_PATH=$NMON_LOG_ROOT_PATH$MODE
echo "Changing Current directory to $NMON_LOG_PATH ..."
cd $NMON_LOG_PATH
#
# Set command line ...
#
echo "Setting up command line ..."
if [ "$1" = "-d" ]; then
NMON_COMMAND_LINE='nmon -f -s 300 -t -c '$(expr $REMAINING_DAYLY \* 12 )
elif [ "$1" = "-w" ]; then
NMON_COMMAND_LINE='nmon -f -s 900 -c '$(expr $REMAINING_WEEKLY \* 4)
else
NMON_COMMAND_LINE='nmon -f -s 3600 -c '$(expr $REMAINING_MONTHLY)
fi
#
# Excute nmon command
#
echo $NMON_COMMAND_LINE
$NMON_COMMAND_LINE
#
# Remove older files
#
if [ "$1" = "-d" ]; then
MTIME_OPTION="+7"
elif [ "$1" = "-w" ]; then
MTIME_OPTION="+14"
else
MTIME_OPTION="+60"
fi
echo "Cleaning old file ..."
find $NMON_LOG_ROOT_PATH$MODE/*.nmon -maxdepth 1 -mtime $MTIME_OPTION | xargs echo
2.2) Change Script permission
$ chmod 777 /root/nmon_spreadsheet.sh3) Configure crontab to invoke nmon collect spreadsheet periodicaly
$ crontab -e#+------------------ 1: min(0-59)
#| +--------------- 2: hour(0-23)
#| | +------------ 3: day_of_month(1-31)
#| | | +--------- 4: month_of_year(1-12)
#| | | | +------ 5: day_of_week(0-6)(Sun-Sat)
#| | | | | +--- 6: command-line
#| | | | | |
#v v v v v v
00 00 01 * * /root/nmon_spreadsheet.sh -m > /root/nmon_spreadsheet.monthly.log 2>&1
00 00 * * 1 /root/nmon_spreadsheet.sh -w > /root/nmon_spreadsheet.weekly.log 2>&1
00 00 * * 1-5 /root/nmon_spreadsheet.sh -d > /root/nmon_spreadsheet.daylylog 2>&1
4) Referencias
- http://nmon.sourceforge.net/pmwiki.php
- http://nmon.sourceforge.net/pmwiki.php?n=Site.Download
- http://www.ibm.com/developerworks/aix/library/au-analyze_aix/
- http://www.ibm.com/developerworks/wikis/display/WikiPtype/nmonanalyser