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

Last change on this file since 2209 was 1488, checked in by nanardon, 9 years ago

Fix documentation

  • 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-sql-runstat [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=item -s
40
41Run the statistics and store data into history.
42
43=back
44
45=cut
46
47my $LA = LATMOS::Accounts->new($config, noacl => 1);
48my $labase = $LA->base($base);
49$labase && $labase->load or die "Cannot load base";
50$labase->wexported(1);
51
52my ($name) = @ARGV;
53
54my $stat = $labase->get_object('stat', $name) or die "no stat name $name";
55
56my $res;
57if ($store) {
58    $stat->collect and $labase->commit;
59    $res = $stat->getStat;
60} else {
61    $res = $stat->compute;
62}
63
64foreach (sort { $res->{$b} <=> $res->{$a} } keys %$res) {
65   print "$_: " . $res->{$_} . "\n";
66} 
Note: See TracBrowser for help on using the repository browser.