Saturday, October 31, 2009

What Is Personal Leadership Brand

If you have 10 minutes to spare, you should watch this video from Harvard Business in YouTube

Labels:

Friday, October 30, 2009

Thumbnail Your RRDtool Graphs

If you have lots of RRDtool graphs you need to go through everyday, you may want to consider creating thumbnail dynamically from the RRD files. As CPU and memory utilisations are plotted with same scale (100%), we can put them together for ease of viewing and analysis.

A simple CGI script is able to do the job. Basically it ignores x- & y-grids/ticks/labels and legends

echo "Content-tyep: image/png"
echo ""
/usr/bin/rrdtool graph - \
        --start -${2:-1d} \
        --imgformat PNG \
        --lower-limit 0 --upper-limit 100 --rigid \
        --width=125 --height=30 \
        --x-grid none \
        --y-grid none \
        --title "$host" \
        --color=BACK#ffffff \
        --color=CANVAS#ffeee5 \
        --color=GRID#7F7F7F \
        --color=MGRID#B8B8B8 \
        --color=ARROW#FF0000 \
        DEF:usr=$rrd_cpu:usr:AVERAGE \
        DEF:sys=$rrd_cpu:sys:AVERAGE \
        DEF:wio=$rrd_cpu:wio:AVERAGE \
        DEF:idle=$rrd_cpu:idle:AVERAGE \
        DEF:mtotal=$rrd_mem:total:AVERAGE \
        DEF:mused=$rrd_mem:used:AVERAGE \
        CDEF:gbtotal=mtotal,1024,/ \
        CDEF:gbused=mused,1024,/ \
        CDEF:gbfree=mtotal,mused,-,1024,/ \
        CDEF:percent=gbfree,gbtotal,/,100,* \
        AREA:usr#dddd00:\
        STACK:sys#dd0000:\
        STACK:wio#ff8a60:\
        STACK:idle#e2e2f2:\
        LINE1:percent#0000ff: \
        GPRINT:gbfree:LAST:"Mem\:%5.1lf/" \
        GPRINT:gbtotal:LAST:"%5.1lfGB"

Labels:

Friday, October 23, 2009

New DTrace Resources

Tuesday, October 20, 2009

Scripting Hustle

I was given this compliment:
不愧是万中无一的scripting guy
+ learn a lifetime skill of scripting for $10

Watch this movie clip (fast forward to 08:40) to find out the resemblance

Monday, October 12, 2009

Too Big An Audit Log To Handle

Have you ever encounter Solaris audit log that has not been rotated for months ? It is just far too big for some of the down stream programs to handle. Click here for a sample of the output from praudit -l. Here is a sample script to 'chop' them into individual files based on day. With this simple script, now you can handle audit log with ease.
IFS_orig=$IFS
cd /var/audit
praudit -l 2009052803069.20091009095022.myhost | while read line
do
        IFS=","
        set -- $line
        d=$7
        IFS=$IFS_orig
        set -- $d
        ymd=$1
        echo $line >> $ymd.txt
done

Labels:

Number of Days in a Month

If you have to loop through everyday in a month to generate daily summary, you may want to know how many days in a particular month. It may not be as straightforward as you think because you need to take into account of leap year, short months, and so on. Here is a simple trick that can help you on this. Run the cal command to display the calendar and pipe it to awk to pick up the last number from the last non-empty line.
$ cal
    October 2009
Su Mo Tu We Th Fr Sa
             1  2  3
 4  5  6  7  8  9 10
11 12 13 14 15 16 17
18 19 20 21 22 23 24
25 26 27 28 29 30 31

$ cal | awk 'NF>0{n=$NF}END{print n}'
31

$ cal 2 2012
    February 2012
Su Mo Tu We Th Fr Sa
          1  2  3  4
 5  6  7  8  9 10 11
12 13 14 15 16 17 18
19 20 21 22 23 24 25
26 27 28 29

$ cal 2 2012 | awk 'NF>0{n=$NF}END{print n}'
29

Labels: