File: //opt/PUC/collector.pl
#!/usr/bin/env perl
=pod
=head1 Product Usage Collector
This script implements a system to gather information about how customers are
using our hosting servers. The initial implementation will include gathering
information about what applications customers have installed on their websites
(WordPress, Joomla, etc). Later modules may be added to gather other kinds of
information, such as plugins installed for those web applications.
=cut
use strict;
use warnings;
use 5.10.1;
use FindBin;
use Getopt::Long;
use FindBin;
use PUC::Collector;
my $debug;
my $dryrun;
my $help;
my $single_domain;
my $single_user;
my $dataroot = '/';
my $datastore_url;
my $datastore_key_file;
my $got_valid_options = GetOptions(
'debug' => \$debug,
'dryrun' => \$dryrun,
'help' => \$help,
'domain=s' => \$single_domain,
'user=s' => \$single_user,
'dataroot=s' => \$dataroot,
'datastore_url=s' => \$datastore_url,
'datastore_key_file=s' => \$datastore_key_file,
);
if (
not $got_valid_options
or $help
or ( $single_domain and $single_user )
)
{
help();
exit;
}
PUC::Collector::run(
bindir => $FindBin::Bin,
debug => $debug,
dryrun => $dryrun,
single_domain => $single_domain,
single_user => $single_user,
dataroot => $dataroot,
datastore_base_url => $datastore_url,
datastore_key_file => $datastore_key_file,
);
exit;
################################################################################
sub help {
print << "EOD";
USAGE $FindBin::Script [--debug] [--dryrun] [--help]
[--domain=xyz.com|--user=auser] [--dataroot=/some/directory] [--datastore_url=https://localhost]
Perform a system scan to analyze the way customers are using the system.
--debug Print extra debugging information.
--dryrun Perform the scan and print results to screen, but do
not save or report the data.
--help Print these instructions and exit.
--domain=xyz.com
--user=auser Only one of these options may be specified. Perfor
scan of the indicated domain or user only.
--dataroot=/ Specifies the root directory of the files to test. This
is really intended for testing so you don't have to be
on a cPanel server to do test runs. To use the provided
test data set --dataroot=../testdata/
The trailing slash is required.
--datastore_url Override the base_url setting of the datastore. Note in particular that you can use "dryrun://localhost" to effectively disable using the datastore.
EOD
exit;
}