Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
tree: 5ef7ebee87
Fetching contributors…

Cannot retrieve contributors at this time

executable file 81 lines (64 sloc) 2.175 kb
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81
#!/usr/bin/env perl

#use strict;
#use warnings;

##H List pending transfer and delete requests
##H
##H Options:
##H -db : DBParam file (required)
##H

use Getopt::Long;
use PHEDEX::Core::Help;
use PHEDEX::Core::DB;
use PHEDEX::Core::Formats;
use PHEDEX::Core::Timing;
use File::Path;
use File::Basename;
use Date::Calc qw ( Today Time_to_Date Delta_Days );

my %args;
&GetOptions ("db=s" => \$args{DBCONFIG},
             "out=s" => \$args{OUT},
             "help|h" => sub { &usage() });

# Script name
my $me = fileparse($0);

# Check arguments.
if (!$args{DBCONFIG})
{
  die "Insufficient parameters, use -h for help.\n";
}

if (!$args{OUT})
{
  $args{OUT} = "/tmp/$me.out"
}

open(OUT,">$args{OUT}") || die "Cannot open $args{OUT}: $!";

my $self = { DBCONFIG => $args{DBCONFIG} };
my $dbh = &connectToDatabase ($self);
my $now = &mytimeofday();

my $sqlx = qq{
select substr(min(dn.name),0,20) dst_node, substr(min(n.name),0,20) src_node, b.name dataset, xq.time_create
from t_xfer_request xq
left join t_xfer_path xp on xp.fileid = xq.fileid and xp.destination = xq.destination
join t_dps_file f on f.id = xq.fileid
join t_adm_node n on n.id = f.node
join t_adm_node dn on dn.id = xq.destination
join t_dps_block b on b.id = f.inblock
join t_dps_dataset ds on ds.id = b.dataset
where xp.fileid is null and xq.state = 0 and xq.time_create < ((sysdate - to_date('01-JAN-1970','DD-MON-YYYY')) * (86400) - 600)
group by dn.name, n.name, b.name, xq.time_create
order by dn.name, n.name, b.name, xq.time_create
};

$dbh->{LongReadLen} = 3000;
my $q = &dbexec($dbh, $sqlx);

my $date = `date`;
print OUT "Report generated: $date\n";
printf OUT ("%-22s %-22s %-120s %-4s\n","DESTINATION","SOURCE","BLOCK","DAYS");
print OUT "\n";

while (my $r = $q->fetchrow_arrayref) {
    my ($dest, $source, $dataset, $create) = @$r;

    # get current GMT date
    ($ty,$tm,$td) = Today(1);
    ($cy,$cm,$cd,undef) = Time_to_Date($create);

    #next unless ($dataset =~ /MC_/);
    printf OUT ("%-22s %-22s %-120s %-4s\n",$dest, $source, $dataset, Delta_Days($ty,$tm,$td,$cy,$cm,$cd));
}

&disconnectFromDatabase($self, $dbh, 1);

close(OUT);
Something went wrong with that request. Please try again.