/[BackupPC]/trunk/bin/BackupPC_xls_report
This is repository of my old source code which isn't updated any more. Go to git.rot13.org for current projects!
ViewVC logotype

Diff of /trunk/bin/BackupPC_xls_report

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 107 by dpavlin, Mon Aug 22 09:46:57 2005 UTC revision 108 by dpavlin, Wed Aug 31 21:22:48 2005 UTC
# Line 1  Line 1 
1  #!/usr/local/bin/perl  #!/usr/bin/perl
2    
3  use strict;  use strict;
4  use lib "__INSTALLDIR__/lib";  use lib "__INSTALLDIR__/lib";
# Line 13  my $xls_file = '/tmp/report.xls'; Line 13  my $xls_file = '/tmp/report.xls';
13  my $workbook  = Spreadsheet::WriteExcel->new($xls_file) || die "can't write to $xls_file: $!";  my $workbook  = Spreadsheet::WriteExcel->new($xls_file) || die "can't write to $xls_file: $!";
14    
15  my @cols = qw(  my @cols = qw(
16    hostname
17  type  type
18  num  num
19  startTime  startTime
20  endTime  endTime
21  =D##-C##,duration  =E##-D##,duration
22  level  level
23  noFill  noFill
24  fillFromNum  fillFromNum
# Line 39  sizeExist Line 40  sizeExist
40    
41  compress  compress
42  sizeNewComp  sizeNewComp
43  =V##/S##,sizeNewRatio  =W##/T##,sizeNewRatio
44  sizeExistComp  sizeExistComp
45  =X##/T##,sizeExistRatio  =Y##/U##,sizeExistRatio
46  );  );
47    
48  my $date_format = $workbook->add_format(num_format => 'yyyy-mm-dd hh:mm:ss');  my $date_format = $workbook->add_format(num_format => 'yyyy-mm-dd hh:mm:ss');
# Line 67  my $TopDir = $bpc->TopDir(); Line 68  my $TopDir = $bpc->TopDir();
68    
69  my $hosts = $bpc->HostInfoRead();  my $hosts = $bpc->HostInfoRead();
70    
71    my $worksheet = $workbook->add_worksheet('BackupPC');
72    my $row = 0;
73    
74    my $i = 0;
75    # insert sheet header (with formatting)
76    foreach my $c (@cols) {
77            if ($c =~ m/^=.*,(.+)/) {
78                    $worksheet->write($row, $i++, $1, $header_format);
79            } else {
80                    $worksheet->write($row, $i++, $c, $header_format);
81            }
82    }
83    $row++;
84    
85  foreach my $host_key (sort keys %{$hosts}) {  foreach my $host_key (sort keys %{$hosts}) {
86    
87          my $hostname = $hosts->{$host_key}->{'host'} || die "can't find host for $host_key";          my $hostname = $hosts->{$host_key}->{'host'} || die "can't find host for $host_key";
88    
89          print $hostname, " ";          print $hostname, " ";
90    
         my $worksheet = $workbook->add_worksheet($hostname);  
   
91          # get backups for a host          # get backups for a host
92          my @backups = $bpc->BackupInfoRead($hostname);          my @backups = $bpc->BackupInfoRead($hostname);
93          print scalar @backups, " increments\n";          print scalar @backups, " increments\n";
94    
         my $row = 0;  
95          my $i = 0;          my $i = 0;
96            $worksheet->write($row, $i++, $hostname);
         foreach my $c (@cols) {  
                 if ($c =~ m/^=.*,(.+)/) {  
                         $worksheet->write($row, $i++, $1, $header_format);  
                 } else {  
                         $worksheet->write($row, $i++, $c, $header_format);  
                 }  
         }  
         $row++;  
97    
98          foreach my $backup (@backups) {          foreach my $backup (@backups) {
99                  for (my $i = 0; $i <= $#cols; $i++) {                  for (my $i = 0; $i <= $#cols; $i++) {

Legend:
Removed from v.107  
changed lines
  Added in v.108

  ViewVC Help
Powered by ViewVC 1.1.26