For more information regarding the security incident at F5, the actions we are taking to address it, and our ongoing efforts to protect our customers, click here.

Perl Script to gather iQuery Statistics

Problem this snippet solves:

This Perl script gathers iquery statistics of the entire iquery mesh

How to use this snippet:

iquery.pl < gtmsyncmember> < user> < pass>

Code :

#!/usr/bin/perl

use SOAP::Lite;
use Data::Dumper;
use POSIX qw(strftime);

my $BIGIP = $ARGV[0];
my $User = $ARGV[1];
my $Pass = $ARGV[2];



sub SOAP::Transport::HTTP::Client::get_basic_credentials
{
  return "$User" => "$Pass";
}

 
&getiquery();


sub SOAP::Deserializer::typecast
{
  my ($self, $value, $name, $attrs, $children, $type) = @_;
  my $retval = undef;
  if ( "{urn:iControl}GlobalLB.LBMethod" == $type )
  {
    $retval = $value;
  }
  return $retval;
}

sub GetInterface()
{
  my ($module, $name) = @_;

  $interface = SOAP::Lite
    -> uri("urn:iControl:$module/$name")
    -> readable(1)
    -> proxy("https://$BIGIP/iControl/iControlPortal.cgi");
  eval { $interface->transport->http_request->header
  ( 'Authorization' => 'Basic ' . MIME::Base64::encode("$User:$Pass", '') ); };

  return $interface;
}


sub getiquery()
{
 
  
  $GTMiquery = &GetInterface("System", "Statistics");  
  $soapResponse = $GTMiquery->get_all_gtm_iquery_statistics_v2();
  $iqueryget = $soapResponse->result;
  foreach $iquerygetx ($iqueryget)
  {
   @value=@{$iquerygetx->{"statistics"}};
   foreach $valuex (@value)
   {
   print $valuex->{"ip_address"}."\t"."\t"; 
   print $valuex->{"connection_state"}."\t"."\t"."\t";
   $datex=$valuex->{"cert_expire_time"}."\t";
   print strftime('%d-%b-%Y',localtime($datex))."\t";
   print $valuex->{"server"}."\n";
   } 
 } 


}
Updated Jun 06, 2023
Version 2.0
No CommentsBe the first to comment