1
0
Fork 0
mirror of https://github.com/munin-monitoring/contrib.git synced 2025-07-21 18:41:03 +00:00

Whitespace cleanup

* remove trailing whitespace
* remove empty lines at the end of files
This commit is contained in:
Lars Kruse 2018-08-02 02:03:42 +02:00
parent ef851f0c34
commit 17f784270a
604 changed files with 2927 additions and 2945 deletions

View file

@ -70,7 +70,7 @@ def find_vm_names(pids):
cmdline = open("/proc/%s/cmdline" % pid, "r")
result[pid] = clean_vm_name(re.sub(r"^.*-name\x00([a-zA-Z0-9.-_-]*)\x00\-.*$",r"\1", cmdline.readline()))
return result
def list_pids():
''' Find the pid of kvm processes
@return a list of pids from running kvm
@ -85,7 +85,7 @@ def fetch(vms):
for ( pid, name ) in vms.iteritems():
( user, system ) = open("/proc/%s/stat" % pid, 'r').readline().split(' ')[13:15]
print '%s_cpu.value %d' % ( name, int(user) + int(system) )
if __name__ == "__main__":
if len(sys.argv) > 1:
if sys.argv[1] in ['autoconf', 'detect']:

View file

@ -37,7 +37,7 @@ graph_args --base 1024
print "%s_read.info I/O used by virtual machine %s" % (vm, vm)
print "%s_write.label %s" % (vm, vm)
print "%s_write.type COUNTER" % vm
print "%s_write.min 0" % vm
print "%s_write.min 0" % vm
print "%s_write.draw LINE1" % vm
print "%s_write.negative %s_read" % (vm, vm)
print "%s_write.info I/O used by virtual machine %s" % (vm, vm)
@ -53,7 +53,7 @@ def clean_vm_name(vm_name):
vm_name = re.sub(suffix,'',vm_name)
return re.sub(r"[^a-zA-Z0-9_]", "_", vm_name)
def fetch(vms):
''' Fetch values for a list of pids
@param dictionnary {kvm_pid: cleaned vm name}
@ -64,11 +64,11 @@ def fetch(vms):
for line in f.readlines():
if "read_bytes" in line:
read = line.split()[1]
print "%s_read.value %s" % (vms[pid], read)
print "%s_read.value %s" % (vms[pid], read)
if "write_bytes" in line:
write = line.split()[1]
print "%s_write.value %s" % (vms[pid], write)
break
print "%s_write.value %s" % (vms[pid], write)
break
f.close()
def detect_kvm():
@ -87,14 +87,14 @@ def find_vm_names(pids):
cmdline = open("/proc/%s/cmdline" % pid, "r")
result[pid] = clean_vm_name(re.sub(r"^.*-name\x00([a-zA-Z0-9.-_-]*)\x00\-.*$",r"\1", cmdline.readline()))
return result
def list_pids():
''' Find the pid of kvm processes
@return a list of pids from running kvm
'''
pid = Popen("pidof qemu-kvm qemu-system-x86_64 kvm", shell=True, stdout=PIPE)
return pid.communicate()[0].split()
if __name__ == "__main__":
if len(sys.argv) > 1:
if sys.argv[1] in ['autoconf', 'detect']:

View file

