JohnyBricks

Retention calculation via Rest API for Log Data

Discussion created by JohnyBricks on Mar 27, 2013
Latest reply on Nov 9, 2016 by Naushad Kasu

All,

Most of the posts on this forum are Packet Centric, I'm posting this to help others on the Log Data side that are trying to get REST apps to work.

I ran this in a cygwin environment but this should work well in any UNIX environment too.

#!/usr/bin/perl
use Time::ParseDate qw(parsedate);

@stat_string =
`/usr/bin/curl --user "xxx:xxx" "http://concentrator_iphttp://concentrator_ip:50105/database/stats:50105/database/stats"`;
foreach $date (@stat_string) {
    if ( $date =~ /meta.oldest.file.time/ ) {
        ( $Year, $Month, $Day ) =
          ( $date =~ /([0-9]{4})-([A-Z]{1}[a-z]{1,4})-([0-9]{2})/ );
        print "Year is $Year Month is $Month Day is $Day\n";
    }
}

$d1 = "$Day-$Month-$Year";
$d2 = `date  "+%d-%B-%Y"`;

print "The oldest file on record  is '$d1' current date is '$d2'\n";

printf "Currently retaining %d days worth of log data\n",
  ( parsedate($d2) - parsedate($d1) ) / ( 60 * 60 * 24 );

 

This should print out the amount of days that the SA 10.x environment is retaining.

Outcomes