package memcollector

import (
	"kvmtop/models"
	"kvmtop/util"
)

func hostCollect(host *models.Host) {
	stats := util.GetProcMeminfo()

	host.AddMetricMeasurement("ram_Total", models.CreateMeasurement(uint64(stats.MemTotal)))
	host.AddMetricMeasurement("ram_Free", models.CreateMeasurement(uint64(stats.MemFree)))
	host.AddMetricMeasurement("ram_Available", models.CreateMeasurement(uint64(stats.MemAvailable)))
	host.AddMetricMeasurement("ram_Buffers", models.CreateMeasurement(uint64(stats.Buffers)))
	host.AddMetricMeasurement("ram_Cached", models.CreateMeasurement(uint64(stats.Cached)))
	host.AddMetricMeasurement("ram_SwapCached", models.CreateMeasurement(uint64(stats.SwapCached)))
	host.AddMetricMeasurement("ram_Active", models.CreateMeasurement(uint64(stats.Active)))
	host.AddMetricMeasurement("ram_Inactive", models.CreateMeasurement(uint64(stats.Inactive)))
	host.AddMetricMeasurement("ram_ActiveAanon", models.CreateMeasurement(uint64(stats.ActiveAanon)))
	host.AddMetricMeasurement("ram_InactiveAanon", models.CreateMeasurement(uint64(stats.InactiveAanon)))
	host.AddMetricMeasurement("ram_ActiveFile", models.CreateMeasurement(uint64(stats.ActiveFile)))
	host.AddMetricMeasurement("ram_InactiveFile", models.CreateMeasurement(uint64(stats.InactiveFile)))
	host.AddMetricMeasurement("ram_Unevictable", models.CreateMeasurement(uint64(stats.Unevictable)))
	host.AddMetricMeasurement("ram_Mlocked", models.CreateMeasurement(uint64(stats.Mlocked)))
	host.AddMetricMeasurement("ram_SwapTotal", models.CreateMeasurement(uint64(stats.SwapTotal)))
	host.AddMetricMeasurement("ram_SwapFree", models.CreateMeasurement(uint64(stats.SwapFree)))
	host.AddMetricMeasurement("ram_Dirty", models.CreateMeasurement(uint64(stats.Dirty)))
	host.AddMetricMeasurement("ram_Writeback", models.CreateMeasurement(uint64(stats.Writeback)))
	host.AddMetricMeasurement("ram_AnonPages", models.CreateMeasurement(uint64(stats.AnonPages)))
	host.AddMetricMeasurement("ram_Mapped", models.CreateMeasurement(uint64(stats.Mapped)))
	host.AddMetricMeasurement("ram_Shmem", models.CreateMeasurement(uint64(stats.Shmem)))
	host.AddMetricMeasurement("ram_Slab", models.CreateMeasurement(uint64(stats.Slab)))
	host.AddMetricMeasurement("ram_SReclaimable", models.CreateMeasurement(uint64(stats.SReclaimable)))
	host.AddMetricMeasurement("ram_SUnreclaim", models.CreateMeasurement(uint64(stats.SUnreclaim)))
	host.AddMetricMeasurement("ram_KernelStack", models.CreateMeasurement(uint64(stats.KernelStack)))
	host.AddMetricMeasurement("ram_PageTables", models.CreateMeasurement(uint64(stats.PageTables)))
	host.AddMetricMeasurement("ram_NFSUnstable", models.CreateMeasurement(uint64(stats.NFSUnstable)))
	host.AddMetricMeasurement("ram_Bounce", models.CreateMeasurement(uint64(stats.Bounce)))
	host.AddMetricMeasurement("ram_WritebackTmp", models.CreateMeasurement(uint64(stats.WritebackTmp)))
	host.AddMetricMeasurement("ram_CommitLimit", models.CreateMeasurement(uint64(stats.CommitLimit)))
	host.AddMetricMeasurement("ram_CommittedAS", models.CreateMeasurement(uint64(stats.CommittedAS)))
	host.AddMetricMeasurement("ram_VmallocTotal", models.CreateMeasurement(uint64(stats.VmallocTotal)))
	host.AddMetricMeasurement("ram_VmallocUsed", models.CreateMeasurement(uint64(stats.VmallocUsed)))
	host.AddMetricMeasurement("ram_VmallocChunk", models.CreateMeasurement(uint64(stats.VmallocChunk)))
	host.AddMetricMeasurement("ram_HardwareCorrupted", models.CreateMeasurement(uint64(stats.HardwareCorrupted)))
	host.AddMetricMeasurement("ram_AnonHugePages", models.CreateMeasurement(uint64(stats.AnonHugePages)))
	host.AddMetricMeasurement("ram_ShmemHugePages", models.CreateMeasurement(uint64(stats.ShmemHugePages)))
	host.AddMetricMeasurement("ram_ShmemPmdMapped", models.CreateMeasurement(uint64(stats.ShmemPmdMapped)))
	host.AddMetricMeasurement("ram_HugePagesTotal", models.CreateMeasurement(uint64(stats.HugePagesTotal)))
	host.AddMetricMeasurement("ram_HugePagesFree", models.CreateMeasurement(uint64(stats.HugePagesFree)))
	host.AddMetricMeasurement("ram_HugePagesRsvd", models.CreateMeasurement(uint64(stats.HugePagesRsvd)))
	host.AddMetricMeasurement("ram_HugePagesSurp", models.CreateMeasurement(uint64(stats.HugePagesSurp)))
	host.AddMetricMeasurement("ram_Hugepagesize", models.CreateMeasurement(uint64(stats.Hugepagesize)))
	host.AddMetricMeasurement("ram_Hugetlb", models.CreateMeasurement(uint64(stats.Hugetlb)))
	host.AddMetricMeasurement("ram_DirectMap4k", models.CreateMeasurement(uint64(stats.DirectMap4k)))
	host.AddMetricMeasurement("ram_DirectMap2M", models.CreateMeasurement(uint64(stats.DirectMap2M)))
	host.AddMetricMeasurement("ram_DirectMap1G", models.CreateMeasurement(uint64(stats.DirectMap1G)))

	//fmt.Printf("collected these values: %+v\n\n", host.Dump())

}
