本文整理汇总了Golang中github.com/cha87de/kvmtop/models.VirtualMachine类的典型用法代码示例。如果您正苦于以下问题:Golang VirtualMachine类的具体用法?Golang VirtualMachine怎么用?Golang VirtualMachine使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了VirtualMachine类的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Golang代码示例。
示例1: Collect
func (collector StaticCollector) Collect(vm models.VirtualMachine) (string, error) {
vmx := vms[vm.Name()]
// nothing to do, just look up the osUuid and print it as a result
vmOsUuid := vmx.StaticData.Values["UUID"]
result := fmt.Sprintf("%s", vmOsUuid)
return result, nil
}
示例2: readItems
func readItems(vm models.VirtualMachine) (models.Statistic, error) {
/*
# virsh dominfo xy
Id: 4
Name: instance-0000012c
UUID: 5f065a85-9a0f-402c-8470-681155a10021
OS Type: hvm
State: running
CPU(s): 2
CPU time: 15240.3s
Max memory: 4194304 KiB
Used memory: 4194304 KiB
Persistent: yes
Autostart: disable
Managed save: no
Security model: none
Security DOI: 0
*/
staticData, err := util.VirshXDetails("dominfo", vm.Name(), "", 0, 1, nil)
if err != nil {
log.Printf("Error while readItems %a", err)
return models.Statistic{}, err
}
return staticData, nil
}
示例3: readItemStats
func readItemStats(vm models.VirtualMachine, vmif models.MeasurementItem) (models.Statistic, error) {
/*
Capacity: 21474836480
Allocation: 483991552
Physical: 483991552
*/
stat1, err1 := util.VirshXDetails("domblkinfo", vm.Name(), vmif.Name, 0, 1, nil)
if err1 != nil {
return models.Statistic{}, err1
}
/*
hda rd_req 23316
hda rd_bytes 461506990
hda wr_req 0
hda wr_bytes 0
hda flush_operations 0
hda rd_total_times 1514874067
hda wr_total_times 0
hda flush_total_times 0
*/
stat2, err2 := util.VirshXDetails("domblkstat", vm.Name(), vmif.Name, 1, 2, nil)
if err2 != nil {
return models.Statistic{}, err2
}
// copy stats from stat1 to stat2
for k, v := range stat1.Values {
stat2.Values[k] = v
}
return stat2, nil
}
示例4: getTasks
func getTasks(vm models.VirtualMachine) {
folder := fmt.Sprint("/proc/", vm.Ppid(), "/task/")
files, _ := ioutil.ReadDir(folder)
for _, f := range files {
taskId := f.Name()
fmt.Printf("%s ", taskId)
}
}
示例5: lookupStats
func lookupStats(vm models.VirtualMachine) (VmCpuSchedStat, error) {
cpuSchedStats := []CpuSchedStat{}
for _, taskId := range vm.VCpuTasks() {
cpuSchedStat, err := getCpuSchedStat(taskId)
if err != nil {
return VmCpuSchedStat{}, err
}
cpuSchedStats = append(cpuSchedStats, cpuSchedStat)
}
other := CpuSchedStat{}
// TODO fill other
//getTasks(vm)
return VmCpuSchedStat{cpuSchedStats, other}, nil
}
示例6: CollectDetails
func (collector StaticCollector) CollectDetails(vm models.VirtualMachine) {
staticData, err := readItems(vm)
if err != nil {
log.Printf("Error while CollectDetails in StaticCollector %a", err)
return
}
if vmx, exists := vms[vm.Name()]; exists {
vmx.StaticData = staticData
vms[vm.Name()] = vmx
} else {
vms[vm.Name()] = VirtualMachineExtended{vm, staticData}
}
}