Hi haukex,
Absolutely ,
xl is part of xen-tools.
xl is used to manipulate virtual machines as other system parameters as well.
Here is a tipical output of "xl list" ( used to list running virtual machines ) I am using FreeBSD as dom0. When I start a VM on HVM mode, I use VNC to access vm console.
# xl list
Name ID Mem VCPUs State
+ Time(s)
Domain-0 0 18442 2 r-----
+ 16256.2
git 1 1023 2 -b----
+ 14499.4
zabbix 2 512 1 -b----
+ 3228.6
jenkins 3 4096 2 -b----
+ 21733.3
openbsd 4 2048 1 -b----
+ 1202.6
wiki 5 2048 1 -b----
+ 1140.4
builder 6 4096 2 -b----
+ 206.9
This perl script which you guys helped, do the follow: "pxl vmlist" ( which will return xl list ), and "pxl getvnc jenkins" ( which will return vnc port listening of that VM ) "127.0.0.1:5906"
Next steps, I will provide ssh port forward and connect to it :)
Thanks again
| [reply] [d/l] |
Since I don't have all the commands you're using on my system, here are just some general tips. Your command | fgrep | awk sequences can be rewritten in Perl in the following manner, using xl list as an example. You can write these loops one after the other, first getting the ID, then the VNC port, and finally for the IP address.
use warnings;
use strict;
use IPC::System::Simple qw/capturex/;
my $vm_run = 'zabbix';
my $id;
for ( capturex('xl','list') ) { # loop over lines of command output
chomp; # remove newline
my @F = split; # split the line into fields on whitespace (like a
+wk)
if ( $F[0] eq $vm_run ) { # match on the first field
$id = $F[1]; # store the second field
#last; # would be the equivalent of fgrep -m1
}
}
print "ID: $id\n"; # prints "ID: 2" in this example
Also, I suspect print `$DOMID`; isn't right, you probably don't want to execute the contents of the $DOMID as a command (that's what the backticks will do)? You probably want a simple print "$DOMID\n"; instead. | [reply] [d/l] [select] |