Reputation: 145
When we need memory related stats we add input plugin in telegraf.conf
file.
[[inputs.mem]]
[[inputs.statsd]]
Could someone explain how does [[inputs.mem]]
input plugins get data related to memory? Because no one is pushing data to telegraf in this case.
Upvotes: 1
Views: 801
Reputation: 129
Telegraf retrieves system data using system libraries written for Go. At this time it is using the gopsutil library. This library's link above includes an example of how it could be used within any Go program.
func main() {
v, _ := mem.VirtualMemory()
// almost every return value is a struct
fmt.Printf("Total: %v, Free:%v, UsedPercent:%f%%\n", v.Total, v.Free, v.UsedPercent)
// convert to JSON. String() is also implemented
fmt.Println(v)
}
This library supports a number of different operating systems and has modules for a variety of system information such as cpu, memory, disk, and networking usage. You can see where these are incorporated into the telegraf project here.
Upvotes: 1