mirror of
https://github.com/retspen/webvirtcloud.git
synced 2026-04-25 15:35:57 +03:00
[GH-ISSUE #245] There is any way i can add memory monitor of guest vm #165
Labels
No labels
bug
enhancement
pull-request
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set.
Reference
starred/webvirtcloud#165
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Originally created by @alshba7 on GitHub (Jun 22, 2019).
Original GitHub issue: https://github.com/retspen/webvirtcloud/issues/245
There is any way i can add memory monitor of guest vm
my code for example
#!/usr/bin/env python
import libvirt
from libvirt import libvirtError
import time
def request_cred(credentials, user_data):
for credential in credentials:
if credential[0] == libvirt.VIR_CRED_AUTHNAME:
credential[4] = 'test'
elif credential[0] == libvirt.VIR_CRED_PASSPHRASE:
credential[4] = 'dddddddd'
return 0
auth = [[libvirt.VIR_CRED_AUTHNAME, libvirt.VIR_CRED_PASSPHRASE], request_cred, None]
conn = libvirt.openAuth('qemu+{0}://{1}/system'.format('tcp','127.0.0.1'), auth, 0)
#conn = libvirt.open(optional_params['conn'])
guest = 'guest'
vm = conn.lookupByName(guest)
""" test with running vm """
memstats = vm.memoryStats()
percent = memstats['rss'] / memstats['actual'] * 100
pcentCurrMem = max(100.0,min(percent, 0.0))
print(percent)
print(int( float(int(memstats['rss'])) / float(int(memstats['actual'])) * 100 ))
time.sleep(1)
vm.setMemoryStatsPeriod(5, libvirt.VIR_DOMAIN_AFFECT_LIVE)
memstats = vm.memoryStats()
print(int( float(int(memstats['rss'])) / float(int(memstats['actual'])) * 100 ))
But the usage of memory the same 99% or 101%
how can i solve this problem
@catborise commented on GitHub (Jun 22, 2019):
I have add that information to stats as graph for vm. Have you see that? You can search rss in instance/view.py and vrtmanager/instance.py