Subversion Repositories camp_sysinfo_client_3

Rev

Rev 248 | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 248 Rev 249
Line 22... Line 22...
22
# version 2.2.1 20191112 RWR
22
# version 2.2.1 20191112 RWR
23
# added timeStamp
23
# added timeStamp
24
#
24
#
25
# version 2.3.0 20220609 RWR
25
# version 2.3.0 20220609 RWR
26
# moved loadConfigurationFile and timeStamp here
26
# moved loadConfigurationFile and timeStamp here
-
 
27
#
-
 
28
# version 2.3.1 20241224 RWR
-
 
29
# set server info file to be in either /etc or /usr/local/etc
27
 
30
 
28
package sysinfoconf;
31
package sysinfoconf;
29
 
32
 
30
 
33
 
31
our $VERSION = '2.3.0';
34
our $VERSION = '2.3.1';
32
use warnings;
35
use warnings;
33
use strict;  
36
use strict;  
34
 
37
 
35
#use Data::Dumper;
38
#use Data::Dumper;
36
use YAML::Tiny;
39
use YAML::Tiny;
Line 62... Line 65...
62
   '0123456789' => '' # used by some SuperMicro computers
65
   '0123456789' => '' # used by some SuperMicro computers
63
);
66
);
64
 
67
 
65
my %UUIDTranslation = ( 
68
my %UUIDTranslation = ( 
66
   '03000200-0400-0500-0006-000700080009' => '', # some routers
69
   '03000200-0400-0500-0006-000700080009' => '', # some routers
67
   'sot settable' => '' # not set in DMI
70
   'not settable' => '' # not set in DMI
68
);
71
);
69
 
72
 
70
# paths to search for configuration file
73
# paths to search for configuration file
71
my @confFileSearchPath = ( '.', '/etc/camp/sysinfo-client', '/etc/camp', '/usr/local/etc/camp/sysinfo-client' );
74
my @confFileSearchPath = ( '.', '/etc/camp/sysinfo-client', '/etc/camp', '/usr/local/etc/camp/sysinfo-client' );
72
my $serverInfoFileName = '/etc/server.info';
75
my @serverInfoFileName = ( '/etc/server.info', '/usr/local/etc/server.info' );
73
 
76
 
74
our %displayOrder = (
77
our %displayOrder = (
75
      '1' => {
78
      '1' => {
76
         'fieldname' => 'clientName',
79
         'fieldname' => 'clientName',
77
         'display' => 'Client Name',
80
         'display' => 'Client Name',
Line 241... Line 244...
241
   } # foreach
244
   } # foreach
242
   return $config;
245
   return $config;
243
} # transportsToConfig
246
} # transportsToConfig
244
 
247
 
245
sub readServerInfo {
248
sub readServerInfo {
246
   my $serverInfoName = shift;
-
 
247
   my %return;
249
   my %return;
248
 
250
 
249
   print "Reading server info from $serverInfoName\n";
251
   while ( my $serverInfoName = shift ) {
250
   
-
 
251
   if ( -f $serverInfoName ) {
252
      if ( -f $serverInfoName ) {
-
 
253
      print "Reading server info from $serverInfoName\n";
252
      print "found $serverInfoName\n";
254
         print "found $serverInfoName\n";
253
      open DATA, $serverInfoName or die "Could not read $serverInfoName: $!\n";
255
         open DATA, $serverInfoName or die "Could not read $serverInfoName: $!\n";
254
      print "opened $serverInfoName\n";
256
         print "opened $serverInfoName\n";
255
      while ( my $line = <DATA> ) {
257
         while ( my $line = <DATA> ) {
256
         next if $line =~ m/^#/;
258
            next if $line =~ m/^#/;
257
         chomp $line;
259
            chomp $line;
258
         next if $line =~ m/^\s*$/;
260
            next if $line =~ m/^\s*$/;
259
         my ($key,$value) = split( ':', $line );
261
            my ($key,$value) = split( ':', $line );
260
         $key =~ s/^\s+|\s+$//g;
262
            $key =~ s/^\s+|\s+$//g;
261
         $value =~ s/^\s+|\s+$//g;
263
            $value =~ s/^\s+|\s+$//g;
262
         # note, we make the key lower case so we can find it
264
            # note, we make the key lower case so we can find it
263
         $return{ lc $key} = $value;
265
            $return{ lc $key} = $value;
-
 
266
         }
264
      }
267
      }
265
   }
268
   }
266
   return \%return;
269
   return \%return;
267
}
270
}
268
 
271
 
269
 
272
 
270
sub makeConfig {
273
sub makeConfig {
271
   my $configFile = shift;
274
   my $configFile = shift;
272
   my $config = {}; # make sure it is a ref to a hash so mergeHash can recognize it
275
   my $config = {}; # make sure it is a ref to a hash so mergeHash can recognize it
273
   my $serverInfo = readServerInfo( $serverInfoFileName );
276
   my $serverInfo = readServerInfo( @serverInfoFileName );
274
   # die Dumper( $serverInfo );
277
   # die Dumper( $serverInfo );
275
   if ( -f $configFile ) {
278
   if ( -f $configFile ) {
276
      print "Processing config file $configFile\n";
279
      print "Processing config file $configFile\n";
277
      my $yaml = YAML::Tiny->read( $configFile );
280
      my $yaml = YAML::Tiny->read( $configFile );
278
      $config = $yaml->[0];
281
      $config = $yaml->[0];