Thursday 14 July 2016

Setting up GUDS to be run as a simpler start/stop script

GUDS is a performance gathering script available from oracle.
It collects data periodically, based on input parameters and places data into output files with time stamps.
The script is useful when we need to analyze server performance during high load situations.

GUDS options are as follows:

-b : Bind guds to the processor cpuid
-c : Count value for commands that require it
      (vmstat, prstat, iostat, mpstat, sar, ...)
-d : A one line statement describing the state of the system during this               capture
-D : Change the default directory from /var/tmp/guds to <dir>
-g : If specified, skip collecting static configuration data
-h : Display this help text
-H : Run the script for the given number of hours, else for the given number
      of iterations if hours is zero
-i : Interval value for commands that require it
      (vmstat, prstat, iostat, mpstat, sar, ...)
-l : If specified and level >= 2, collect lockstat -H data
-L : Specify the interval during which lockstat is gathering data
      (default: 2 seconds)
-n : The number of iterations the script will do to collect data
-p : If specified, on SPARC, and level >= 2, collect trapstat data
-P : Overide guds exit on perl binary error
-q : Run in non interactive mode
-r : If specified, collect prstat cpu,rss,size, and zones data if able
-R : If specified, allow script to run when uid is not root
-s : The SR # used to create the directory where the data are going to be stored
-S : If specified, mask all IP addresses in the data
-T : Emit timestamps for commands that loop 
      (vmstat, mpstat, prstat, iostat)
-v : Print the GUDS Version
-w : Wait time between each iteration (default: 0 seconds)
      If set to 0, then the next iteration will start when the previous finishes
-x : Run this extra command during each iteration
      Output saved in xtra.out - Errors saved in xtra.err
-X : Run the extended set of commands depending on specified level
      level 0 : nothing
      level 1 : lockstat for contention events
      level 2 : trapstat (if -p), lockstat profiling, threadlist, TNF tracing (default)
      level 3 : kmastat, kmausers, memstat (they can take a long time to complete
                on systems with a lot of memory)Increasing extended level can affect system performance.
 -Z : If specified, allow script to run in a non-global zone


Here is a short script with which guds can be run without having to specify all required parameters every time.
This script can be put in /etc/init.d & be run in a similar fashion like other scripts available in the /etc/init.d directory.

$ cat guds
#!/sbin/sh
#
# Script to start/stop GUDS perf collection scripts
#
case "$1" in
'start')
        cd /root
        /var/tmp/guds_3_6 -q -i 5 -T -c 17500 -n 1 -s `/usr/bin/date '+%Y%m%d%H%M'` -w 0 -X 2 -D /storage/performance/output -d "Performance Issues " &
        echo 'GUDS starting.'
        ;;

'stop')
        /usr/bin/kill `/usr/bin/ps -eo 'pid,ppid,fname'|/usr/bin/egrep -i guds|/usr/bin/egrep -v " 1 "|/usr/bin/awk '{print $1}'`
        echo 'GUDS stopping.'
        ;;

*)
        echo "Usage: $0 { start | stop }"
        exit 1
        ;;

esac
exit 0

This script can be scheduled as a cron job like the one in the example given below:

# Restart GUDS performance gathering tool at midnight every day
0 0 * * * /etc/init.d/guds stop; sleep 120; /etc/init.d/guds start

The timings can be adjusted as per requirements.

No comments:

Post a Comment

Using capture groups in grep in Linux

Introduction Let me start by saying that this article isn't about capture groups in grep per se. What we are going to do here with gr...