Dr. Dobb's is part of the Informa Tech Division of Informa PLC

This site is operated by a business or businesses owned by Informa PLC and all copyright resides with them. Informa PLC's registered office is 5 Howick Place, London SW1P 1WG. Registered in England and Wales. Number 8860726.


Channels ▼
RSS

Extracting Symmetrix Data with Orca


Listing 2 Orca-symmetrix_probe.pl

#!/usr/local/bin/perl
#
# Tom Kranz - [email protected]
#
# With thanks to Mick Sheppard for his Perl skillz!
#
# This script calls symstat, pulls the required data out from it's 
# output and then prints that to a log file
# That is then copied to Orac via rsync for plotting by Orca


# We need to setup several date variables first
($Second,$Minute,$Hour,$Month_Day,$Month,$Year,$Week_Day,$IsDST) = \
  (localtime)[0
,1,2,3,4,5,6,8];
$realyear=$Year+1900;
$realmon=$Month+1;
$monlength=length($Month_Day);
if ( $monlength == 1 ) {
        $Month_Day="0$Month_Day";
};
$realmonlen=length($realmon);
if ( $realmonlen == 1 ) {
    $realmon="0$realmon";
};

# We need a nice ISO format date for the log file, and we also need an 
# epoch timestamp for the first data column - Orca can then use this 
# to track updates
$gdate="$realyear-$realmon-$Month_Day";
$epochtime=time;

# Here's our output file
open(PROBEOUT,">>/var/log/probe/probe-$gdate");

# Now we have some arrays to create the column headings
# Note that volumes 00A and 00B are listed as 010 and 011
# Orca doesn't plot them otherwise
@logicaldisks=("001", "002", "003", "004", "005", "006", "007", \
               "008", "009", "010", "011");
@columns=("ioread", "iowrite", "kbread", "kbwrite", "cacheread", \
          "cachewrite", "seqread", "wptracks");

# Now we need to print the column headings to the output file
print PROBEOUT "timestamp ";
foreach $name (@logicaldisks) {
    foreach $column (@columns) {
        print PROBEOUT "$name$column ";
    };
};
print PROBEOUT "\n";

# Now we add our timestamp for Orca to keep track of when new data 
# was added
print PROBEOUT "$epochtime ";

# And now we take in the results from the symstat command, and do 
# some munging
# before printing them out to the output file
foreach $dev (@logicaldisks) {
    # Note: here we need to change the volume IDs to hex so that we can
    # spot them from the output of symstat
    if ( $dev == "010" ) {
        $dev="00A";
    } elsif ( $dev == "011" ) {
        $dev="00B";
    }
    # Now we start reading in the data from symstat
    $probe=open(PROBEIN,"/opt/emc/SYMCLI/4.0.1/bin/symstat -i 10 \
                -c 2 -dev $dev|");

    my $found = 0 ;
    while( <PROBEIN> ) {
        chomp;
        if( /([0-9A-F]{3})\s+\(rdmp\/(\w+)\*\)(.*)$/ ) {
            $found = 1;
            $volumeID = $1 ;
            $devPath = $2 ;
            @results = split( /\s+/, $3 ) ;
            for( $idx = 0 ; $idx <= $#results ; $idx ++ ) {
                if( $results[ $idx ] eq "N/A" ) {
                    $results[ $idx ] = 0 ;
                }
            }
            print PROBEOUT join( ' ', @results ) ;
            last ;
        }
    }
    close( PROBEIN ) ;

    # symstat often doesn't come back for all volumes, so we need to pad
    # the data with nulls
    if ( $found == 0 ) {
        print PROBEOUT "0 0 0 0 0 0 0 0" ;
    }
    # Just in case we're missing a space somewhere between data sets 
    # on the line - Orca isn't fazed (it appears to be matching on \s+)
    print PROBEOUT " " ;
}

# And we end the line, ready for the next round of column headings
print PROBEOUT "\n";

# Always tidy up after yourself
close(PROBEOUT);


Related Reading


More Insights






Currently we allow the following HTML tags in comments:

Single tags

These tags can be used alone and don't need an ending tag.

<br> Defines a single line break

<hr> Defines a horizontal line

Matching tags

These require an ending tag - e.g. <i>italic text</i>

<a> Defines an anchor

<b> Defines bold text

<big> Defines big text

<blockquote> Defines a long quotation

<caption> Defines a table caption

<cite> Defines a citation

<code> Defines computer code text

<em> Defines emphasized text

<fieldset> Defines a border around elements in a form

<h1> This is heading 1

<h2> This is heading 2

<h3> This is heading 3

<h4> This is heading 4

<h5> This is heading 5

<h6> This is heading 6

<i> Defines italic text

<p> Defines a paragraph

<pre> Defines preformatted text

<q> Defines a short quotation

<samp> Defines sample computer code text

<small> Defines small text

<span> Defines a section in a document

<s> Defines strikethrough text

<strike> Defines strikethrough text

<strong> Defines strong text

<sub> Defines subscripted text

<sup> Defines superscripted text

<u> Defines underlined text

Dr. Dobb's encourages readers to engage in spirited, healthy debate, including taking us to task. However, Dr. Dobb's moderates all comments posted to our site, and reserves the right to modify or remove any content that it determines to be derogatory, offensive, inflammatory, vulgar, irrelevant/off-topic, racist or obvious marketing or spam. Dr. Dobb's further reserves the right to disable the profile of any commenter participating in said activities.

 
Disqus Tips To upload an avatar photo, first complete your Disqus profile. | View the list of supported HTML tags you can use to style comments. | Please read our commenting policy.