Projet

Général

Profil

Révision 2385a6f5

ID2385a6f570e1a58fe11941ea911ed3c1360d8759
Parent 8cb47cbf
Enfant 6b4a3124

Ajouté par Bianco Veigel il y a environ 5 ans

refactoring and python3 compatibility

Voir les différences:

plugins/libvirt/kvm_mem
25 25
graph_vlabel Bytes
26 26
graph_category virtualization
27 27
graph_info This graph shows the current amount of memory used by virtual machines
28
graph_args --base 1024"""
29
    print base_config
30
    draw = "AREA"
28
graph_args --base 1024 -l 0"""
29
    print(base_config)
31 30
    for vm in vm_names:
32
        print "%s_mem.label %s" % (vm, vm)
33
        print "%s_mem.type GAUGE" % vm
34
        if draw == 'AREA':
35
            print "%s_mem.min 0" % vm
36
        print "%s_mem.draw %s" % (vm, draw)
37
        print "%s_mem.info memory used by virtual machine %s" % (vm, vm)
38
	draw = "STACK"
31
        print("%s_mem.label %s" % (vm, vm))
32
        print("%s_mem.type GAUGE" % vm)
33
        print("%s_mem.draw %s" % (vm, "AREASTACK"))
34
        print("%s_mem.info memory used by virtual machine %s" % (vm, vm))
39 35

  
40 36

  
41 37
def clean_vm_name(vm_name):
......
68 64
            cmdline = open("/proc/%s/cmdline" % pid, "r")
69 65
            amount = re.sub(r"^.*-m\x00(.*)\x00-smp.*$",r"\1", cmdline.readline())
70 66
            amount = int(amount) * 1024 * 1024
71
            print "%s_mem.value %s" % (vms[pid], amount)
67
            print("%s_mem.value %s" % (vms[pid], amount))
72 68
        except:
73 69
            cmdline = open("/proc/%s/cmdline" % pid, "r")
74 70
            amount = re.sub(r"^.*-m\x00(\d+).*$",r"\1", cmdline.readline())
75 71
            amount = int(amount) * 1024 * 1024
76
            print "%s_mem.value %s" % (vms[pid], amount)
72
            print("%s_mem.value %s" % (vms[pid], amount))
77 73

  
78 74
def detect_kvm():
79 75
    ''' Check if kvm is installed
......
103 99
    if len(sys.argv) > 1:
104 100
        if sys.argv[1] in ['autoconf', 'detect']:
105 101
            if detect_kvm():
106
                print "yes"
102
                print("yes")
107 103
            else:
108
                print "no"
104
                print("no")
109 105
        elif sys.argv[1] == "config":
110 106
            config(find_vm_names(list_pids()).values())
111 107
        else:

Formats disponibles : Unified diff