Subversion Repositories havirt

Rev

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

Rev 19 Rev 25
Line 52... Line 52...
52
}
52
}
53
 
53
 
54
sub status {
54
sub status {
55
   my $return = '';
55
   my $return = '';
56
   &main::readDB();
56
   &main::readDB();
57
   my @header = ('Node','Threads','Memory','Domains','vcpu','mem_used' );
57
   my @header = ('Node','Threads','Memory','Domains','vcpu','mem_used', 'Status' );
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
   my $maintenance = 0;
64
   foreach my $node (sort keys %{ $main::statusDB->{'node'} } ) {
65
   foreach my $node (sort keys %{ $main::statusDB->{'node'} } ) {
65
      my $memory = 0;
66
      my $memory = 0;
66
      my $vcpus = 0;
67
      my $vcpus = 0;
67
      my $count = 0;
68
      my $count = 0;
68
      foreach my $domain ( keys %{ $main::statusDB->{'nodePopulation'}->{$node}->{'running'} } ) {
69
      foreach my $domain ( keys %{ $main::statusDB->{'nodePopulation'}->{$node}->{'running'} } ) {
69
         $memory += $main::statusDB->{'virt'}->{$domain}->{'memory'};
70
         $memory += $main::statusDB->{'virt'}->{$domain}->{'memory'};
70
         $vcpus += $main::statusDB->{'virt'}->{$domain}->{'vcpu'};
71
         $vcpus += $main::statusDB->{'virt'}->{$domain}->{'vcpu'};
71
         $count++;
72
         $count++;
72
      }
73
      }
73
      push @data, [ $node,$main::statusDB->{'node'}->{$node}->{cpu_count},$main::statusDB->{'node'}->{$node}->{memory},$count,$vcpus,$memory ];
74
      push @data, [ $node,$main::statusDB->{'node'}->{$node}->{cpu_count},$main::statusDB->{'node'}->{$node}->{memory},$count,$vcpus,$memory, $main::statusDB->{'node'}->{$node}->{maintenance} ? 'Maintenance' : 'Online' ];
74
      $usedmem += $memory;
75
      $usedmem += $memory;
75
      $usedcpu += $vcpus;
76
      $usedcpu += $vcpus;
76
      $totalDomains += $count;
77
      $totalDomains += $count;
77
      $availmem += $main::statusDB->{'node'}->{$node}->{memory};
78
      $availmem += $main::statusDB->{'node'}->{$node}->{memory};
78
      $availcpu += $main::statusDB->{'node'}->{$node}->{cpu_count};
79
      $availcpu += $main::statusDB->{'node'}->{$node}->{cpu_count};
-
 
80
      $maintenance += $main::statusDB->{'node'}->{$node}->{maintenance} ? 1 : 0;
79
   } # outer for
81
   } # outer for
80
   push @data, [ 'Total',$availcpu,$availmem,$totalDomains,$usedcpu,$usedmem ];
82
   push @data, [ 'Total',$availcpu,$availmem,$totalDomains,$usedcpu,$usedmem, $maintenance ];
81
   return &main::report( \@header, \@data );
83
   return &main::report( \@header, \@data );
82
}
84
}