Subversion Repositories sysadmin_scripts

Rev

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

Rev 144 Rev 145
Line 46... Line 46...
46
   print "\tnode update [node] [node]... # update a given node (or ALL)\n";
46
   print "\tnode update [node] [node]... # update a given node (or ALL)\n";
47
   print "\tnode list # display tab delimited list of node specs\n";
47
   print "\tnode list # display tab delimited list of node specs\n";
48
   print "\tnode scan # find domains on all nodes\n ";
48
   print "\tnode scan # find domains on all nodes\n ";
49
   print "\tdomain update ALL|RUNNING|[domain] [domain]... # update domains\n";
49
   print "\tdomain update ALL|RUNNING|[domain] [domain]... # update domains\n";
50
   print "\tdomain list ALL|RUNNING|[domain] [domain]... # display tab delimited list of domain specs\n";
50
   print "\tdomain list ALL|RUNNING|[domain] [domain]... # display tab delimited list of domain specs\n";
-
 
51
   print "\tcluster status # report of memory and vcpu status on all nodes\n";
51
}
52
}
52
 
53
 
53
sub readDB {
54
sub readDB {
54
   my ($filename) = @_;
55
   my ($filename) = @_;
55
   my $yaml = YAML::Tiny->new( {} );
56
   my $yaml = YAML::Tiny->new( {} );
Line 243... Line 244...
243
      &writeDB( $nodePopulationDBName,$nodePopulations );
244
      &writeDB( $nodePopulationDBName,$nodePopulations );
244
   } # if..elsif
245
   } # if..elsif
245
   return $return;
246
   return $return;
246
}
247
}
247
 
248
 
-
 
249
 
-
 
250
sub cluster {
-
 
251
   my $action = lc shift;
-
 
252
   my $return = '';
-
 
253
   if ( $action eq 'status' ) {
-
 
254
      &loadVirtDB();
-
 
255
      &loadNodePopulations();
-
 
256
      &loadNodeDB();
-
 
257
      print "Node\tThreads\tMemory\tDomains\tvcpu\tmem_used\n";
-
 
258
      my $usedmem = 0;
-
 
259
      my $usedcpu = 0;
-
 
260
      my $availmem = 0;
-
 
261
      my $availcpu = 0;
-
 
262
      my $totalDomains = 0;
-
 
263
      foreach my $node (sort keys %$nodeDB ) {
-
 
264
         my $memory = 0;
-
 
265
         my $vcpus = 0;
-
 
266
         my $count = 0;
-
 
267
         foreach my $domain ( keys %{ $nodePopulations->{$node}->{'running'} } ) {
-
 
268
            $memory += $virtDB->{$domain}->{'memory'};
-
 
269
            $vcpus += $virtDB->{$domain}->{'vcpu'};
-
 
270
            $count++;
-
 
271
         }
-
 
272
         $return .= "$node\t$nodeDB->{$node}->{cpu_count}\t$nodeDB->{$node}->{memory}\t$count\t$vcpus\t$memory\n";
-
 
273
         $usedmem += $memory;
-
 
274
         $usedcpu += $vcpus;
-
 
275
         $totalDomains += $count;
-
 
276
         $availmem += $nodeDB->{$node}->{memory};
-
 
277
         $availcpu += $nodeDB->{$node}->{cpu_count};
-
 
278
      } # outer for
-
 
279
      $return .= "Total\t$availcpu\t$availmem\t$totalDomains\t$usedcpu\t$usedmem\n";
-
 
280
   }
-
 
281
   return $return;
-
 
282
}
-
 
283
 
-
 
284
      
248
#my $config = &readConf( $confFile );
285
#my $config = &readConf( $confFile );
249
 
286
 
250
my $command = shift; # the first one is the actual subsection
287
my $command = shift; # the first one is the actual subsection
251
my $action = shift; # second is action to run
288
my $action = shift; # second is action to run
252
 
289
 
253
if ( $command eq 'node' ) {
290
if ( $command eq 'node' ) {
254
   print &node( $action, @ARGV );
291
   print &node( $action, @ARGV );
255
} elsif ( $command eq 'domain' ) {
292
} elsif ( $command eq 'domain' ) {
256
   print &domain( $action, @ARGV );
293
   print &domain( $action, @ARGV );
-
 
294
} elsif ( $command eq 'cluster' ) {
-
 
295
   print &cluster( $action, @ARGV );
257
} else {
296
} else {
258
   &help();
297
   &help();
259
}
298
}
260
 
299
 
261
 
300