Subversion Repositories camp_sysinfo_client_3

Rev

Go to most recent revision | Details | Last modification | View Log | RSS feed

Rev Author Line No. Line
16 rodolico 1
#!/usr/bin/env perl
20 rodolico 2
use warnings;
26 rodolico 3
use strict;  
2 rodolico 4
 
5
# sysinfo
6
# Author: R. W. Rodolico
7
# Primary client portion of sysinfo system. Will collect information about its current
8
# host and create a report containing the information. This report can then be processed
9
# by process_sysinfo.pl on the collection computer.
10
# output file consists of an XML file of the form:
11
#  <sysinfo3.0.0>
12
#    <diskinfo name='/dev/xvda3'>
13
#      <fstype>ext3</fstype>
14
#      <mount>/home</mount>
15
#      <size>51606140</size>
16
#      <used>331472</used>
17
#    </diskinfo>
18
#    <network name='eth0'>
19
#      <address>192.168.1.3</address>
20
#      <ip6address>fe80::216:3eff:fefb:4e10</ip6address>
21
#      <ip6networkbits>64</ip6networkbits>
22
#      <mac>00:16:3e:fb:4e:10</mac>
23
#      <mtu>1500</mtu>
24
#      <netmask>255.255.255.0</netmask>
25
#    </network>
26
#    <operatingsystem>
27
#      <codename>squeeze</codename>
28
#      <description>Debian GNU/Linux 6.0.4 (squeeze)</description>
29
#      <distribution>Debian</distribution>
30
#      <kernel>2.6.32-5-xen-686</kernel>
31
#      <os_name>Linux</os_name>
32
#      <os_version>Linux version 2.6.32-5-xen-686 (Debian 2.6.32-41) (ben@decadent.org.uk) (gcc version 4.3.5 (Debian 4.3.5-4) ) #1 SMP Mon Jan 16 19:46:09 UTC 2012</os_version>
33
#      <release>6.0.4</release>
34
#    </operatingsystem>
35
#    <pci name='0000:00:00.0'>
36
#      <class>RAM memory</class>
37
#      <device>MCP55 Memory Controller</device>
38
#      <rev>a2</rev>
39
#      <sdevice>Device cb84</sdevice>
40
#      <slot>0000:00:00.0</slot>
41
#      <svendor>nVidia Corporation</svendor>
42
#      <vendor>nVidia Corporation</vendor>
43
#    </pci>
44
#    <report>
45
#      <client>Staffmasters</client>
46
#      <date>2012-05-01 03:00</date>
47
#      <version>2.0.0</version>
48
#    </report>
49
#    <software name='aptitude'>
50
#      <description>terminal-based package manager (terminal interface only)</description>
51
#      <version>0.6.3-3.2+squeeze1</version>
52
#    </software>
53
#    <system>
54
#      <cpu_speed>1800.103</cpu_speed>
55
#      <cpu_sub>i686</cpu_sub>
56
#      <cpu_type>GenuineIntel</cpu_type>
57
#      <hostname>backup.staffmasters.local</hostname>
58
#      <last_boot>1333259809</last_boot>
59
#      <memory>520852</memory>
60
#      <num_cpu>1</num_cpu>
61
#    </system>
62
#  </sysinfo3.0.0>
63
 
64
 
65
#
66
# Version 1.3 20071104
67
# added capability of e-mailing the results by itself and external configuration file
68
 
69
# Version 1.3.1 20071110
70
# added du -sk to explicitly do directory sizes in 'k'. Also, fixed some documentation
71
 
72
# Version 1.3.3 20081104
73
# modified hostname to hostname -f, and allowed user to place custom value in configuration file
74
# also, modified to go with Debian standards in preparation to creating a debian package.
75
 
76
# Version 2.0 20081208
77
# Modified to use different libraries for different OS's in preparation to porting to Windows
78
# Uses different packages based on which OS it is on.
79
 
