Add documentation

This commit is contained in:
hjp 2019-09-08 09:06:01 +00:00
parent a6b9dff48e
commit f01efab3a6
1 changed files with 32 additions and 1 deletions

View File

@ -1,5 +1,29 @@
#!/usr/bin/perl #!/usr/bin/perl
=head1 SYNOPSIS
remove_session [--age time] [session_ids ...]
=head1 DESCRIPTION
The C<remove_session> script removes the specified sessions from the
simba database and then cleans up orphaned entries.
The sessions can be specified by minimum age or by listing their ids (or
both, but that is probably not very useful).
The age is specified as a fractional number followed by a unit: "y",
"m", "w", or "d". So C<remove_session --age 2.5y> removes all sessions
older than 2.5 years (actually 2.5 * 365 * 86400 seconds -- leap years
and DST are ignored), and C<remove_session --age 52w> removes all
sessions older than 52 weeks.
If neither the age nor a list of sessions is specified, no sessions are
removed, but the cleanup phase is still run, which may take considerable
time (and might be considered a bug).
=cut
# This script removes all data associated with the given sessions. # This script removes all data associated with the given sessions.
# For each session it first removes all instances of that session and # For each session it first removes all instances of that session and
# then cleans up any orphans. # then cleans up any orphans.
@ -10,6 +34,7 @@ use strict;
use Simba::CA; use Simba::CA;
use Bit::Vector::Judy; use Bit::Vector::Judy;
use Getopt::Long; use Getopt::Long;
use Pod::Usage;
$| = 1; $| = 1;
@ -24,7 +49,13 @@ my $partition_size = $ca->{instances_part_size};
my %opt; my %opt;
GetOptions( GetOptions(
\%opt, \%opt,
"age=s"); "age=s",
"help",
) or pod2usage(verbose => 0);
if ($opt{help}) {
pod2usage(verbose => 2);
}
if ($opt{age}) { if ($opt{age}) {
my ($num, $unit) = $opt{age} =~ /(\d(?:.\d+)?)(y|m|w|d)/; my ($num, $unit) = $opt{age} =~ /(\d(?:.\d+)?)(y|m|w|d)/;