mirror of https://github.com/mikaku/Monitorix.git
added the option 'cmd' in 'libvirt.pm' in order to be able to execute a custom command
This commit is contained in:
parent
e6c56b66b0
commit
d6082b02bf
2
Changes
2
Changes
|
@ -1,5 +1,7 @@
|
||||||
N.N.N - DD-MMM-2015
|
N.N.N - DD-MMM-2015
|
||||||
====================
|
====================
|
||||||
|
- Added the option 'cmd' in 'libvirt.pm' in order to be able to execute a
|
||||||
|
custom command like 'virsh -r -c qemu:///session'.
|
||||||
- Fixed in 'libvirt.pm' limiting to 100 all CPU values greater than 100.
|
- Fixed in 'libvirt.pm' limiting to 100 all CPU values greater than 100.
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -125,6 +125,12 @@ sub libvirt_init {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
# check for missing options
|
||||||
|
if(!$libvirt->{cmd}) {
|
||||||
|
logger("$myself: WARNING: the 'cmd' option doesn't exist. Please consider upgrading your configuration file.");
|
||||||
|
$libvirt->{cmd} = "virsh";
|
||||||
|
}
|
||||||
|
|
||||||
$config->{libvirt_hist} = ();
|
$config->{libvirt_hist} = ();
|
||||||
push(@{$config->{func_update}}, $package);
|
push(@{$config->{func_update}}, $package);
|
||||||
logger("$myself: Ok") if $debug;
|
logger("$myself: Ok") if $debug;
|
||||||
|
@ -161,13 +167,13 @@ sub libvirt_update {
|
||||||
}
|
}
|
||||||
|
|
||||||
# check first if that 'vm' is running
|
# check first if that 'vm' is running
|
||||||
if($vm && open(IN, "virsh domstate $vm |")) {
|
if($vm && open(IN, "$libvirt->{cmd} domstate $vm |")) {
|
||||||
$state = trim(<IN>);
|
$state = trim(<IN>);
|
||||||
close(IN);
|
close(IN);
|
||||||
}
|
}
|
||||||
|
|
||||||
if($state eq "running") {
|
if($state eq "running") {
|
||||||
if(open(IN, "virsh cpu-stats $vm --total |")) {
|
if(open(IN, "$libvirt->{cmd} cpu-stats $vm --total |")) {
|
||||||
my $c = 0;
|
my $c = 0;
|
||||||
while(<IN>) {
|
while(<IN>) {
|
||||||
if(/^\s+cpu_time\s+(\d+\.\d+) seconds$/) {
|
if(/^\s+cpu_time\s+(\d+\.\d+) seconds$/) {
|
||||||
|
@ -182,7 +188,7 @@ sub libvirt_update {
|
||||||
$cpu = $cpu > 100 ? 100 : $cpu;
|
$cpu = $cpu > 100 ? 100 : $cpu;
|
||||||
$config->{libvirt_hist}->{$str} = $c;
|
$config->{libvirt_hist}->{$str} = $c;
|
||||||
}
|
}
|
||||||
if(open(IN, "virsh dommemstat $vm |")) {
|
if(open(IN, "$libvirt->{cmd} dommemstat $vm |")) {
|
||||||
while(<IN>) {
|
while(<IN>) {
|
||||||
if(/^rss\s+(\d+)$/) {
|
if(/^rss\s+(\d+)$/) {
|
||||||
$mem = $1 * 1024;
|
$mem = $1 * 1024;
|
||||||
|
@ -190,7 +196,7 @@ sub libvirt_update {
|
||||||
}
|
}
|
||||||
close(IN);
|
close(IN);
|
||||||
}
|
}
|
||||||
if(open(IN, "virsh domblkstat $vm $vda |")) {
|
if(open(IN, "$libvirt->{cmd} domblkstat $vm $vda |")) {
|
||||||
my $r = 0;
|
my $r = 0;
|
||||||
my $w = 0;
|
my $w = 0;
|
||||||
while(<IN>) {
|
while(<IN>) {
|
||||||
|
@ -210,7 +216,7 @@ sub libvirt_update {
|
||||||
$dsk /= 60;
|
$dsk /= 60;
|
||||||
$config->{libvirt_hist}->{$str} = $t;
|
$config->{libvirt_hist}->{$str} = $t;
|
||||||
}
|
}
|
||||||
if(open(IN, "virsh domiflist $vm |")) {
|
if(open(IN, "$libvirt->{cmd} domiflist $vm |")) {
|
||||||
while(<IN>) {
|
while(<IN>) {
|
||||||
if(/^(\S+)\s+.*?\s+$vmac$/) {
|
if(/^(\S+)\s+.*?\s+$vmac$/) {
|
||||||
$vnet = $1;
|
$vnet = $1;
|
||||||
|
@ -218,7 +224,7 @@ sub libvirt_update {
|
||||||
}
|
}
|
||||||
close(IN);
|
close(IN);
|
||||||
}
|
}
|
||||||
if(open(IN, "virsh domifstat $vm $vnet |")) {
|
if(open(IN, "$libvirt->{cmd} domifstat $vm $vnet |")) {
|
||||||
my $r = 0;
|
my $r = 0;
|
||||||
my $w = 0;
|
my $w = 0;
|
||||||
while(<IN>) {
|
while(<IN>) {
|
||||||
|
|
|
@ -287,6 +287,7 @@ secure_log_date_format = %b %e
|
||||||
# LIBVIRT graph
|
# LIBVIRT graph
|
||||||
# -----------------------------------------------------------------------------
|
# -----------------------------------------------------------------------------
|
||||||
<libvirt>
|
<libvirt>
|
||||||
|
cmd = virsh
|
||||||
<list>
|
<list>
|
||||||
0 = centos6, winxp
|
0 = centos6, winxp
|
||||||
</list>
|
</list>
|
||||||
|
|
Loading…
Reference in New Issue