uint제거 kbytes로 옮김
This commit is contained in:
parent
8c1dcace29
commit
505d6b8332
|
@ -17,20 +17,20 @@ import (
|
||||||
|
|
||||||
type NetIOInfo struct {
|
type NetIOInfo struct {
|
||||||
Name string `json:"name"`
|
Name string `json:"name"`
|
||||||
RxBytes uint64 `json:"rx_bytes"`
|
RxKBytes int64 `json:"rx_kbytes"`
|
||||||
TxBytes uint64 `json:"tx_bytes"`
|
TxKBytes int64 `json:"tx_kbytes"`
|
||||||
}
|
}
|
||||||
|
|
||||||
type MemoryInfo struct {
|
type MemoryInfo struct {
|
||||||
Total uint64 `json:"total_bytes"`
|
Total int64 `json:"total_kbytes"`
|
||||||
Active uint64 `json:"active_bytes"`
|
Active int64 `json:"active_kbytes"`
|
||||||
Cached uint64 `json:"cached_bytes"`
|
Cached int64 `json:"cached_kbytes"`
|
||||||
Free uint64 `json:"free_bytes"`
|
Free int64 `json:"free_kbytes"`
|
||||||
Inactive uint64 `json:"inactive_bytes"`
|
Inactive int64 `json:"inactive_kbytes"`
|
||||||
SwapFree uint64 `json:"swap_free_bytes"`
|
SwapFree int64 `json:"swap_free_kbytes"`
|
||||||
SwapTotal uint64 `json:"swap_total_bytes"`
|
SwapTotal int64 `json:"swap_total_kbytes"`
|
||||||
SwapUsed uint64 `json:"swap_used_bytes"`
|
SwapUsed int64 `json:"swap_used_kbytes"`
|
||||||
Used uint64 `json:"used_bytes"`
|
Used int64 `json:"used_kbytes"`
|
||||||
}
|
}
|
||||||
|
|
||||||
type LoadInfo struct {
|
type LoadInfo struct {
|
||||||
|
@ -118,8 +118,8 @@ func (p *OSMetricInfo) MarshalNetworks() (name string, tags []map[string]string,
|
||||||
"name": name,
|
"name": name,
|
||||||
}),
|
}),
|
||||||
append(fields, map[string]interface{}{
|
append(fields, map[string]interface{}{
|
||||||
"rx_bytes": info.RxBytes,
|
"rx_kbytes": info.RxKBytes,
|
||||||
"tx_bytes": info.TxBytes,
|
"tx_kbytes": info.TxKBytes,
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
return
|
return
|
||||||
|
@ -135,15 +135,15 @@ func (p *OSMetricInfo) MarshalMemory() (name string, tags []map[string]string, f
|
||||||
},
|
},
|
||||||
[]map[string]interface{}{
|
[]map[string]interface{}{
|
||||||
{
|
{
|
||||||
"total_bytes": p.Memory.Total,
|
"total_kbytes": p.Memory.Total,
|
||||||
"active_bytes": p.Memory.Active,
|
"active_kbytes": p.Memory.Active,
|
||||||
"cached_bytes": p.Memory.Cached,
|
"cached_kbytes": p.Memory.Cached,
|
||||||
"free_bytes": p.Memory.Free,
|
"free_kbytes": p.Memory.Free,
|
||||||
"inactive_bytes": p.Memory.Inactive,
|
"inactive_kbytes": p.Memory.Inactive,
|
||||||
"swap_free_bytes": p.Memory.SwapFree,
|
"swap_free_kbytes": p.Memory.SwapFree,
|
||||||
"swap_total_bytes": p.Memory.SwapTotal,
|
"swap_total_kbytes": p.Memory.SwapTotal,
|
||||||
"swap_used_bytes": p.Memory.SwapUsed,
|
"swap_used_kbytes": p.Memory.SwapUsed,
|
||||||
"used_bytes": p.Memory.Used,
|
"used_kbytes": p.Memory.Used,
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
return
|
return
|
||||||
|
@ -187,15 +187,15 @@ func (p *osMetric) readMemoryStat(info *OSMetricInfo, errChan chan<- error, wait
|
||||||
p.logger.Debug("memory swapUsed: ", misc.FileSizeIEC(memoryInfo.SwapUsed))
|
p.logger.Debug("memory swapUsed: ", misc.FileSizeIEC(memoryInfo.SwapUsed))
|
||||||
p.logger.Debug("memory used: ", misc.FileSizeIEC(memoryInfo.Used))
|
p.logger.Debug("memory used: ", misc.FileSizeIEC(memoryInfo.Used))
|
||||||
|
|
||||||
info.Memory.Total = memoryInfo.Total
|
info.Memory.Total = int64(memoryInfo.Total>>10)
|
||||||
info.Memory.Active = memoryInfo.Active
|
info.Memory.Active = int64(memoryInfo.Active>>10)
|
||||||
info.Memory.Cached = memoryInfo.Cached
|
info.Memory.Cached = int64(memoryInfo.Cached>>10)
|
||||||
info.Memory.Free = memoryInfo.Free
|
info.Memory.Free = int64(memoryInfo.Free>>10)
|
||||||
info.Memory.Inactive = memoryInfo.Inactive
|
info.Memory.Inactive = int64(memoryInfo.Inactive>>10)
|
||||||
info.Memory.SwapFree = memoryInfo.SwapFree
|
info.Memory.SwapFree = int64(memoryInfo.SwapFree>>10)
|
||||||
info.Memory.SwapTotal = memoryInfo.SwapTotal
|
info.Memory.SwapTotal = int64(memoryInfo.SwapTotal>>10)
|
||||||
info.Memory.SwapUsed = memoryInfo.SwapUsed
|
info.Memory.SwapUsed = int64(memoryInfo.SwapUsed>>10)
|
||||||
info.Memory.Used = memoryInfo.Used
|
info.Memory.Used = int64(memoryInfo.Used>>10)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -250,8 +250,8 @@ func (p *osMetric) readNetworkStat(info *OSMetricInfo, errChan chan<- error, wai
|
||||||
p.logger.Debug("netio txBytes: ", misc.FileSizeIEC(netio.TxBytes))
|
p.logger.Debug("netio txBytes: ", misc.FileSizeIEC(netio.TxBytes))
|
||||||
netIoMap[netio.Name] = NetIOInfo{
|
netIoMap[netio.Name] = NetIOInfo{
|
||||||
Name: netio.Name,
|
Name: netio.Name,
|
||||||
RxBytes: netio.RxBytes,
|
RxKBytes: int64(netio.RxBytes>>10),
|
||||||
TxBytes: netio.TxBytes,
|
TxKBytes: int64(netio.TxBytes>>10),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
info.NetIO = netIoMap
|
info.NetIO = netIoMap
|
||||||
|
|
|
@ -18,28 +18,28 @@ import (
|
||||||
|
|
||||||
type NetIOInfo struct {
|
type NetIOInfo struct {
|
||||||
Name string `json:"name"`
|
Name string `json:"name"`
|
||||||
RxBytes uint64 `json:"rx_bytes"`
|
RxKBytes int64 `json:"rx_kbytes"`
|
||||||
TxBytes uint64 `json:"tx_bytes"`
|
TxKBytes int64 `json:"tx_kbytes"`
|
||||||
}
|
}
|
||||||
|
|
||||||
type DiskIOInfo struct {
|
type DiskIOInfo struct {
|
||||||
Name string `json:"name"`
|
Name string `json:"name"`
|
||||||
ReadsCompletedBytes uint64 `json:"reads_completed_bytes"`
|
ReadsCompletedKBytes int64 `json:"reads_completed_kbytes"`
|
||||||
WritesCompletedBytes uint64 `json:"writes_completed_bytes"`
|
WritesCompletedKBytes int64 `json:"writes_completed_kbytes"`
|
||||||
}
|
}
|
||||||
type MemoryInfo struct {
|
type MemoryInfo struct {
|
||||||
Total uint64 `json:"total_bytes"`
|
Total int64 `json:"total_kbytes"`
|
||||||
Available uint64 `json:"available_bytes"`
|
Available int64 `json:"available_kbytes"`
|
||||||
Used uint64 `json:"used_bytes"`
|
Used int64 `json:"used_kbytes"`
|
||||||
Buffers uint64 `json:"buffers_bytes"`
|
Buffers int64 `json:"buffers_kbytes"`
|
||||||
Cached uint64 `json:"cached_bytes"`
|
Cached int64 `json:"cached_kbytes"`
|
||||||
Free uint64 `json:"free_bytes"`
|
Free int64 `json:"free_kbytes"`
|
||||||
Active uint64 `json:"active_bytes"`
|
Active int64 `json:"active_kbytes"`
|
||||||
Inactive uint64 `json:"inactive_bytes"`
|
Inactive int64 `json:"inactive_kbytes"`
|
||||||
SwapTotal uint64 `json:"swap_total_bytes"`
|
SwapTotal int64 `json:"swap_total_kbytes"`
|
||||||
SwapUsed uint64 `json:"swap_used_bytes"`
|
SwapUsed int64 `json:"swap_used_kbytes"`
|
||||||
SwapCached uint64 `json:"swap_cached_bytes"`
|
SwapCached int64 `json:"swap_cached_kbytes"`
|
||||||
SwapFree uint64 `json:"swap_free_bytes"`
|
SwapFree int64 `json:"swap_free_kbytes"`
|
||||||
}
|
}
|
||||||
type LoadInfo struct {
|
type LoadInfo struct {
|
||||||
Avg1 float64 `json:"avg_1"`
|
Avg1 float64 `json:"avg_1"`
|
||||||
|
@ -136,8 +136,8 @@ func (p *OSMetricInfo) MarshalNetworks() (name string, tags []map[string]string,
|
||||||
"name": name,
|
"name": name,
|
||||||
}),
|
}),
|
||||||
append(fields, map[string]interface{}{
|
append(fields, map[string]interface{}{
|
||||||
"rx_bytes": info.RxBytes,
|
"rx_kbytes": info.RxKBytes,
|
||||||
"tx_bytes": info.TxBytes,
|
"tx_kbytes": info.TxKBytes,
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
return
|
return
|
||||||
|
@ -154,8 +154,8 @@ func (p *OSMetricInfo) MarshalDisk() (name string, tags []map[string]string, fie
|
||||||
"name": name,
|
"name": name,
|
||||||
}),
|
}),
|
||||||
append(fields, map[string]interface{}{
|
append(fields, map[string]interface{}{
|
||||||
"reads_completed_bytes": info.ReadsCompletedBytes,
|
"reads_completed_kbytes": info.ReadsCompletedKBytes,
|
||||||
"writes_completed_bytes": info.WritesCompletedBytes,
|
"writes_completed_kbytes": info.WritesCompletedKBytes,
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
return
|
return
|
||||||
|
@ -171,18 +171,18 @@ func (p *OSMetricInfo) MarshalMemory() (name string, tags []map[string]string, f
|
||||||
},
|
},
|
||||||
[]map[string]interface{}{
|
[]map[string]interface{}{
|
||||||
{
|
{
|
||||||
"total_bytes": p.Memory.Total,
|
"total_kbytes": p.Memory.Total,
|
||||||
"used_bytes": p.Memory.Used,
|
"used_kbytes": p.Memory.Used,
|
||||||
"available_bytes": p.Memory.Available,
|
"available_kbytes": p.Memory.Available,
|
||||||
"buffers_bytes": p.Memory.Buffers,
|
"buffers_kbytes": p.Memory.Buffers,
|
||||||
"cached_bytes": p.Memory.Cached,
|
"cached_kbytes": p.Memory.Cached,
|
||||||
"free_bytes": p.Memory.Free,
|
"free_kbytes": p.Memory.Free,
|
||||||
"active_bytes": p.Memory.Active,
|
"active_kbytes": p.Memory.Active,
|
||||||
"inactive_bytes": p.Memory.Inactive,
|
"inactive_kbytes": p.Memory.Inactive,
|
||||||
"swap_total_bytes": p.Memory.SwapTotal,
|
"swap_total_kbytes": p.Memory.SwapTotal,
|
||||||
"swap_used_bytes": p.Memory.SwapUsed,
|
"swap_used_kbytes": p.Memory.SwapUsed,
|
||||||
"swap_cached_bytes": p.Memory.SwapCached,
|
"swap_cached_kbytes": p.Memory.SwapCached,
|
||||||
"swap_free_bytes": p.Memory.SwapFree,
|
"swap_free_kbytes": p.Memory.SwapFree,
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
return
|
return
|
||||||
|
@ -229,18 +229,18 @@ func (p *osMetric) readMemoryStat(info *OSMetricInfo, errChan chan<- error, wait
|
||||||
p.logger.Debug("memory swapCached: ", misc.FileSizeIEC(memoryInfo.SwapCached))
|
p.logger.Debug("memory swapCached: ", misc.FileSizeIEC(memoryInfo.SwapCached))
|
||||||
p.logger.Debug("memory swapFree: ", misc.FileSizeIEC(memoryInfo.SwapFree))
|
p.logger.Debug("memory swapFree: ", misc.FileSizeIEC(memoryInfo.SwapFree))
|
||||||
|
|
||||||
info.Memory.Total = memoryInfo.Total
|
info.Memory.Total = int64(memoryInfo.Total>>10)
|
||||||
info.Memory.Used = memoryInfo.Used
|
info.Memory.Used = int64(memoryInfo.Used>>10)
|
||||||
info.Memory.Available = memoryInfo.Available
|
info.Memory.Available = int64(memoryInfo.Available>>10)
|
||||||
info.Memory.Buffers = memoryInfo.Buffers
|
info.Memory.Buffers = int64(memoryInfo.Buffers>>10)
|
||||||
info.Memory.Cached = memoryInfo.Cached
|
info.Memory.Cached = int64(memoryInfo.Cached>>10)
|
||||||
info.Memory.Free = memoryInfo.Free
|
info.Memory.Free = int64(memoryInfo.Free>>10)
|
||||||
info.Memory.Active = memoryInfo.Active
|
info.Memory.Active = int64(memoryInfo.Active>>10)
|
||||||
info.Memory.Inactive = memoryInfo.Inactive
|
info.Memory.Inactive = int64(memoryInfo.Inactive>>10)
|
||||||
info.Memory.SwapTotal = memoryInfo.SwapTotal
|
info.Memory.SwapTotal = int64(memoryInfo.SwapTotal>>10)
|
||||||
info.Memory.SwapUsed = memoryInfo.SwapUsed
|
info.Memory.SwapUsed = int64(memoryInfo.SwapUsed>>10)
|
||||||
info.Memory.SwapCached = memoryInfo.SwapCached
|
info.Memory.SwapCached = int64(memoryInfo.SwapCached>>10)
|
||||||
info.Memory.SwapFree = memoryInfo.SwapFree
|
info.Memory.SwapFree = int64(memoryInfo.SwapFree>>10)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (p *osMetric) readLoadStat(info *OSMetricInfo, errChan chan<- error, waiter *sync.WaitGroup) {
|
func (p *osMetric) readLoadStat(info *OSMetricInfo, errChan chan<- error, waiter *sync.WaitGroup) {
|
||||||
|
@ -294,8 +294,8 @@ func (p *osMetric) readNetworkStat(info *OSMetricInfo, errChan chan<- error, wai
|
||||||
p.logger.Debug("netio txBytes: ", misc.FileSizeIEC(netio.TxBytes))
|
p.logger.Debug("netio txBytes: ", misc.FileSizeIEC(netio.TxBytes))
|
||||||
netIoMap[netio.Name] = NetIOInfo{
|
netIoMap[netio.Name] = NetIOInfo{
|
||||||
Name: netio.Name,
|
Name: netio.Name,
|
||||||
RxBytes: netio.RxBytes,
|
RxKBytes: int64(netio.RxBytes>>10),
|
||||||
TxBytes: netio.TxBytes,
|
TxKBytes: int64(netio.TxBytes>>10),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
info.NetIO = netIoMap
|
info.NetIO = netIoMap
|
||||||
|
@ -396,8 +396,8 @@ func (p *osMetric) readDiskStat(info *OSMetricInfo, errChan chan<- error, waiter
|
||||||
p.logger.Debug("disk written: ", misc.FileSizeIEC(dsk.WritesCompleted))
|
p.logger.Debug("disk written: ", misc.FileSizeIEC(dsk.WritesCompleted))
|
||||||
diskIoMap[dsk.Name] = DiskIOInfo{
|
diskIoMap[dsk.Name] = DiskIOInfo{
|
||||||
Name: dsk.Name,
|
Name: dsk.Name,
|
||||||
ReadsCompletedBytes: dsk.ReadsCompleted,
|
ReadsCompletedKBytes: int64(dsk.ReadsCompleted>>10),
|
||||||
WritesCompletedBytes: dsk.WritesCompleted,
|
WritesCompletedKBytes: int64(dsk.WritesCompleted>>10),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
info.DiskIO = diskIoMap
|
info.DiskIO = diskIoMap
|
||||||
|
|
Loading…
Reference in New Issue