當前位置: 首頁>>代碼示例>>Golang>>正文


Golang models.VirtualMachine類代碼示例

本文整理匯總了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
}
開發者ID:cha87de,項目名稱:kvmtop,代碼行數:7,代碼來源:collector.go

示例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
}
開發者ID:cha87de,項目名稱:kvmtop,代碼行數:25,代碼來源:helper.go

示例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
}
開發者ID:cha87de,項目名稱:kvmtop,代碼行數:33,代碼來源:helper.go

示例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)
	}
}
開發者ID:cha87de,項目名稱:kvmtop,代碼行數:8,代碼來源:helper.go

示例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
}
開發者ID:cha87de,項目名稱:kvmtop,代碼行數:14,代碼來源:helper.go

示例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}
	}

}
開發者ID:cha87de,項目名稱:kvmtop,代碼行數:14,代碼來源:collector.go


注:本文中的github.com/cha87de/kvmtop/models.VirtualMachine類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。