Subversion Repositories sysadmin_scripts

Rev

Go to most recent revision | Details | Last modification | View Log | RSS feed

Rev Author Line No. Line
24 rodolico 1
#! /usr/bin/env perl
2
 
3
use Data::Dumper;
4
 
5
my @DOM0 = (
6
   'vengeance',
7
   'tardis',
8
   'ds9',
9
   'prometheus',
10
   'asimov',
11
   'executor',
12
   'durandel'
13
   );
14
 
15
sub parseOutput {
16
   my $output = shift;
17
   my @lines = split( "\n", $output );
18
   my %domu;
19
   return ( 'noname' ) unless $lines[0] =~ m/^Name/;
20
   return ( 'baddomu') unless $lines[1] =~ m/^Domain-0/;
21
   for ( my $i = 2; $i < @lines; $i++ ) {
22
      my ( $name,$id,$mem,$vcpu,$state,$time) = split( /\s+/, $lines[$i] );
23
      $domu{$name}{'ID'} = $id;
24
      $domu{$name}{'memory'} = $mem;
25
      $domu{$name}{'CPUs'} = $vcpu;
26
   }
27
   return \%domu;
28
}
29
 
30
my %hier;
31
my $dom0;
32
 
33
foreach $dom0 ( @DOM0 ) {
34
#   print STDOUT "Working on $dom0\n";
35
   my $output = `ssh root\@$dom0 'xl list'`;
36
   $heir{$dom0} = &parseOutput( $output );
37
}
38
 
39
 
40
print "DOM0\tDOMU\tMemory\tCPU\tID\n";
41
foreach $dom0 ( sort keys %heir ) {
42
   print "$dom0\n";
43
   my $thisOne = $heir{$dom0};
44
   foreach my $domu ( sort keys %$thisOne ) {
45
      print "\t" . join( "\t", ( $domu, $$thisOne{$domu}{'memory'}, $$thisOne{$domu}{'CPUs'}, $$thisOne{$domu}{'ID'} ) ) . "\n";
46
   } # foreach
47
} # foreach
48
my $host = `hostname -f`;
49
chomp $host;
50
print "Generated by $0 running on $host\n"; 
51
1;