Subversion Repositories havirt

Rev

Rev 12 | Rev 19 | Go to most recent revision | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 12 Rev 13
Line 51... Line 51...
51
   return join( "\n", @return ) . "\n";
51
   return join( "\n", @return ) . "\n";
52
}
52
}
53
 
53
 
54
sub status {
54
sub status {
55
   my $return = '';
55
   my $return = '';
56
   &main::loadDB();
56
   &main::readDB();
57
   my @header = ('Node','Threads','Memory','Domains','vcpu','mem_used' );
57
   my @header = ('Node','Threads','Memory','Domains','vcpu','mem_used' );
58
   my @data;
58
   my @data;
59
   my $usedmem = 0;
59
   my $usedmem = 0;
60
   my $usedcpu = 0;
60
   my $usedcpu = 0;
61
   my $availmem = 0;
61
   my $availmem = 0;
62
   my $availcpu = 0;
62
   my $availcpu = 0;
63
   my $totalDomains = 0;
63
   my $totalDomains = 0;
64
   foreach my $node (sort keys %$main::nodeDB ) {
64
   foreach my $node (sort keys %{ $main::statusDB->{'node'} } ) {
65
      my $memory = 0;
65
      my $memory = 0;
66
      my $vcpus = 0;
66
      my $vcpus = 0;
67
      my $count = 0;
67
      my $count = 0;
68
      foreach my $domain ( keys %{ $main::nodePopulations->{$node}->{'running'} } ) {
68
      foreach my $domain ( keys %{ $main::statusDB->{'nodePopulation'}->{$node}->{'running'} } ) {
69
         $memory += $main::virtDB->{$domain}->{'memory'};
69
         $memory += $main::statusDB->{'virt'}->{$domain}->{'memory'};
70
         $vcpus += $main::virtDB->{$domain}->{'vcpu'};
70
         $vcpus += $main::statusDB->{'virt'}->{$domain}->{'vcpu'};
71
         $count++;
71
         $count++;
72
      }
72
      }
73
      push @data, [ $node,$main::nodeDB->{$node}->{cpu_count},$main::nodeDB->{$node}->{memory},$count,$vcpus,$memory ];
73
      push @data, [ $node,$main::statusDB->{'node'}->{$node}->{cpu_count},$main::statusDB->{'node'}->{$node}->{memory},$count,$vcpus,$memory ];
74
      $usedmem += $memory;
74
      $usedmem += $memory;
75
      $usedcpu += $vcpus;
75
      $usedcpu += $vcpus;
76
      $totalDomains += $count;
76
      $totalDomains += $count;
77
      $availmem += $main::nodeDB->{$node}->{memory};
77
      $availmem += $main::statusDB->{'node'}->{$node}->{memory};
78
      $availcpu += $main::nodeDB->{$node}->{cpu_count};
78
      $availcpu += $main::statusDB->{'node'}->{$node}->{cpu_count};
79
   } # outer for
79
   } # outer for
80
   push @data, [ 'Total',$availcpu,$availmem,$totalDomains,$usedcpu,$usedmem ];
80
   push @data, [ 'Total',$availcpu,$availmem,$totalDomains,$usedcpu,$usedmem ];
81
   return &main::report( \@header, \@data );
81
   return &main::report( \@header, \@data );
82
}
82
}