Exemple #1
0
func _getmem(kind string, in sigar.Swap) operating.Memory {
	total, approxtotal, _ := format.HumanBandback(in.Total)
	used, approxused, _ := format.HumanBandback(in.Used)

	return operating.Memory{
		Kind:       operating.Field(kind),
		Total:      total,
		Used:       used,
		Free:       format.HumanB(in.Free),
		UsePercent: format.FormatPercent(approxused, approxtotal),
	}
}
Exemple #2
0
func FormatDFinodes(md operating.MetricDF) operating.DiskInodes {
	var (
		diskInodes = md.Inodes.Snapshot().Value()
		diskIused  = md.Iused.Snapshot().Value()
		diskIfree  = md.Ifree.Snapshot().Value()
	)
	itotal, approxitotal, _ := format.HumanBandback(uint64(diskInodes))
	iused, approxiused, _ := format.HumanBandback(uint64(diskIused))
	return operating.DiskInodes{
		DiskMeta:    diskMeta(md),
		Inodes:      itotal,
		Iused:       iused,
		Ifree:       format.HumanB(uint64(diskIfree)),
		IusePercent: format.FormatPercent(approxiused, approxitotal),
	}
}
Exemple #3
0
func FormatDFbytes(md operating.MetricDF) operating.DiskBytes {
	var (
		diskTotal = md.Total.Snapshot().Value()
		diskUsed  = md.Used.Snapshot().Value()
		diskAvail = md.Avail.Snapshot().Value()
	)
	total, approxtotal, _ := format.HumanBandback(uint64(diskTotal))
	used, approxused, _ := format.HumanBandback(uint64(diskUsed))
	return operating.DiskBytes{
		DiskMeta:   diskMeta(md),
		Total:      total,
		Used:       used,
		Avail:      format.HumanB(uint64(diskAvail)),
		UsePercent: format.FormatPercent(approxused, approxtotal),
	}
}