In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-04-03 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >
Share
Shulou(Shulou.com)05/31 Report--
Editor to share with you the KVM virtual machine monitoring example analysis, I believe that most people do not know much about it, so share this article for your reference, I hope you will learn a lot after reading this article, let's go to know it!
1 Monitoring of CPU
Python code
Import libvirt
Import os
Import time
Conn=libvirt.open ("qemu:///system")
If conn==None:
Print "fail to connect hypervisor"
Sys.exit (1)
Try:
Dom0=conn.lookupByID (85) # get the corresponding Domain object according to the Instance ID created by OpenStack
Except:
Print "fail to find the domain by ID"
Sys.exit (1)
Pstart_time=time.time () # take the current time
Dstart_time=dom0.info () [4] # directly get the CPU time information in DomainInfo
Time.sleep (2)
Dstop_time=dom0.info () [4]
Pstop_time=time.time ()
Core_num=int (dom0.info () [3]) # get the quantity information of core in DomainIndo
# CPU utilization calculation formula-CPU time difference / interval / 100000000000 / number of cores * 100=CPU utilization
Cpu_usage= (Dstart_time-Dstop_time) / (Pstart_time-Pstop_time) / 1000000000/core_num*100
Cpu_usage=cpu_usage if (cpu_usage > 0) else 0.0
Cpu_usage=cpu_usage if (cpu_usage
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.