How to Monitor data or Structs in memory in Go

huangapple go评论70阅读模式
英文:

How to Monitor data or Structs in memory in Go

问题

我想创建一个在内存中加载数据(可能是100万到200万个项目)的项目或包。我想监控这些数据,并知道这些数据是否在内存中,是否存在。在Java中,可以使用JMX(Java管理扩展)来实现,但在Golang中,我不知道如何做到这一点。

我希望在生产环境中实现这个功能,而不仅仅是在测试环境中。

任何帮助将不胜感激。

英文:

I want to create a project or package that loads data (maybe 1 or 2 million items) in memory. I want to monitor this data and know if this data is well on memory, exist or no. In Java this can be done with JMX (Java Management Extensions) but in Golang I do not know how do it.

I want to do this in a production environment, not just a testing environment.

Any help would be appreciated.

答案1

得分: 2

你可以使用os.GetUsage来跟踪内存使用情况。然后,你可以使用statsd客户端或直接发送UDP消息来更新graphite(或者你喜欢的任何监控包)。

你可能会发现这篇文章Monitoring a Production Golang Server with Memstats很有帮助。

英文:

You can use os.GetUsage to track memory usage. You can then either use a statsd client or direct UDP messages to update graphite (or whatever monitoring package you like).

You might also find this article Monitoring a Production Golang Server with Memstats helpful.

huangapple
  • 本文由 发表于 2014年4月15日 03:51:18
  • 转载请务必保留本文链接:https://go.coder-hub.com/23069028.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定