80
# Version 3.0 20120923
81
# Major revision. Most internal intelligence pulled out and put into modules and data transfer format has been changed to YAML
82
#
83
# Base system only pulls client name, machine name and machine number, all of which can be set in the configuration file
84
# if the value is not set, it attempts various means to determine the values and, if it fails, aborts with an error message
85
#    client name -- REQUIRED, must come from configuration file
86
#    machine name --  REQUIRED, if not set via conf file, attempts hostname command (hostname -f) or module getHostName
87
#    machine number -- REQUIRED, if not set via conf file, attempts "echo `hostname -f`-clientname | md5sum" or module getSerial
88
# modules are stored in "configuration directory/modules" (/etc/sysinfo/modules on most Linux systems) and are processed in 
89
# standard sort order (case sensitive). 
90
# Module filenames may contain alpha-numeric, underscore and the period only (files containing other characters are ignored).
91
# Modules should set their exit code to 0 for success, and non-zero for failure
92
# Modules should return 0 or more tab delimited, newline terminated strings, processed as one record per line
93
# A module return string line is processed as follows:
94
#     category \t [category \t ...] \t key \t value
95
# example:
96
#    System \t num_cpu \t 1
97
#    System \t Users \t root \t /root/
98
# (note, if non-zero exit code returned, return value is assumed to be error message and is printed to STDERR) 
99
# sysinfo stores the result in a hash, using categories as the keys (case sensitive), thus, the above results in
100
# $store{'System'}{'num_cpu'} = '1';
101
# $store{'System'}{'Users'}{'root'} = '/root';
102
# upon completion, sysinfo converts the $store hash into an XML or YAML string for transfer
103
# It then sends it to the main server as defined in the conf file.
104
# NOTE: YAML is hand crafted to kill any requirements for external libraries
105
# see sub hashToYAML for details
106
 
9 rodolico 107
# Version 3.0.1 20160321
108
# Renamed to sysinfo-client to not conflict with Linux package sysinfo
109
# created installer in Perl to not rely on package managers
110
# default path for configuration file changed to /etc/camp/sysinfo-client.conf
111
# $VERSION changed to $DATA_VERSION to not conflict with $main::VERSION (script version vs data format version)
13 rodolico 112
#
113
# Version 3.1.0 20160401
114
# module and script dirs now arrays to be searched. Idea is that default
115
#    modules/scripts are in installdir/modules or installdir/scripts, and
116
#    user supplied are in /etc/scripts and /etc/modules
14 rodolico 117
# Tightened up the file systems checks, requiring all scripts and modules
118
#    be set 0700 at least, and owned by root
18 rodolico 119
# Transport layers now an array, and if one fails to send the report, the others
120
#    are tried in turn
14 rodolico 121
# Worked on logic for sendReport to give better error checking.
122
# Doing a search for the configuration file matching cwd, then /etc/camp, then /usr/local/etc/camp
21 rodolico 123
# Self documenting, ie a key for software\tsysinfo-client\version\current version is inserted
28 rodolico 124
#
125
# Version 3.1.1 20160915 RWR
126
# set use strict and use warnings, then fixed errors
37 rodolico 127
#
128
# Version 3.1.2 20160922 RWR
129
# $exitCode 1 (not applicable to this machine) does not throw warning
130
#
42 rodolico 131
# Version 3.1.3 20161010 RWR
132
# Removed extra use warnings
47 rodolico 133
#
134
# Version 3.1.4 20161023 RWR
135
# Would error out if moduledir does not exist, added a return
51 rodolico 136
#
137
# Version 3.1.5 20170327 RWR
138
# On freeBSD systems, was looking in wrong place for configuration file
59 rodolico 139
#
140
# Version 3.2.0 20180320 RWR
141
# changed configuration to be loaded into hash (vs directly loaded into variables)
142
# added UUID to configuration file
143
# install.pl should automagically convert conf file
9 rodolico 144
 
2 rodolico 145
# Following are global variables overridden if configuration file exists
146
 
61 rodolico 147
my $TESTING = 3; # level's 0 (none) to 3 defined and increase verbosity while decreasing functionality
51 rodolico 148
our $VERSION = '3.1.5';
9 rodolico 149
 
2 rodolico 150
my $indentLevel = 2; # number of spaces to indent per level in XML or YAML
151
 
152
$indentLevel = 3 if $TESTING;
153
if ($TESTING) {
154
   use Data::Dumper;
155
}
156
 
13 rodolico 157
# paths to search for configuration file
51 rodolico 158
my @confFileSearchPath = ( '.', '/etc/camp/sysinfo-client', '/etc/camp', '/usr/local/etc/camp/sysinfo-client' );
2 rodolico 159
 
13 rodolico 160
my $configurationFile = 'sysinfo-client.conf'; # name of the configuration file
2 rodolico 161
 
162
my $reportDate = &getReportDate; # set report date
163
 
59 rodolico 164
my %configuration = (
61 rodolico 165
   'moduleDirs' => [], # search paths for modules
166
   'scriptDirs' => [], # search paths for scripts
59 rodolico 167
   'clientName' => '',  # Required!! Must be set in conf file (no defaults)
168
   'serialNumber' => '', # serial number of machine
169
   'UUID'         => '', # UUID of machine
61 rodolico 170
   'transports'   => [], # hash with various transports
171
   'hostname' => &getHostName() # fully qualified host name of machine
59 rodolico 172
)
173
;
2 rodolico 174
 
9 rodolico 175
my $DATA_VERSION = '3.0.0'; # used in sending the data file. sets version of XML/YAML data file
2 rodolico 176
 
13 rodolico 177
 
178
 
2 rodolico 179
#######################################################
180
#
13 rodolico 181
# findFile( $filename, @directories )
182
#
183
# Locates a file by searching sequentially in one or more
184
# directories, returning the first one found
185
# 
186
# Returns '' if not found
187
#
188
#######################################################
189
 
190
sub findFile {
59 rodolico 191
   my ( $filename, $directories ) = @_;
192
   for ( my $i = 0; $i < scalar( @{$directories} ); $i++ ) {
193
      my $confFile = $$directories[$i] . '/' . $filename;
13 rodolico 194
      return $confFile if ( -f $confFile );
195
   }
196
   return '';
197
}
198
 
199
 
200
#######################################################
201
#
2 rodolico 202
# loadConfigurationFile($confFile)
203
#
204
# Loads configuration file defined by $configurationFile, and dies if not available
205
# Reads entire contents into memory where it is eval'd in main program
206
# Parameters: configuration file fully path/file name
207
# NOTE: conf file must be a valid Perl file
208
#
209
#######################################################
210
 
211
sub loadConfigurationFile {
14 rodolico 212
   my ( $fileName, @searchPath ) = @_;
13 rodolico 213
   my $confFile;
59 rodolico 214
   if ( $confFile = &findFile( $fileName, \@searchPath ) ) {
61 rodolico 215
      print "Opening configuration from $confFile\n" if $TESTING > 2;
13 rodolico 216
      open CONFFILE, "<$confFile" or die "Can not open configuration file $confFile: $!\n";
217
      my $confFileContents = join( '', <CONFFILE> ); # just slurp it into memory
218
      close CONFFILE;
219
      return ($confFileContents);
220
   }
14 rodolico 221
   die "Can not find $fileName in any of " . join( "\n\t", @searchPath ) . "\n";
2 rodolico 222
}
223
 
224
#######################################################
225
#
226
# sendResults( $parameters, $message, $scriptDirectory )
227
#
228
# Sends results of run to server using external script. If external
229
# script not defined, just print to STDOUT
230
#
231
# Parameters
232
#  $parameters - a hash containing the information necessary to make the transfer
233
#  $message - the message to be sent
234
#  $scriptDirectory - path (not filename) of script to be executed
235
# 
236
# $parameters contains different key/value pairs depending on the script used
237
#             for example, a stand-alone SMTP script may need a username/password,
238
#             smtp server name, port number, from and to address
239
#             while an http transfer may only need a script name
240
#             See the individual scripts to determine what parameters need to be
241
#             filled in.
242
#             The only required parameter is 'sendScript' which must contain the
243
#             name of the script to execute (and it must be located in $scriptDirectory)
244
# SCRIPT must contain one sub named doit, that accepts three parameters, the hash, 
245
#       the message, and, optionally, the script directory
246
#
247
# If script not defined, just dump to STDOUT. With a properly set up cron job, the output
248
# would then be sent via e-mail to an administrative account, possibly root
249
#
250
#######################################################
251
sub sendResults {
59 rodolico 252
   my ( $globals, $parameters, $message, $scriptDirectory ) = @_;
18 rodolico 253
   foreach my $key ( sort { $a <=> $b } keys %$parameters ) {
19 rodolico 254
      if ( $$parameters{$key}{'sendScript'} ) {
255
         # print "Trying to find file " . $$parameters{$key}{'sendScript'} . " in " . join( "\n\t", @scriptDirectory ) . "\n";
59 rodolico 256
         my $sendScript = &findFile( $$parameters{$key}{'sendScript'}, @{$scriptDirectory} );
19 rodolico 257
         if ( $sendScript ) {
18 rodolico 258
            # load the chosen script into memory
259
            require $sendScript;
19 rodolico 260
            # merge the globals in
261
            while ( my ( $gkey, $value ) = each %$globals ) { 
262
               $$parameters{$key}{$gkey} = $value; 
263
            }
20 rodolico 264
            # do variable substitution for any values which need it
265
            foreach my $thisOne ( keys %{$$parameters{$key}} ) {
266
               #print "$thisOne\n";
61 rodolico 267
               if ( $$parameters{$key}{$thisOne} =~ m/(\$configuration\{'hostname'\})|(\$reportDate)|(\$configuration\{'clientName'\})|(\$configuration\{'serialNumber'\})/ ) {
20 rodolico 268
                  $$parameters{$key}{$thisOne} = eval "\"$$parameters{$key}{$thisOne}\"";
269
               }
270
            }
271
 
19 rodolico 272
            #%$parameters{$key}{keys %$globals} = values %$globals;
273
            #print Dumper( $$parameters{$key} );
20 rodolico 274
            #next;
18 rodolico 275
            # execute the "doit" sub from that script
28 rodolico 276
            my $return = &doit( $$parameters{$key}, $message );
18 rodolico 277
            return $return if ( $return == 1 );
278
         } else {
279
            print "Could not find " . $$parameters{$key}{'sendScript'} . ", trying next transport\n";
280
         } # if..else
281
      } # if
282
   } # foreach
283
   # if we made it here, we have not sent the report, so just return it to the user
284
   print $message;
16 rodolico 285
   return 1;
2 rodolico 286
}
287
 
