Hi there,
First of all thank you very much. I am starting with perl and I trying to automate my shell scripts by perl scripts.
Here my final script ( of course I will follow HAUKEX advice which is what I want.
#!/usr/local/bin/perl
use strict;
use warnings;
my @get_vmlist = ( `xl list` );
sub show_vmlist {
print @get_vmlist;
}
my $arg = shift @ARGV;
my $vm_run = pop @ARGV;
sub get_vncport {
my $DOMID = qq(DOM_ID="`xl list | fgrep $vm_run | awk '{print
+\$2}'`" && VNCPORT="`ps x | fgrep -m 1 "domid \$DOM_ID" | awk '{print
+ \$1}'`" && sockstat -4l | fgrep \$VNCPORT | awk '{print \$6}');
print `$DOMID`;
}
my %rec_args = ( vmlist => \&show_vmlist,
getvnc => \&get_vncport,
);
if (defined $arg && exists $rec_args{$arg}) {
$rec_args{$arg}->();
}
| [reply] [Watch: Dir/Any] [d/l] |
| [reply] [Watch: Dir/Any] [d/l] [select] |
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] [Watch: Dir/Any] [d/l] |