1
0
Fork 0

linux Available memory 추가

This commit is contained in:
Sangbum Kim 2018-07-10 01:44:28 +09:00
parent acc89db356
commit 84a1cc5a63
2 changed files with 4 additions and 5 deletions

View File

@ -29,6 +29,7 @@ type DiskIOInfo struct {
}
type MemoryInfo struct {
Total uint64 `json:"total_bytes"`
Available uint64 `json:"available_bytes"`
Used uint64 `json:"used_bytes"`
Buffers uint64 `json:"buffers_bytes"`
Cached uint64 `json:"cached_bytes"`
@ -172,6 +173,7 @@ func (p *OSMetricInfo) MarshalMemory() (name string, tags []map[string]string, f
{
"total_bytes": p.Memory.Total,
"used_bytes": p.Memory.Used,
"available_bytes": p.Memory.Available,
"buffers_bytes": p.Memory.Buffers,
"cached_bytes": p.Memory.Cached,
"free_bytes": p.Memory.Free,
@ -216,6 +218,7 @@ func (p *osMetric) readMemoryStat(info *OSMetricInfo, errChan chan<- error, wait
}
p.logger.Debugf("memory total: ", misc.FileSizeIEC(memoryInfo.Total))
p.logger.Debugf("memory used: ", misc.FileSizeIEC(memoryInfo.Used))
p.logger.Debugf("memory available: ", misc.FileSizeIEC(memoryInfo.Available))
p.logger.Debugf("memory buffers: ", misc.FileSizeIEC(memoryInfo.Buffers))
p.logger.Debugf("memory cached: ", misc.FileSizeIEC(memoryInfo.Cached))
p.logger.Debugf("memory free: ", misc.FileSizeIEC(memoryInfo.Free))
@ -228,6 +231,7 @@ func (p *osMetric) readMemoryStat(info *OSMetricInfo, errChan chan<- error, wait
info.Memory.Total = memoryInfo.Total
info.Memory.Used = memoryInfo.Used
info.Memory.Available = memoryInfo.Available
info.Memory.Buffers = memoryInfo.Buffers
info.Memory.Cached = memoryInfo.Cached
info.Memory.Free = memoryInfo.Free

View File

@ -33,11 +33,6 @@ func a() {
//SwapFree uint64
// Stats represents memory statistics for linux
type Stats struct {
Total, Used, Buffers, Cached, Free, Available, Active, Inactive,
SwapTotal, SwapUsed, SwapCached, SwapFree uint64
MemAvailableEnabled bool
}
fmt.Println("memory total: ", misc.FileSizeIEC(memory.Total))
fmt.Println("memory used: ", misc.FileSizeIEC(memory.Used))
fmt.Println("memory buffers: ", misc.FileSizeIEC(memory.Buffers))