Line 192... |
Line 192... |
192 |
# additionally, if the key 'postRunScript' is in the config, it is assumed to be the name of a script to be run after sysinfo
|
192 |
# additionally, if the key 'postRunScript' is in the config, it is assumed to be the name of a script to be run after sysinfo
|
193 |
# completes it's task. This can be used to download/update the program, add new modules, etc..
|
193 |
# completes it's task. This can be used to download/update the program, add new modules, etc..
|
194 |
#
|
194 |
#
|
195 |
# Version 3.6.1 20230308 RWR
|
195 |
# Version 3.6.1 20230308 RWR
|
196 |
# fixed a problem where it did not correctly find the source directory when called from a symbolic link
|
196 |
# fixed a problem where it did not correctly find the source directory when called from a symbolic link
|
- |
|
197 |
#
|
- |
|
198 |
# Version 3.7.0 20240517 RWR
|
- |
|
199 |
# Added code to put everything from config file except for moduleDirs, transports and scriptDirs into the report. This allows
|
- |
|
200 |
# users to arbitrarily choose to send additional information by simply adding it to the config file.
|
197 |
|
201 |
|
198 |
|
202 |
|
199 |
# find our location and use it for searching for libraries
|
203 |
# find our location and use it for searching for libraries
|
200 |
BEGIN {
|
204 |
BEGIN {
|
201 |
use FindBin;
|
205 |
use FindBin;
|
Line 211... |
Line 215... |
211 |
my $sourceDir = dirname( abs_path( __FILE__ ) );
|
215 |
my $sourceDir = dirname( abs_path( __FILE__ ) );
|
212 |
|
216 |
|
213 |
# define the version number
|
217 |
# define the version number
|
214 |
# see https://metacpan.org/pod/release/JPEACOCK/version-0.97/lib/version.pod
|
218 |
# see https://metacpan.org/pod/release/JPEACOCK/version-0.97/lib/version.pod
|
215 |
use version;
|
219 |
use version;
|
216 |
our $VERSION = version->declare("v3.6.1");
|
220 |
our $VERSION = version->declare("v3.7.0");
|
217 |
our $DATA_VERSION = version->declare( 'v3.0.1' ); # used in sending the data file. sets version of XML/YAML data file
|
221 |
our $DATA_VERSION = version->declare( 'v3.7.0' ); # used in sending the data file. sets version of XML/YAML data file
|
218 |
|
222 |
|
219 |
# see https://perldoc.perl.org/Getopt/Long.html
|
223 |
# see https://perldoc.perl.org/Getopt/Long.html
|
220 |
use Getopt::Long;
|
224 |
use Getopt::Long;
|
221 |
# allow -vvn (ie, --verbose --verbose --dryrun)
|
225 |
# allow -vvn (ie, --verbose --verbose --dryrun)
|
222 |
Getopt::Long::Configure ("bundling");
|
226 |
Getopt::Long::Configure ("bundling");
|
Line 560... |
Line 564... |
560 |
$config->{'moduleDirs'} = [ $config->{'moduleDirs'} ];
|
564 |
$config->{'moduleDirs'} = [ $config->{'moduleDirs'} ];
|
561 |
$config->{'scriptDirs'} = [ $config->{'scriptDirs'} ];
|
565 |
$config->{'scriptDirs'} = [ $config->{'scriptDirs'} ];
|
562 |
return $config;
|
566 |
return $config;
|
563 |
}
|
567 |
}
|
564 |
|
568 |
|
- |
|
569 |
# Initialize the report with some stuff from the program itself and the configuration file
|
- |
|
570 |
sub initReport {
|
- |
|
571 |
my $config = shift;
|
- |
|
572 |
my %ignore = ( # list of config keys to ignore. Using hash for fast lookup
|
- |
|
573 |
'moduleDirs' => 1,
|
- |
|
574 |
'transports' => 1,
|
- |
|
575 |
'scriptDirs' => 1,
|
- |
|
576 |
'logging' => 1
|
- |
|
577 |
);
|
- |
|
578 |
my $report;
|
- |
|
579 |
# some presets for compatibility
|
- |
|
580 |
$report->{'report'}->{'version'} = $VERSION->normal; # global value
|
- |
|
581 |
$report->{'report'}->{'date'} = $reportDate; # global value
|
- |
|
582 |
$report->{'report'}->{'client'} = $config->{'clientName'};
|
- |
|
583 |
$report->{'system'}->{'hostname'} = $config->{'hostname'};
|
- |
|
584 |
$report->{'system'}->{'serial'} = $config->{'serialNumber'};
|
- |
|
585 |
$report->{'system'}->{'UUID'} = $config->{'UUID'};
|
- |
|
586 |
foreach my $key ( keys %$config ) {
|
- |
|
587 |
next if defined( $ignore{$key} ); # ignore anything in our ignore hash
|
- |
|
588 |
$report->{'system'}->{$key} = $config->{$key}; # simply copy to the system part of the report
|
- |
|
589 |
}
|
- |
|
590 |
return $report;
|
- |
|
591 |
}
|
- |
|
592 |
|
565 |
# simple display if --help is passed
|
593 |
# simple display if --help is passed
|
566 |
sub help {
|
594 |
sub help {
|
567 |
use File::Basename;
|
595 |
use File::Basename;
|
568 |
print basename($0) . " $VERSION\n";
|
596 |
print basename($0) . " $VERSION\n";
|
569 |
print <<END
|
597 |
print <<END
|
Line 597... |
Line 625... |
597 |
'client|c=s' => \$configuration{clientName},
|
625 |
'client|c=s' => \$configuration{clientName},
|
598 |
'serial|s=s' => \$configuration{serialNumber},
|
626 |
'serial|s=s' => \$configuration{serialNumber},
|
599 |
'hostname=s' => \$configuration{hostname},
|
627 |
'hostname=s' => \$configuration{hostname},
|
600 |
'modules|m=s' => \$configuration{moduleDirs},
|
628 |
'modules|m=s' => \$configuration{moduleDirs},
|
601 |
'scripts=s' => \$configuration{scriptDirs},
|
629 |
'scripts=s' => \$configuration{scriptDirs},
|
- |
|
630 |
'test|t=s' => \$TESTING
|
602 |
) or die "Error parsing command line\n";
|
631 |
) or die "Error parsing command line\n";
|
603 |
|
632 |
|
604 |
|
633 |
|
605 |
if ( $help ) { &help() ; exit; }
|
634 |
if ( $help ) { &help() ; exit; }
|
606 |
if ( $version ) { use File::Basename; print basename($0) . " $VERSION\n"; exit; }
|
635 |
if ( $version ) { use File::Basename; print basename($0) . " $VERSION\n"; exit; }
|
Line 626... |
Line 655... |
626 |
|
655 |
|
627 |
$TESTING = $configuration{'TESTING'} if defined $configuration{'TESTING'};
|
656 |
$TESTING = $configuration{'TESTING'} if defined $configuration{'TESTING'};
|
628 |
|
657 |
|
629 |
&logIt( 0, "Testing => $TESTING" ) if $TESTING;
|
658 |
&logIt( 0, "Testing => $TESTING" ) if $TESTING;
|
630 |
|
659 |
|
631 |
|
- |
|
632 |
my $System; # hash reference that will store all info we are going to send to the server
|
660 |
# hash reference that will store all info we are going to send to the server
|
633 |
# some defaults.
|
- |
|
634 |
$System->{'report'}->{'version'} = $VERSION->normal;
|
- |
|
635 |
$System->{'report'}->{'date'} = $reportDate;
|
- |
|
636 |
$System->{'report'}->{'client'} = $configuration{'clientName'};
|
- |
|
637 |
$System->{'system'}->{'hostname'} = $configuration{'hostname'};
|
- |
|
638 |
$System->{'system'}->{'serial'} = $configuration{'serialNumber'};
|
- |
|
639 |
$System->{'system'}->{'UUID'} = $configuration{'UUID'};
|
661 |
my $System = &initReport( \%configuration );
|
640 |
|
662 |
|
641 |
&logIt( 3, "Initial System\n" . Data::Dumper->Dump( [$System], [qw( $System )] ) );
|
663 |
&logIt( 3, "Initial System\n" . Data::Dumper->Dump( [$System], [qw( $System )] ) );
|
642 |
|
664 |
|
643 |
# process any modules in the system
|
665 |
# process any modules in the system
|
644 |
foreach my $moduleDir ( @{$configuration{'moduleDirs'}} ) {
|
666 |
foreach my $moduleDir ( @{$configuration{'moduleDirs'}} ) {
|