Forum Discussion

Aaron_McMahon_2's avatar
Aaron_McMahon_2
Icon for Nimbostratus rankNimbostratus
Jun 01, 2006

Get statistics history instead of current snapshot?

Is there a way to get a statistic's history instead of just the current value? I notice in the BIG-IP GUI, I can go to the Performance window and it shows a graph with the history of various statistics like throughput bits per second. But iControl seems to just give me a current total.

 

 

Thanks...

 

- Aaron

 

5 Replies

  • The data behind the Performance graphs are available via iControl with the following methods:

     

     

    System::Statistics::get_performance_graph_list()

     

    System::Statistics::get_performance_graph_csv_statistics()

     

     

    The data is presented in CSV format so you'll need to parse the returned data (it's not for the feint of heart).

     

     

    The data is compressed over time so that there is always a constant amount of data that is stored.

     

     

    Here's some sample Perl code to get you going:

     

     

    !/usr/bin/perl
    ----------------------------------------------------------------------------
     The contents of this file are subject to the "END USER LICENSE AGREEMENT FOR F5
     Software Development Kit for iControl"; you may not use this file except in
     compliance with the License. The License is included in the iControl
     Software Development Kit.
     Software distributed under the License is distributed on an "AS IS"
     basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See
     the License for the specific language governing rights and limitations
     under the License.
     The Original Code is iControl Code and related documentation
     distributed by F5.
     The Initial Developer of the Original Code is F5 Networks,
     Inc. Seattle, WA, USA. Portions created by F5 are Copyright (C) 1996-2004 F5 Networks,
     Inc. All Rights Reserved.  iControl (TM) is a registered trademark of F5 Networks, Inc.
     Alternatively, the contents of this file may be used under the terms
     of the GNU General Public License (the "GPL"), in which case the
     provisions of GPL are applicable instead of those above.  If you wish
     to allow use of your version of this file only under the terms of the
     GPL and not to allow others to use your version of this file under the
     License, indicate your decision by deleting the provisions above and
     replace them with the notice and other provisions required by the GPL.
     If you do not delete the provisions above, a recipient may use your
     version of this file under either the License or the GPL.
    ----------------------------------------------------------------------------
    use SOAP::Lite + trace => qw(method debug);
    use SOAP::Lite;
    use MIME::Base64;
    BEGIN { push (@INC, ".."); }
    use iControlTypeCast;
    ----------------------------------------------------------------------------
     Validate Arguments
    ----------------------------------------------------------------------------
    my $sHost = $ARGV[0];
    my $sPort = $ARGV[1];
    my $sUID = $ARGV[2];
    my $sPWD = $ARGV[3];
    my $sGraphName = $ARGV[4];
    my $sProtocol = "https";
    if ( ("80" eq $sPort) or ("8080" eq $sPort) )
    {
      $sProtocol = "http";
    }
    if ( ($sHost eq "") or ($sPort eq "") or ($sUID eq "") or ($sPWD eq "") )
    {
      die ("Usage: PerformanceGraphs.pl host port uid pwd [graph_name]\n");
    }
    ----------------------------------------------------------------------------
     Transport Information
    ----------------------------------------------------------------------------
    sub SOAP::Transport::HTTP::Client::get_basic_credentials
    {
      return "$sUID" => "$sPWD";
    }
    $Statistics = SOAP::Lite
      -> uri('urn:iControl:System/Statistics')
      -> proxy("$sProtocol://$sHost:$sPort/iControl/iControlPortal.cgi");
    eval { $Statistics->transport->http_request->header
    (
      'Authorization' => 
        'Basic ' . MIME::Base64::encode("$sUID:$sPWD", '')
    ); };
    if ( "" eq $sGraphName )
    {
      &getPerformanceGraphList();
    }
    else
    {
      &getPerformanceGraph("detailthroughput");
      &getPerformanceGraph("CPU");
      &getPerformanceGraph($sGraphName);
    }
    ----------------------------------------------------------------------------
     sub getPerformanceGraph
    ----------------------------------------------------------------------------
    sub getPerformanceGraph()
    {
      ($graph_name) = (@_);
      print "Requesting Graph: $graph_name\n";
      $PerformanceGraphQuery =
      {
        object_name => $graph_name,
        start_time => 0,
        end_time => 0,
        interval => 0,
        maximum_rows => 0
      };
      
      $soapResponse = $Statistics->get_performance_graph_csv_statistics
      (
        SOAP::Data->name(objects => [$PerformanceGraphQuery])
      );
      &checkResponse($soapResponse);
      @PerformanceGraphCSVList = @{$soapResponse->result};
      foreach $PerformanceGraphCSV (@PerformanceGraphCSVList)
      {
        $object_name = $PerformanceGraphCSV->{"object_name"};
        $start_time = $PerformanceGraphCSV->{"start_time"};
        $end_time = $PerformanceGraphCSV->{"end_time"};
        $interval = $PerformanceGraphCSV->{"interval"};
        $statistic_data = $PerformanceGraphCSV->{"statistic_data"};
        $file_name = &generateFileName($object_name);
        print "===================================\n";
        print "Object Name: $object_name\n";
        print "Start Time : $start_time\n";
        print "End Time   : $end_time\n";
        print "Interval   : $interval\n";
        print "Statistics : stored in file '$file_name'\n";
        print "===================================\n";
        open (LOCAL_FILE, ">$file_name") or die ("Can't open $file_name for output!");
        print LOCAL_FILE $statistic_data;
        close(LOCAL_FILE);
      }
    }
    ----------------------------------------------------------------------------
     sub getPerformanceGraphList
    ----------------------------------------------------------------------------
    sub getPerformanceGraphList()
    {
      $soapResponse = $Statistics->get_performance_graph_list();
      &checkResponse($soapResponse);
      
      print "--------------------------------------------\n";
      print "     Available Performance Graphs\n";
      print "--------------------------------------------\n";
      @PerformanceGraphList = @{$soapResponse->result};
      foreach $PerformanceGraph (@PerformanceGraphList)
      {
        $graph_name = $PerformanceGraph->{"graph_name"};
        $graph_title = $PerformanceGraph->{"graph_title"};
        $graph_description = $PerformanceGraph->{"graph_description"};
        printf "%20s - $graph_description\n", $graph_name;
      
      }
    }
    ----------------------------------------------------------------------------
     checkResponse
    ----------------------------------------------------------------------------
    sub checkResponse()
    {
      my ($soapResponse) = (@_);
      if ( $soapResponse->fault )
      {
        print $soapResponse->faultcode, " ", $soapResponse->faultstring, "\n";
        exit();
      }
    }
    ----------------------------------------------------------------------------
     sub generateFileName
    ----------------------------------------------------------------------------
    sub generateFileName()
    {
      ($report_name) = (@_);
      
      ($sec,$min,$hour,$mday,$mon,$year,$wday,$yday,$isdst) = localtime(time);
      $year += 1900;
      $sName = sprintf("%s-%04d%02d%02d_%02d%02d%02d.csv", $report_name, $year, $mon, $mday, $hour, $min, $sec);
      return $sName;
    }

     

     

    Good luck!!!

     

     

    -Joe

     

  • I was looking at one csv file returned by this example:

     

     

    timestampConnections

     

    11920137604.67E+00

     

    1192014000 nan

     

    11920142405.68E+00

     

    11920144806.17E+00

     

    11920147206.23E+00

     

    11920149606.11E+00

     

    11920152006.19E+00

     

    11920154405.23E+00

     

    11920156805.83E+00

     

    ...

     

     

    (1) The 'timestamp' is not a Julian date, right? What does the timestamp represent?

     

     

    (2) I recognize the scientific notation under 'Connections'. Does 'nan' non-applicable or something similar?

     

     

    Thanks
  • Nevermind about the timestamp .. it's a unix type timestamp .. I have the conversion part done.
  • Considering the screen output:

     

     

    Requesting Graph: activecons

     

    ===================================

     

    Object Name: activecons

     

    Start Time : 1192040640

     

    End Time : 1192127280

     

    Interval : 240

     

    Statistics : stored in file 'activecons-20070911_134710.csv'

     

    ===================================

     

     

    I think there is 24hours of sample data being placed in the csv-file that is written.

     

     

    Question: I was hoping to get 30-days worth of samples (like the GUI provides); is it possible to request 30 or more days of sample historical data?
  • Answered in this thread:

     

     

    http://devcentral.f5.com/Default.aspx?tabid=53&forumid=1&tpage=1&view=topic&postid=1767417719

     

    Click here

     

     

     

    -Joe