288
#######################################################
289
#
290
# getReportDate
291
#
292
# return current system date as YYYY-MM-DD HH:MM:SS
293
#
294
#######################################################
295
sub getReportDate {
28 rodolico 296
   my ($second, $minute, $hour, $dayOfMonth, $month, $year) = localtime();
2 rodolico 297
   return sprintf( "%4u-%02u-%02u %02u:%02u:%02u", $year+1900, $month+1, $dayOfMonth, $hour, $minute, $second );
298
}
299
 
300
#######################################################
301
#
302
# getHostName
303
#
304
# return hostname from hostname -f
305
#
306
#######################################################
307
sub getHostName {
28 rodolico 308
   my $hostname = `hostname -f`;
2 rodolico 309
   chomp $hostname;
310
   return $hostname;
311
}
312
 
313
#######################################################
314
#
18 rodolico 315
# escapeForYAML
2 rodolico 316
#
18 rodolico 317
# Escapes values put into YAML report
2 rodolico 318
#
319
#######################################################
320
sub escapeForYAML {
321
   my $value = shift;
322
   $value =~ s/'/\\'/gi; # escape single quotes
323
   $value =~ s/"/\\"/gi; # escape double quotes
324
   # pound sign indicates start of a comment and thus loses part
325
   # of strings. Surrounding it by double quotes in next statement
326
   # allows 
327
   $value = '"' . $value . '"' if ( $value =~ m/[#:]/ );
328
   return $value;
329
}
330
 
331
#######################################################
332
#
333
# hashToYAML( $hashRef, $indent )
334
#
335
# Converts a hash to a YAML string
336
#
337
# NOTE: This routine recursively calls itself for every level
338
#       in the hash
339
#
340
# Parameters
341
#     $hashref - reference (address) of a hash
342
#     $indent  - current indent level, defaults to 0
343
#
344
# Even though there are some very good libraries that do this
345
# I chose to hand-code it so sysinfo can be run with no libraries
346
# loaded. I chose to NOT do a full implementation, so special chars
347
# that would normally be escaped are not in here. 
348
# However, I followed all the RFC for the values that were given, so
349
# assume any YAML reader can parse this
350
# NOTE: YAML appears to give a resulting file 1/3 smaller than the above
351
#       XML, and compresses down in like manner
352
#
353
#######################################################
354
sub hashToYAML {
355
   my ($hashRef, $indent) = @_;
356
   $indent = 0 unless $indent; # default to 0 if not defined
357
 
358
   my $output; # where the output is stored
359
   foreach my $key ( keys %$hashRef ) { # for each key in the current reference
360
      print "Looking at $key\n" if $TESTING > 3;
361
      # see http://www.perlmonks.org/?node_id=175651 for isa function
362
      if ( UNIVERSAL::isa( $$hashRef{$key}, 'HASH' ) ) { # is the value another hash?
363
            # NOTE: unlike xml, indentation is NOT optional in YAML, so the following line verifies $indentlevel is non-zero
364
            #       and, if it is, uses a default 3 character indentation
365
            $output .= (' ' x $indent ) . &escapeForYAML($key) . ":\n" . # key, plus colon, plus newline
366
                    &hashToYAML( $$hashRef{$key}, $indent+($indentLevel ? $indentLevel : 3) ) . # add results of recursive call
367
                    "\n";
368
      } elsif ( UNIVERSAL::isa( $$hashRef{$key}, 'ARRAY' ) ) { # is it an array? ignore it
369
      } else { # it is a scalar, so just do <key>value</key>
370
         $output .= (' ' x $indent ) . &escapeForYAML($key) . ': ' . &escapeForYAML($$hashRef{$key}) . "\n";
371
      }
372
   }
373
   return $output;
374
}
375
 
376
 
377
#######################################################
378
#
379
# tabDelimitedToHash ($hashRef, $tabdelim)
380
#
381
# Takes a tab delimited multi line string and adds it
382
# to a hash. The final field in each line is considered to
383
# be the value, and all prior fields are considered to be
384
# hierachial keys.
385
#
386
# Parameters
387
#     $hashref - reference (address) of a hash
388
#     $tabdelim - A tab delimited, newline terminated set of records
389
#
390
#
391
#######################################################
392
sub tabDelimitedToHash {
393
   my ($hashRef, $tabdelim) = @_;
394
   foreach my $line ( split( "\n", $tabdelim ) ) { # split on newlines, then process each line in turn
395
      $line =~ s/'/\\'/gi; # escape single quotes
28 rodolico 396
      my @fields = split( / *\t */, $line ); # get all the field values into array
2 rodolico 397
      my $theValue = pop @fields; # the last one is the value, so save it
398
      # now, we build a Perl statement that would create the assignment. The goal is
399
      # to have a string that says something like $$hashRef{'key'}{'key'} = $value;
400
      # then, eval that.
401
      my $command = '$$hashRef'; # start with the name of the dereferenced hash (parameter 1)
402
      while (my $key = shift @fields) { # while we have a key, from left to right
403
         $command .= '{' . "'$key'" . '}'; # build it as {'key'} concated to string
404
      }
405
      $command .= "='$theValue';"; # add the assignment
406
      #print STDERR "$command\n"; 
407
      eval $command; # eval the string to make the actual assignment
408
   }
409
}
410
 
411
#######################################################
412
#
13 rodolico 413
# validatePermission ( $file )
414
#
415
# Checks that file is owned by root, and has permission
416
# 0700 or less
417
# 
418
# Returns empty string on success, error message
419
# on failure
420
#
421
#######################################################
422
 
423
sub validatePermission {
424
   my $file = shift;
14 rodolico 425
   my $return;
13 rodolico 426
   # must be owned by root
28 rodolico 427
   my $owner = (stat($file))[4];
13 rodolico 428
   $return .= " - Bad Owner [$owner]" if $owner;
429
   # must not have any permissions for group or world
430
   # ie, 0700 or less
28 rodolico 431
   my $mode = (stat($file))[2];
13 rodolico 432
   $mode = sprintf( '%04o', $mode & 07777 );
433
   $return .= " - Bad Permission [$mode]" unless $mode =~ m/0.00/;
434
   return $return ? $file . $return : '';
435
}
436
 
437
#######################################################
438
#
2 rodolico 439
# ProcessModules ( $system, $moduleDir )
440
#
441
# Processes all modules in $moduleDir, adding result to $system hash
442
# 
443
# Parameters
444
#     $system - reference (address) of a hash
445
#     $moduleDir - full path to a directory containing executable scripts
446
#  
447
# Each file in the $moduleDir directory that matches the regex in the grep
448
# and is executable is run. It is assumed the script will return 0 on success
449
# or a non-zero on failure
450
# The output of the script is assumed to be a tab delimited, newline separated
451
# list of records that should be added to the hash $system. This is done by calling 
452
# &parseModule above.
453
# on failure, the returned output of the script is assumed to be an error message
454
# and is displayed on STDERR
455
#######################################################
456
sub ProcessModules {
457
   my ( $system, $moduleDir ) = @_;
458
   # open the module directory
47 rodolico 459
   return unless -d $moduleDir;
2 rodolico 460
   opendir( my $dh, $moduleDir ) || die "Module Directory $moduleDir can not be opened: $!\n";
461
   # and get all files which are executable and contain nothing but alpha-numerics and underscores (must begin with alpha-numeric)
462
   my @modules = grep { /^[a-zA-Z0-9][a-zA-Z0-9_]+$/ && -x "$moduleDir/$_" } readdir( $dh );
463
   closedir $dh;
28 rodolico 464
   foreach my $modFile ( sort @modules ) { # for each valid script
14 rodolico 465
      if ( my $error = &validatePermission( "$moduleDir$modFile" ) ) {
13 rodolico 466
         print STDERR "Not Processed: $error\n";
467
         next;
468
      }
2 rodolico 469
      print "Processing module $moduleDir$modFile\n" if $TESTING > 2;
470
      my $output = qx/$moduleDir$modFile $moduleDir/; # execute it and grab the output
471
      my $exitCode = $? >> 8; # process the exitCode
37 rodolico 472
      # exitCode 0 - processed normally
473
      # exitCode 1 - not applicable to this machine
474
      if ( $exitCode && $exitCode > 1) { # if non-zero, error, so show an error message
2 rodolico 475
         warn "Error in $moduleDir$modFile, [$output]\n";
476
      } else { # otherwise, call tabDelimitedToHash to save the data
477
         &tabDelimitedToHash( $system, $output );
21 rodolico 478
      } # if
479
   } # foreach
480
   # add sysinfo-client (me) to the software list, since we're obviously installed
481
   &tabDelimitedToHash( $system, "software\tsysinfo-client\tversion\t$main::VERSION\n" );
2 rodolico 482
}
483
 
20 rodolico 484
sub processParameters {
485
   while ( my $parameter = shift ) {
486
      if ( $parameter eq '-v' ) {
487
         print "$main::VERSION\n";
488
         exit;
489
      }
490
   } # while
491
}
492
 
493
&processParameters( @ARGV );
494
 
14 rodolico 495
# load the configuration file
13 rodolico 496
 
14 rodolico 497
#die "Searching for $configurationFile in = \n" . join( "\n", @confFileSearchPath ) . "\n";
13 rodolico 498
eval ( &loadConfigurationFile( $configurationFile, @confFileSearchPath) );
61 rodolico 499
die Dumper( \%configuration ) . "\n" if $TESTING > 4;
500
 
2 rodolico 501
# user did not define a serial number, so make something up
59 rodolico 502
$configuration{'serialNumber'} = '' unless $configuration{'serialNumber'};
2 rodolico 503
# oops, no client name (required) so tell them and exit
61 rodolico 504
die "No client name defined in $configurationFile" unless $configuration{'clientName'};
2 rodolico 505
 
61 rodolico 506
$TESTING = $configuration{'TESTING'} if defined $configuration{'TESTING'};
507
 
2 rodolico 508
my $System; # hash reference that will store all info we are going to send to the server
509
# some defaults.
9 rodolico 510
$$System{'report'}{'version'} = $DATA_VERSION;
2 rodolico 511
$$System{'report'}{'date'} = $reportDate;
59 rodolico 512
$$System{'report'}{'client'} = $configuration{'clientName'};
513
$$System{'system'}{'hostname'} = $configuration{'hostname'};
514
$$System{'system'}{'serial'} = $configuration{'serialNumber'};
2 rodolico 515
 
516
# process any modules in the system
59 rodolico 517
foreach my $moduleDir ( @{$configuration{'moduleDirs'}} ) {
13 rodolico 518
   &ProcessModules( $System, "$moduleDir/" );
519
}
2 rodolico 520
 
521
# now, everything ins in $System, so convert it to the proper output format
20 rodolico 522
my $out =  "#sysinfo: $VERSION YAML\n---\n" . &hashToYAML( $System ) . "...\n";
2 rodolico 523
 
61 rodolico 524
print Data::Dumper->Dump([$System],['System']) if $TESTING>2;
2 rodolico 525
 
19 rodolico 526
# load some global values for use in the script, if required
527
my $globals = { 
528
      'data version' => $DATA_VERSION,
529
      'report date'  => $reportDate,
59 rodolico 530
      'client name'  => $configuration{'clientName'},
531
      'host name'    => $configuration{'hostname'},
61 rodolico 532
      'serial number'=> $configuration{'serialNumber'},
533
      'UUID'         => $configuration{'UUID'}
19 rodolico 534
      };
61 rodolico 535
die;
2 rodolico 536
# and send the results to the server
59 rodolico 537
if ( my $success = &sendResults( $globals, $configuration{'transports'}, $out, $configuration{'scriptDirs'} ) != 1 ) {
538
   print "Error $success while sending report from $configuration{'hostname'}\n";
16 rodolico 539
}
2 rodolico 540
 
9 rodolico 541
1;