Last change
on this file since 2141 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 | |
---|
3 | use strict; |
---|
4 | use warnings; |
---|
5 | use LATMOS::Accounts::Maintenance; |
---|
6 | use LATMOS::Accounts::Log; |
---|
7 | use Getopt::Long; |
---|
8 | use 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 | |
---|
20 | GetOptions( |
---|
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 | |
---|
33 | Use this configuration directory instead of the default one. |
---|
34 | |
---|
35 | =item -b|--base base |
---|
36 | |
---|
37 | Use this specific base |
---|
38 | |
---|
39 | =item -s |
---|
40 | |
---|
41 | Run the statistics and store data into history. |
---|
42 | |
---|
43 | =back |
---|
44 | |
---|
45 | =cut |
---|
46 | |
---|
47 | my $LA = LATMOS::Accounts->new($config, noacl => 1); |
---|
48 | my $labase = $LA->base($base); |
---|
49 | $labase && $labase->load or die "Cannot load base"; |
---|
50 | $labase->wexported(1); |
---|
51 | |
---|
52 | my ($name) = @ARGV; |
---|
53 | |
---|
54 | my $stat = $labase->get_object('stat', $name) or die "no stat name $name"; |
---|
55 | |
---|
56 | my $res; |
---|
57 | if ($store) { |
---|
58 | $stat->collect and $labase->commit; |
---|
59 | $res = $stat->getStat; |
---|
60 | } else { |
---|
61 | $res = $stat->compute; |
---|
62 | } |
---|
63 | |
---|
64 | foreach (sort { $res->{$b} <=> $res->{$a} } keys %$res) { |
---|
65 | print "$_: " . $res->{$_} . "\n"; |
---|
66 | } |
---|
Note: See
TracBrowser
for help on using the repository browser.