@ -50,7 +50,7 @@ def clean_vm_name(vm_name):
vm_name = re.sub(suffix,'',vm_name)
return re.sub(r"[^a-zA-Z0-9_]", "_", vm_name)
def fetch(vms):
''' Fetch values for a list of pids
@param dictionnary {kvm_pid: cleaned vm name}
@ -61,12 +61,12 @@ def fetch(vms):
cmdline = open("/proc/%s/cmdline" % pid, "r")
amount = re.sub(r"^.*-m\x00(.*)\x00-smp.*$",r"\1", cmdline.readline())
amount = int(amount) * 1024 * 1024
print "%s_mem.value %s" % (vms[pid], amount)
print "%s_mem.value %s" % (vms[pid], amount)
except:
cmdline = open("/proc/%s/cmdline" % pid, "r")
amount = re.sub(r"^.*-m\x00(\d+).*$",r"\1", cmdline.readline())
amount = int(amount) * 1024 * 1024
print "%s_mem.value %s" % (vms[pid], amount)
print "%s_mem.value %s" % (vms[pid], amount)
def detect_kvm():
''' Check if kvm is installed
@ -84,14 +84,14 @@ def find_vm_names(pids):
cmdline = open("/proc/%s/cmdline" % pid, "r")
result[pid] = clean_vm_name(re.sub(r"^.*-name\x00([a-zA-Z0-9.-_-]*)\x00\-.*$",r"\1", cmdline.readline()))
return result
def list_pids():
''' Find the pid of kvm processes
@return a list of pids from running kvm
'''
pid = Popen("pidof qemu-kvm qemu-system-x86_64 kvm", shell=True, stdout=PIPE)
return pid.communicate()[0].split()
if __name__ == "__main__":
if len(sys.argv) > 1:
if sys.argv[1] in ['autoconf', 'detect']:

View file

