Ejemplo n.º 1
0
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
}
Ejemplo n.º 2
0
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
}
Ejemplo n.º 3
0
func readItemStats(vm models.VirtualMachine, vmif models.MeasurementItem) (models.Statistic, error) {
	/*
		# virsh domiflist xy
		Interface  Type       Source     Model       MAC
		-------------------------------------------------------
		tap07e88f58-5d bridge     qbr07e88f58-5d virtio      fa:16:3e:63:1c:a9
	*/
	stat, err := util.VirshXDetails("domifstat", vm.Name(), vmif.Name, 1, 2, statisticEvalFunction)
	if err != nil {
		return models.Statistic{}, err
	}
	return stat, nil

}