Commit 8a0fad37 authored by Daniel P. Berrange's avatar Daniel P. Berrange

Allow URI to be specified

parent c4aec8f9
......@@ -2,9 +2,11 @@
use Sys::Virt;
my $con = Sys::Virt->new(address => "", readonly => 1);
my $addr = @ARGV ? shift @ARGV : "";
print "Addr $addr\n";
my $con = Sys::Virt->new(address => $addr, readonly => 1);
print "VMM type: ", $con->get_type(), "\n";
print "VMM type: ", $con->get_type(), "\n";
print "Node: {\n";
my $ninfo = $con->get_node_info;
......@@ -17,7 +19,7 @@ print "libvirt Version: ", $con->get_major_version(), ".", $con->get_minor_versi
foreach my $dom (sort { $a->get_id <=> $b->get_id } $con->list_domains) {
print "Domain: {\n";
print " ID: ", $dom->get_id(), " '" , $dom->get_name(), "'\n";
print " UUID: ", $dom->get_uuid_string(), "\n";
print " UUID: ", $dom->get_uuid_string(), "\n";
my $info = $dom->get_info;
foreach (sort { $a cmp $b } keys %{$info}) {
print " ", $_, ": ", $info->{$_}, "\n";
......
......@@ -2,12 +2,17 @@
use Sys::Virt;
my $addr = "";
if (@ARGV == 2) {
$addr = shift @ARGV;
}
if (@ARGV != 1) {
print STDERR "syntax: $0 DOMAIN-NAME\n";
print STDERR "syntax: $0 [URI] DOMAIN-NAME\n";
exit 1;
}
my $con = Sys::Virt->new(address => "", readonly => 1);
my $con = Sys::Virt->new(address => $addr, readonly => 1);
my $name = shift @ARGV;
......
......@@ -7,7 +7,9 @@ use Sys::Virt;
use Sys::Virt::Domain;
use Time::HiRes qw(time);
my $hv = Sys::Virt->new(readonly => 1);
my $addr = @ARGV ? shift @ARGV : "";
my $hv = Sys::Virt->new(address => $addr, readonly => 1);
my $interval = @ARGV ? shift @ARGV : 1;
my $iterations = @ARGV ? shift @ARGV : 1;
......@@ -32,7 +34,7 @@ for (my $i = 0 ; $i < $iterations ; $i++) {
my $now = time;
my @domains = $hv->list_domains;
my @stats;
if (!($i % 10)) {
printf " %-4s %-15s %-8s %-6s %-4s\n", "ID", "Name", "State", "CPU", "Memory";
......@@ -46,15 +48,13 @@ for (my $i = 0 ; $i < $iterations ; $i++) {
my $timedelta = defined $sample ? ($now - $sample)*1000*1000*1000 :0;
$cpuTime{$uuid} = $info->{cpuTime};
my $util = $timedelta > 0 ? $cpudelta * 100 / $timedelta : 0;
printf " %-4d %-15s %-8s %-6s %-4dMB \n", $domain->get_id, $domain->get_name, $states{$info->{state}}, (sprintf "%d%%",$util), ($info->{memory}/1024);
}
$sample = $now;
print "\n";
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment