Saturday, September 26, 2009

Date Format, N Days Ago

In UNIX shell script, it is very difficult to manipulate date/time using standard UNIX commands. Modern programming languages such as Perl, Python, Tcl, ..., are designed to be a general programming/scripting language that can handle this type of task with ease.

Below shows shell functions that wrap around these general scripting languages to determine the date format that is N days ago.

ago_perl()
{
        # localtime return:
        #       Seconds past the minute
        #       Minutes past the hour
        #       Hours past midnight
        #       Day of the month
        #       Months past the start of the year
        #       Number of years since 1900
        #       Number of days since the start of the week (Sunday)
        #       Number of days since the start of the year
        #       Whether or not daylight savings is active
        days=${1:-1}
        perl -e "@t=localtime(time-86400*$days);\
                printf('%4d-%02d-%02d', @t[5]+1900, @t[4]+1, @t[3])"

}
ago_tcl()
{
        days=${1:-1}
        echo "puts [clock format [expr [clock seconds] - $days*86400] \
                -format {%Y-%m-%d}]" | tclsh
}
ago_python()
{
        days=${1:-1}
        python -c "import time, datetime
t=datetime.datetime.fromtimestamp(time.time()-86400*$days)
print '%4d-%02d-%02d' % (t.year,t.month,t.day)"
}

Here is how you can use any of these functions

$ ago=`ago_perl 45`

$ echo "45 days ago is $ago"
45 days ago is 2009-08-12

Labels: , , ,

Sunday, September 13, 2009

Monitoring of LTO Tape Drives via FC Switch

I was trying to monitor the throughput of individual LTO tape drive but not getting any useful information from the tape library system. The only way to overcome this is to monitor it via the FC switch. In my case, it is a Brocade switch. Online SNMP MIBs for Brocade provides a very detailed description of the OIDs (swFCPortRxWords:1.3.6.1.4.1.1588.2.1.1.1.6.2.1.12 and swFCPortTxWords: 1.3.6.1.4.1.1588.2.1.1.1.6.2.1.11).

Due to the fact that the counter reset so frequent, I need to poll the FC switch every minute. Data is stored in RRDtool format.

Below shows two ways to visualise the LTO throughput. Line grpah shows individual drive throughput. Area/Stack graph shows the overall throughput of the backup:

Labels:

Saturday, September 05, 2009

John Ousterhout is in Stanford

The creator of Tcl/Tk is now in Stanford University. Some links for those who want to find out more:

Labels:

Wednesday, September 02, 2009

7 Mouldes of HPC Videos