@ -87,7 +87,7 @@ $show{'network_drops'} = $ENV{show_network_drops} || 1;
sub init() {
my $type=undef;
if ($ARGV[0] and $ARGV[0] eq "config"){
$type="config";
}
@ -142,7 +142,7 @@ sub init() {
if(defined($hash{$name}{'info'}{'memory'})){
$hash{$name}{'info'}{'memory_bytes'} = 1024 * $hash{$name}{'info'}{'memory'};
}
# Extract network usage
if(defined($hash{$name}{'xml'}{'devices'}{'interface'}{'bridge'})){
my $vif_id=0;
@ -204,7 +204,7 @@ sub init() {
print "graph_category virtualization\n";
print "graph_args -l 0 --base 1000 --upper-limit 100\n";
#print "graph_width 550\n";
for my $vm (sort keys %hash) {
if(defined($hash{$vm}{'devices'}{'block'})){
print $hash{$vm}{'label'} . ".label " . $hash{$vm}{'name'} . "\n";
@ -214,14 +214,14 @@ sub init() {
}
}
print "\n";
} elsif($type eq "fetch"){
print "multigraph libvirt_disk_utilization\n";
for my $vm (sort keys %hash) {
if(defined($hash{$vm}{'devices'}{'block'}) && defined($prev_state_ref->{$vm}->{'devices'}->{'block'})){
my $utilization=0;
for my $device (keys %{$hash{$vm}{'devices'}{'block'}}){
if(defined($prev_state_ref->{$vm}->{'devices'}->{'block'}->{$device})){
@ -274,7 +274,7 @@ sub init() {
print "graph_category virtualization\n";
print "graph_args -l 0 --base 1000 --upper-limit 100\n";
#print "graph_width 550\n";
if($devices>0){
if(defined($hash{$vm}{'devices'}{'block'})){
for my $device (keys %{$hash{$vm}{'devices'}{'block'}}){
@ -286,25 +286,25 @@ sub init() {
}
}
print "\n";
} elsif($type eq "fetch"){
if($devices > 0){
print "multigraph libvirt_disk_utilization." . $hash{$vm}{'label'} . "\n";
if(defined($hash{$vm}{'devices'}{'block'}) && defined($prev_state_ref->{$vm}->{'devices'}->{'block'})){
for my $device (keys %{$hash{$vm}{'devices'}{'block'}}){
my $utilization=0;
if(defined($prev_state_ref->{$vm}->{'devices'}->{'block'}->{$device})){
for my $source_device (keys %{$hash{$vm}{'devices'}{'block'}{$device}{'source'}}){
for my $slave_device (keys %{$hash{$vm}{'devices'}{'block'}{$device}{'source'}{$source_device}{'slaves'}}){
my $prev_ms_spent_doing_io=$prev_state_ref->{$vm}->{'devices'}->{'block'}->{$device}->{'source'}->{$source_device}->{'slaves'}->{$slave_device}->{'io_ticks'};
my $cur_ms_spent_doing_io=$hash{$vm}{'devices'}{'block'}{$device}{'source'}{$source_device}{'slaves'}{$slave_device}{'io_ticks'};
if($cur_ms_spent_doing_io > $prev_ms_spent_doing_io){
my $ticks=$cur_ms_spent_doing_io-$prev_ms_spent_doing_io;
my $interval_ms=($time-$prev_time)*1000;
@ -343,7 +343,7 @@ sub init() {
print "graph_vlabel read (-) / write (+)\n";
print "graph_category virtualization\n";
#print "graph_width 550\n";
for my $vm (sort keys %hash) {
if(defined($hash{$vm}{'devices'}{'block'})){
@ -358,7 +358,7 @@ sub init() {
print $hash{$vm}{'label'} . "_rd.min 0\n";
print $hash{$vm}{'label'} . "_rd.draw LINE2\n";
print $hash{$vm}{'label'} . "_rd.graph no\n";
print $hash{$vm}{'label'} . "_wr.label " . $hash{$vm}{'name'} . "\n";
print $hash{$vm}{'label'} . "_wr.info I/O latency in seconds on " . $hash{$vm}{'name'} . "\n";
print $hash{$vm}{'label'} . "_wr.min 0\n";
@ -368,7 +368,7 @@ sub init() {
}
}
print "\n";
} elsif($type eq "fetch"){
print "multigraph libvirt_disk_latency\n";
for my $vm (sort keys %hash) {
@ -382,9 +382,9 @@ sub init() {
my $cur_total_time_spent_reading=0;
my $cur_total_ios_read=0;
my $cur_total_ios_written=0;
my $devices=0;
for my $device (keys %{$hash{$vm}{'devices'}{'block'}}){
$devices++;
@ -456,16 +456,16 @@ sub init() {
print "graph_vlabel read (-) / write (+)\n";
print "graph_category virtualization\n";
#print "graph_width 550\n";
if(defined($hash{$vm}{'devices'}{'block'})){
for my $device (keys %{$hash{$vm}{'devices'}{'block'}}){
print $hash{$vm}{'label'} . "_" . $device . "_rd.label " . $device . "_rd\n";
print $hash{$vm}{'label'} . "_" . $device . "_rd.info I/O latency in seconds on " . $hash{$vm}{'name'} . ":" . $device . "\n";
print $hash{$vm}{'label'} . "_" . $device . "_rd.min 0\n";
print $hash{$vm}{'label'} . "_" . $device . "_rd.draw LINE2\n";
print $hash{$vm}{'label'} . "_" . $device . "_rd.graph no\n";
print $hash{$vm}{'label'} . "_" . $device . "_wr.label " . $device . "\n";
print $hash{$vm}{'label'} . "_" . $device . "_wr.info I/O latency in seconds on " . $hash{$vm}{'name'} . ":" . $device . "\n";
print $hash{$vm}{'label'} . "_" . $device . "_wr.min 0\n";
@ -479,11 +479,11 @@ sub init() {
print "multigraph libvirt_disk_latency.$hash{$vm}{'label'}\n";
if(defined($hash{$vm}{'devices'}{'block'}) && defined($prev_state_ref->{$vm}->{'devices'}->{'block'})){
for my $device (keys %{$hash{$vm}{'devices'}{'block'}}){
if(defined($prev_state_ref->{$vm}->{'devices'}->{'block'}->{$device})){
for my $source_device (keys %{$hash{$vm}{'devices'}{'block'}{$device}{'source'}}){
my $prev_total_time_spent_writing=0;
my $prev_total_time_spent_reading=0;
my $prev_total_ios_read=0;
@ -492,7 +492,7 @@ sub init() {
my $cur_total_time_spent_reading=0;
my $cur_total_ios_read=0;
my $cur_total_ios_written=0;
for my $slave_device (keys %{$hash{$vm}{'devices'}{'block'}{$device}{'source'}{$source_device}{'slaves'}}){
my $prev_time_spent_writing=$prev_state_ref->{$vm}->{'devices'}->{'block'}->{$device}->{'source'}->{$source_device}->{'slaves'}->{$slave_device}->{'write_ticks'};
@ -518,18 +518,18 @@ sub init() {
my $read_latency=0;
my $write_latency=0;
if($prev_total_time_spent_reading > 0 && $prev_total_ios_read > 0 && ($cur_total_ios_read-$prev_total_ios_read) > 0){
$read_latency=(($cur_total_time_spent_reading-$prev_total_time_spent_reading)/($cur_total_ios_read-$prev_total_ios_read))/1000;
}
if($prev_total_time_spent_writing > 0 && $prev_total_ios_written > 0 && ($cur_total_ios_written-$prev_total_ios_written) > 0){
$write_latency=(($cur_total_time_spent_writing-$prev_total_time_spent_writing)/($cur_total_ios_written-$prev_total_ios_written))/1000;
}
print $hash{$vm}{'label'} . "_" . $device . "_rd.value " . $read_latency . "\n";
print $hash{$vm}{'label'} . "_" . $device . "_wr.value " . $write_latency . "\n";
}
}
}
@ -554,7 +554,7 @@ sub init() {
print "graph_vlabel bytes read (-) / written (+) per \${graph_period}\n";
print "graph_category virtualization\n";
#print "graph_width 550\n";
for my $vm (sort keys %hash) {
my $devices=0;
if(defined($hash{$vm}{'devices'}{'block'})){
@ -565,14 +565,14 @@ sub init() {
if($devices > 0){
if(defined($hash{$vm}{'devices'}{'block'})){
print $hash{$vm}{'label'} . "_rd_bytes.label " . $hash{$vm}{'name'} . "\n";
print $hash{$vm}{'label'} . "_rd_bytes.type COUNTER\n";
print $hash{$vm}{'label'} . "_rd_bytes.info The number of bytes read by " . $hash{$vm}{'name'} . "\n";
print $hash{$vm}{'label'} . "_rd_bytes.min 0\n";
print $hash{$vm}{'label'} . "_rd_bytes.draw LINE2\n";
print $hash{$vm}{'label'} . "_rd_bytes.graph no\n";
print $hash{$vm}{'label'} . "_wr_bytes.label " . $hash{$vm}{'name'} . "\n";
print $hash{$vm}{'label'} . "_wr_bytes.type COUNTER\n";
print $hash{$vm}{'label'} . "_wr_bytes.info The number of bytes written by " . $hash{$vm}{'name'} . "\n";
@ -583,7 +583,7 @@ sub init() {
}
}
print "\n";
} elsif($type eq "fetch"){
print "multigraph libvirt_disk\n";
for my $vm (sort keys %hash) {
@ -604,7 +604,7 @@ sub init() {
#
# Disk used, second level
#
for my $vm (sort keys %hash) {
my $devices=0;
if(defined($hash{$vm}{'devices'}{'block'})){
@ -623,14 +623,14 @@ sub init() {
print "graph_vlabel bytes read (-) / written (+) per \${graph_period}\n";
print "graph_category virtualization\n";
#print "graph_width 550\n";
for my $device (keys %{$hash{$vm}{'devices'}{'block'}}){
print $device . "_rd_bytes.label " . $device . "_rd\n";
print $device . "_rd_bytes.type COUNTER\n";
print $device . "_rd_bytes.info The number of bytes read by " . $hash{$vm}{'name'} . "\n";
print $device . "_rd_bytes.min 0\n";
print $device . "_rd_bytes.graph no\n";
print $device . "_wr_bytes.label " . $device . "\n";
print $device . "_wr_bytes.type COUNTER\n";
print $device . "_wr_bytes.info The number of bytes written by " . $hash{$vm}{'name'} . "\n";
@ -639,7 +639,7 @@ sub init() {
print $device . "_wr_bytes.negative " . $device . "_rd_bytes\n";
}
print "\n";
} elsif($type eq "fetch"){
print "multigraph libvirt_disk.bytes_" . $hash{$vm}{'label'} . "\n";
if(defined($hash{$vm}{'devices'}{'block'})){
@ -672,7 +672,7 @@ sub init() {
print "graph_title Disk errors per domain\n";
print "graph_args --base 1000\n";
print "graph_category virtualization\n";
for my $vm (sort keys %hash) {
if(defined($hash{$vm}{'devices'}{'block'})){
my $devices=0;
@ -691,7 +691,7 @@ sub init() {
}
}
print "\n";
} elsif($type eq "fetch"){
print "multigraph libvirt_disk_errs\n";
for my $vm (sort keys %hash) {
@ -709,7 +709,7 @@ sub init() {
#
# Disk errors, second level
#
for my $vm (sort keys %hash) {
my $devices=0;
if(defined($hash{$vm}{'devices'}{'block'})){
@ -724,9 +724,9 @@ sub init() {
print "graph_title Disk errors for " . $hash{$vm}{'name'} . "\n";
print "graph_args --base 1000\n";
print "graph_category virtualization\n";
for my $device (keys %{$hash{$vm}{'devices'}{'block'}}){
print $device . "_errs.label " . $device . "\n";
print $device . "_errs.type COUNTER\n";
print $device . "_errs.info The number of errors by " . $hash{$vm}{'name'} . " on defice " . $device . "\n";
@ -734,7 +734,7 @@ sub init() {
print $device . "_errs.draw LINE2\n";
}
print "\n";
} elsif($type eq "fetch"){
print "multigraph libvirt_disk_errs." . $hash{$vm}{'label'} . "\n";
if(defined($hash{$vm}{'devices'}{'block'})){
@ -766,10 +766,10 @@ sub init() {
print "graph_vlabel Bytes in (-) / out (+) per \${graph_period}\n";
print "graph_category virtualization\n";
#print "graph_width 550\n";
for my $vm (sort keys %hash) {
if(defined($hash{$vm}{'devices'}{'network'})){
print $hash{$vm}{'label'} . "_rx_bytes.label " . $hash{$vm}{'name'} . "_rx\n";
print $hash{$vm}{'label'} . "_rx_bytes.type DERIVE\n";
print $hash{$vm}{'label'} . "_rx_bytes.info The number of bytes read by " . $hash{$vm}{'name'} . " in total.\n";
@ -777,7 +777,7 @@ sub init() {
print $hash{$vm}{'label'} . "_rx_bytes.draw LINE2\n";
print $hash{$vm}{'label'} . "_rx_bytes.graph no\n";
#print $hash{$vm}{'label'} . "_rx_bytes.cdef " . $hash{$vm}{'label'} . "_rx_bytes,8,*\n";
print $hash{$vm}{'label'} . "_tx_bytes.label " . $hash{$vm}{'name'} . "\n";
print $hash{$vm}{'label'} . "_tx_bytes.type DERIVE\n";
print $hash{$vm}{'label'} . "_tx_bytes.info The number of bytes written by " . $hash{$vm}{'name'} . " in total.\n";
@ -788,7 +788,7 @@ sub init() {
}
}
print "\n";
} elsif($type eq "fetch"){
print "multigraph libvirt_network\n";
for my $vm (sort keys %hash) {
@ -819,10 +819,10 @@ sub init() {
print "graph_vlabel Bits in (-) / out (+) per \${graph_period}\n";
print "graph_category virtualization\n";
#print "graph_width 550\n";
for my $vif (keys %{$hash{$vm}{'devices'}{'network'}}){
my $vif_id=$hash{$vm}{'devices'}{'network'}{$vif}{'vif_id'};
print "rx_bytes_" . $vif_id . ".label " . $vif . "_rx\n";
print "rx_bytes_" . $vif_id . ".type DERIVE\n";
print "rx_bytes_" . $vif_id . ".info The number of bytes read by " . $hash{$vm}{'name'} . "\n";
@ -872,17 +872,17 @@ sub init() {
print "graph_vlabel Count in (-) / out (+) per \${graph_period}\n";
print "graph_category virtualization\n";
#print "graph_width 550\n";
for my $vm (sort keys %hash) {
if(defined($hash{$vm}{'devices'}{'network'})){
print $hash{$vm}{'label'} . "_rx_drop.label " . $hash{$vm}{'name'} . "_rx\n";
print $hash{$vm}{'label'} . "_rx_drop.type DERIVE\n";
print $hash{$vm}{'label'} . "_rx_drop.info The number of packets dropped at reception by " . $hash{$vm}{'name'} . "\n";
print $hash{$vm}{'label'} . "_rx_drop.min 0\n";
print $hash{$vm}{'label'} . "_rx_drop.draw LINE2\n";
print $hash{$vm}{'label'} . "_rx_drop.graph no\n";
print $hash{$vm}{'label'} . "_tx_drop.label " . $hash{$vm}{'name'} . "\n";
print $hash{$vm}{'label'} . "_tx_drop.type DERIVE\n";
print $hash{$vm}{'label'} . "_tx_drop.info The number of packets dropped at transmission by " . $hash{$vm}{'name'} . "\n";
@ -892,7 +892,7 @@ sub init() {
}
}
print "\n";
} elsif($type eq "fetch"){
print "multigraph libvirt_network_drop\n";
for my $vm (sort keys %hash) {
@ -925,10 +925,10 @@ sub init() {
print "graph_vlabel Count in (-) / out (+) per \${graph_period}\n";
print "graph_category virtualization\n";
#print "graph_width 550\n";
for my $vif (keys %{$hash{$vm}{'devices'}{'network'}}){
my $vif_id=$hash{$vm}{'devices'}{'network'}{$vif}{'vif_id'};
print "rx_drop_" . $vif_id . ".label " . $vif . "_rx\n";
print "rx_drop_" . $vif_id . ".type DERIVE\n";
print "rx_drop_" . $vif_id . ".info The number of packets dropped by " . $hash{$vm}{'name'} . ", nic " . $vif_id . "\n";
@ -960,7 +960,7 @@ sub init() {
#
# CPU used
#
if($show{'cpu_used'} == 1){
#
@ -973,7 +973,7 @@ sub init() {
print "graph_args --base 1000 -r --lower-limit 0 --upper-limit 100\n";
print "graph_category virtualization\n";
#print "graph_width 550\n";
my $draw="AREA";
for my $vm (sort keys %hash) {
print $hash{$vm}{'label'} . "_time.label " . $hash{$vm}{'name'} . "\n";
@ -984,7 +984,7 @@ sub init() {
$draw="STACK" if $draw eq "AREA";
}
print "\n";
} elsif($type eq "fetch"){
print "multigraph libvirt_cpu\n";
for my $vm (sort keys %hash) {
@ -996,7 +996,7 @@ sub init() {
#
# CPU used, second level (pr virtual machine)
#
if($type eq "config"){
for my $vm (sort keys %hash) {
print "multigraph libvirt_cpu.vm_" . $hash{$vm}{'label'} . "\n";
@ -1004,7 +1004,7 @@ sub init() {
print "graph_args --base 1000\n";
print "graph_category virtualization\n";
#print "graph_width 550\n";
print "time.label " . $hash{$vm}{'name'} . " (" . $hash{$vm}{'type'} . ")\n";
print "time.type DERIVE\n";
print "time.info The cpu time used by " . $hash{$vm}{'name'} . " in percent of the total available cpu time on the physical node. This domain has access to " . $hash{$vm}{'info'}{'nrVirtCpu'} . " VCPU(s) now, and $hash{$vm}{'maxvcpus'} at maximum. The scheduler for this domain is " . $hash{$vm}{'scheduler'} . ".\n";
@ -1012,7 +1012,7 @@ sub init() {
print "time.draw AREA\n";
print "\n";
}
} elsif($type eq "fetch"){
for my $vm (sort keys %hash) {
print "multigraph libvirt_cpu.vm_" . $hash{$vm}{'label'} . "\n";
@ -1038,7 +1038,7 @@ sub init() {
print "graph_args --base 1000\n";
print "graph_category virtualization\n";
#print "graph_width 550\n";
my $draw="AREA";
for my $vm (sort keys %hash) {
print $hash{$vm}{'label'} . "_alloc.label " . $hash{$vm}{'name'} . "\n";
@ -1049,7 +1049,7 @@ sub init() {
$draw="STACK" if $draw eq "AREA";
}
print "\n";
} elsif($type eq "fetch"){
print "multigraph libvirt_mem\n";
for my $vm (sort keys %hash) {
@ -1061,7 +1061,7 @@ sub init() {
#
# Memory allocated, second level (pr virtual machine)
#
if($type eq "config"){
for my $vm (sort keys %hash) {
print "multigraph libvirt_mem.vm_" . $hash{$vm}{'label'} . "\n";
@ -1069,7 +1069,7 @@ sub init() {
print "graph_args --base 1000\n";
print "graph_category virtualization\n";
#print "graph_width 550\n";
print "mem.label " . $hash{$vm}{'name'} . " (" . $hash{$vm}{'type'} . ")\n";
print "mem.type GAUGE\n";
print "mem.info Amount of memory allocated to " . $hash{$vm}{'name'} . ". The maximum amount of memory for this domain is " . $hash{$vm}{'maxmem'}/1024 . " MB.\n";
@ -1077,7 +1077,7 @@ sub init() {
print "mem.draw AREA\n";
print "\n";
}
} elsif($type eq "fetch"){
for my $vm (sort keys %hash) {
print "multigraph libvirt_mem.vm_" . $hash{$vm}{'label'} . "\n";
@ -1156,7 +1156,7 @@ sub parse_xml {
my $teller = 0;
my $fortsette = 1;
while($fortsette){
if( $a[$i]{'devices'}[0]{'disk'}[$teller] ){
my $type=$a[$i]{'devices'}[0]{'disk'}[$teller]{'type'};
@ -1173,7 +1173,7 @@ sub parse_xml {
else{
$fortsette = 0;
}
}
}
}
# Hack to extract network information and put it into the hash
@ -1182,7 +1182,7 @@ sub parse_xml {
my $teller = 0;
my $fortsette = 1;
while($fortsette){
if( $a[$i]{'devices'}[0]{'interface'}[$teller] ){
my $type=$a[$i]{'devices'}[0]{'interface'}[$teller]{'type'};
@ -1198,7 +1198,7 @@ sub parse_xml {
else{
$fortsette = 0;
}
}
}
}
}
@ -1213,8 +1213,8 @@ sub read_diskstats{
# Verify that $dev is a block device.
if(-b $dev){
# Read minor and major number
my $rdev = stat($dev)->rdev;
$res{'major'} = $rdev >> 8;
my $rdev = stat($dev)->rdev;
$res{'major'} = $rdev >> 8;
$res{'minor'} = $rdev & 0xff;
# If major numer is 253, then proceed as dm-device
@ -1238,7 +1238,7 @@ sub read_diskstats{
while (my $line = <FILE>) {
# 1 2 3 4 5 6 7 8 9 10 11
if($line =~ m/(\d+)\s+(\d+)\s+(\d+)\s+(\d+)\s+(\d+)\s+(\d+)\s+(\d+)\s+(\d+)\s+(\d+)\s+(\d+)\s+(\d+)/){
# Name units description
# ---- ----- -----------
# read I/Os requests number of read I/Os processed

View file

@ -1,6 +1,6 @@
#!/usr/bin/python
# Revision 1.0 2008/05/16 - Steven Wagner
# Revision 1.0 2008/05/16 - Steven Wagner
# First functional release. Works for me.
#
# Revision 0.5 2008/05/01 - Julien Rottenberg
@ -45,7 +45,7 @@ if len(sys.argv) == 2:
print "%s.type COUNTER" %(nodeName)
print "%s.label %s" %(nodeName, nodeName)
sys.exit(1)
for id in ids:
dom = conn.lookupByID(id)
state, maxMem, memory, numVirtCpu, cpuTime = dom.info()
@ -55,5 +55,3 @@ for id in ids:
# print """Domain: %s, %s state (%s), %d CPUs, %d seconds, %d milliseconds, mem/max (%d/%d) """ \
# % (nodeName, ostype, state, numVirtCpu, cpuTime/float(1000000000), cpuTime/float(1000000), memory, maxMem )
print "%s.value %d" % (nodeName, cpuTime/float(1000000))