source: trunk/LATMOS-Accounts/bin/la-sql-runstat @ 1474

Last change on this file since 1474 was 1449, checked in by nanardon, 9 years ago

Add missing file

  • Property svn:executable set to *
File size: 1.1 KB
Line 
1#!/usr/bin/perl
2
3use strict;
4use warnings;
5use LATMOS::Accounts::Maintenance;
6use LATMOS::Accounts::Log;
7use Getopt::Long;
8use Pod::Usage;
9
10=head1 NAME
11
12    la-sql-runstat - Collect statistic data
13
14=head1 SYNOPSIS
15
16    la-expired-reminder [options] statname
17
18=cut
19
20GetOptions(
21    'c|config=s' => \my $config,
22    'b|base=s'   => \my $base,
23    's|store'    => \my $store,
24    'help'       => sub { pod2usage(0) },
25) or pod2usage();
26
27=head1 OPTIONS
28
29=over 4
30
31=item -c|--config configdir
32
33Use this configuration directory instead of the default one.
34
35=item -b|--base base
36
37Use this specific base
38
39=back
40
41=cut
42
43my $LA = LATMOS::Accounts->new($config, noacl => 1);
44my $labase = $LA->base($base);
45$labase && $labase->load or die "Cannot load base";
46$labase->wexported(1);
47
48my ($name) = @ARGV;
49
50my $stat = $labase->get_object('stat', $name) or die "no stat name $name";
51
52my $res;
53if ($store) {
54    $stat->collect and $labase->commit;
55    $res = $stat->getStat;
56} else {
57    $res = $stat->compute;
58}
59
60foreach (sort { $res->{$b} <=> $res->{$a} } keys %$res) {
61   print "$_: " . $res->{$_} . "\n";
62} 
Note: See TracBrowser for help on using the repository browser.