Subversion Repositories sysadmin_scripts

Rev

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

Rev 70 Rev 71
Line 1... Line 1...
1
#! /usr/bin/perl -w
1
#! /usr/bin/env perl
2
 
2
 
3
my @input = <>;
3
use warnings;
4
chomp @input;
4
use strict;
-
 
5
 
5
my $lastClient = '';
6
use YAML::Tiny;
6
#print scalar( @input ) . "\n";
7
use Data::Dumper;
-
 
8
 
7
@headers = split( "\t", shift(@input)  ) ;
9
my $input = join( '', <> );
-
 
10
 
-
 
11
 
8
foreach my $line (sort @input) {
12
my @data = Load($input);
9
   @values = split( "\t", $line ); 
13
my $hashref = $data[0];
-
 
14
 
10
   my %record = map{ $headers[$_],$values[$_] } (0 .. $#values);
15
#print Dumper( $hashref );
-
 
16
#die;
-
 
17
 
11
   if ( $lastClient ne $record{'# Client'} ) {
18
foreach my $group ( sort keys %$hashref ) {
12
      $lastClient = $record{ '# Client' };
19
   if ( $group ) { # only do a group header if it is not empty
13
      print "#########################################\n";
20
      my $header = '#'x10 . " $group " . '#'x10;
14
      print "#   " . $record{ '# Client' } . "\n";
21
      my $length = length( $header );
15
      print "#########################################\n";
22
      print "\n" . join( "\n", ( '#'x$length, $header, '#'x$length ) ) . "\n";
16
   }
23
   }
17
   foreach my $key ( sort keys %record ) {
24
   foreach my $host ( sort keys %{$hashref->{$group}} ) {
18
      next if $key eq '# Client';
25
      print "\nHost " . $host . "\n";
-
 
26
      foreach my $key ( sort keys %{$hashref->{$group}->{$host}} ) {
19
      print $key . ' 'x(10-length($key)) . $record{$key} . "\n" if $record{$key};
27
         print "$key $hashref->{$group}->{$host}->{$key}\n";
-
 
28
      }
20
   }
29
   }
21
   print "\n";
-
 
22
}
30
}
23
 
31
 
24
 
-
 
25
#print join( "\n", @headers );
-
 
26
 
-
 
27
1;
-
 
28
 
32
1;
-
 
33