Introduction
When tracking Unix/Linux issues, we need a way to track usage via ssh/telnet sessions for sustained periods of time.
Why
Using tools like nmon, top or the like provide great overall system performance but lack longer term usage while not consistently watching screen. It is easier at times to just look at the screen to know history and status.
Usage
This is a shell script to allow waterfall status of commands that return a numeric value.
chartit @|<command> [s<seconds>] [t<title>] [m<maxchartvalue>]
BASIC METHODS:
chartit @ - Pull from standard in and chart
vmstat 10 | chartit @
* Chart every 10 secs the runlevel
chartit <command>
chartit "vmstat 10"
* Chart every 10 secs the runlevel
OPTIONS:
s# = Sets number of seconds to wait before executing again.
(This also sets for multi command executions, not a stream)
t<> = Sets a Title String
m# = Sets the start max size of the chart
f# = Field number to collect from
k# = Number of lines to skip before charting input
Simple Sample:
chartit "date +\"%S\"" s5 tSECONDS m60
Sample
SUSE linux sample collection of swap usage:
vmstat -S M 60 | chartit @ f3 k2 m`free -m|grep "^Swap"|awk '{print($2)}'` tSWAP-USED-MB
SWAP-USED-MB Chart Size= 2047
000000000
000000000
000000000
000000000
000000000
000000000
000000000
000000000
000000000
000000000
000000000
000000000
000000000
000000000
000000000
000000000
CMax 243.00
AMax 243.00 LtAMAX=03/07/2014 08:58:33
CMin 243.00
AMin 243.00 LtAMIN=03/07/2014 08:58:33
CAvg 243.00
AAvg 225.00
LAST 243.00 Refresh-by-CMD
General Explanation of the Above
- Title is set with
t<title>
and showed in top left. - Max value is set automatically upon collection or by
m<value> </value>
<value>and adjusted upon higher value found. Note: Max value is the total width of the screen. - Waterfall Area: Latest collected value is at the top of the screen, oldest is at the bottom.
- CMAX - or the ones starting with C are Charted (shown on screen) Max value
- AMAX - or the ones starting with A are All time (since the command was started) Max Value
- On the
AMax
and AMin
, we capture the time of that sample. - Refresh is set by the timing of the input stream not multi run of a command.
Other MFU (Methods For Use)
#ALL UNIX/LINUX
#Track Thread Count of a process Change <PID>
chartit 'ps -p <PID> -o thcount -o pid -o comm' s60 tPID-Threads
#ZVM Linux
#Watch Steal % on systems
vmstat 60 | chartit @ f17 k3 "tCPU-STEAL `vmcp q userid`"
#LINUX
#Watch Free Memory
vmstat -S M 60 | chartit @ f4 k2 m`free -m|grep "^Mem"|awk '{print($2)}'` tMEMORY-FREE-MB
#Watch Swap Usage
vmstat -S M 60 | chartit @ f3 k2 m`free -m|grep "^Swap"|awk '{print($2)}'` tSWAP-USED-MB
#AIX
#Track Virtual Memory used by a process
chartit "svmon -P PID -O unit=MB|awk '{print(\$6)}'" s60 tPID-Virtual
#Track Paging Space used by a process
chartit "svmon -P PID -O unit=MB|awk '{print(\$6)}'" s60 tPID-Pgsp
#Tacke Thread Count by PID based on string in PID
chartit 'ps -p `ps -ef | grep "<PSSTRING>" | grep -v "grep" |
grep "<PSMORESTRING>" | awk '"'"'{print($2)}'"'"'` -o thcount' s10 tWHAT-TITLE
#Watch Phys CPU
chartit "lparstat 60" tPHY-CPU k5 f5
#Watch Swap Usage
chartit "swap -s | awk '{print(\$7*0.00390625)}'" s60 m`swap -s | awk '{print(\$3*0.00390625)}'` tSWAP-MB