stats.go
package nsqd
import (
"sort"
"sync/atomic"
"github.com/nsqio/nsq/internal/quantile"
)
type TopicStats struct {
TopicName string `json:"topic_name"`
Channels []ChannelStats `json:"channels"`
Depth int64 `json:"depth"`
BackendDepth int64 `json:"backend_depth"`
MessageCount uint64 `json:"message_count"`
Paused bool `json:"paused"`
E2eProcessingLatency *quantile.Result `json:"e2e_processing_latency"`
}
func NewTopicStats(t *Topic, channels []ChannelStats) TopicStats {
return TopicStats{
TopicName: t.name,
Channels: channels,
Depth: t.Depth(),
BackendDepth: t.backend.Depth(),
MessageCount: atomic.LoadUint64(&t.messageCount),
Paused: t.IsPaused(),
E2eProcessingLatency: t.AggregateChannelE2eProcessingLatency().Result(),
}
}
type ChannelStats struct {
ChannelName string `json:"channel_name"`
Depth int64 `json:"depth"`
BackendDepth int64 `json:"backend_depth"`
InFlightCount int `json:"in_flight_count"`
DeferredCount int `json:"deferred_count"`
MessageCount uint64 `json:"message_count"`
RequeueCount uint64 `json:"requeue_count"`
TimeoutCount uint64 `json:"timeout_count"`
Clients []ClientStats `json:"clients"`
Paused bool `json:"paused"`
E2eProcessingLatency *quantile.Result `json:"e2e_processing_latency"`
}
func NewChannelStats(c *Channel, clients []ClientStats) ChannelStats {
return ChannelStats{
ChannelName: c.name,
Depth: c.Depth(),
BackendDepth: c.backend.Depth(),
InFlightCount: len(c.inFlightMessages),
DeferredCount: len(c.deferredMessages),
MessageCount: atomic.LoadUint64(&c.messageCount),
RequeueCount: atomic.LoadUint64(&c.requeueCount),
TimeoutCount: atomic.LoadUint64(&c.timeoutCount),
Clients: clients,
Paused: c.IsPaused(),
E2eProcessingLatency: c.e2eProcessingLatencyStream.Result(),
}
}
type ClientStats struct {
// TODO: deprecated, remove in 1.0
Name string `json:"name"`
ClientID string `json:"client_id"`
Hostname string `json:"hostname"`
Version string `json:"version"`
RemoteAddress string `json:"remote_address"`
State int32 `json:"state"`
ReadyCount int64 `json:"ready_count"`
InFlightCount int64 `json:"in_flight_count"`
MessageCount uint64 `json:"message_count"`
FinishCount uint64 `json:"finish_count"`
RequeueCount uint64 `json:"requeue_count"`
ConnectTime int64 `json:"connect_ts"`
SampleRate int32 `json:"sample_rate"`
Deflate bool `json:"deflate"`
Snappy bool `json:"snappy"`
UserAgent string `json:"user_agent"`
Authed bool `json:"authed,omitempty"`
AuthIdentity string `json:"auth_identity,omitempty"`
AuthIdentityURL string `json:"auth_identity_url,omitempty"`
TLS bool `json:"tls"`
CipherSuite string `json:"tls_cipher_suite"`
TLSVersion string `json:"tls_version"`
TLSNegotiatedProtocol string `json:"tls_negotiated_protocol"`
TLSNegotiatedProtocolIsMutual bool `json:"tls_negotiated_protocol_is_mutual"`
}
type Topics []*Topic
func (t Topics) Len() int { return len(t) }
func (t Topics) Swap(i, j int) { t[i], t[j] = t[j], t[i] }
type TopicsByName struct {
Topics
}
func (t TopicsByName) Less(i, j int) bool { return t.Topics[i].name < t.Topics[j].name }
type Channels []*Channel
func (c Channels) Len() int { return len(c) }
func (c Channels) Swap(i, j int) { c[i], c[j] = c[j], c[i] }
type ChannelsByName struct {
Channels
}
func (c ChannelsByName) Less(i, j int) bool { return c.Channels[i].name < c.Channels[j].name }
func (n *NSQD) GetStats() []TopicStats {
n.RLock()
realTopics := make([]*Topic, 0, len(n.topicMap))
for _, t := range n.topicMap {
realTopics = append(realTopics, t)
}
n.RUnlock()
sort.Sort(TopicsByName{realTopics})
topics := make([]TopicStats, 0, len(realTopics))
for _, t := range realTopics {
t.RLock()
realChannels := make([]*Channel, 0, len(t.channelMap))
for _, c := range t.channelMap {
realChannels = append(realChannels, c)
}
t.RUnlock()
sort.Sort(ChannelsByName{realChannels})
channels := make([]ChannelStats, 0, len(realChannels))
for _, c := range realChannels {
c.RLock()
clients := make([]ClientStats, 0, len(c.clients))
for _, client := range c.clients {
clients = append(clients, client.Stats())
}
c.RUnlock()
channels = append(channels, NewChannelStats(c, clients))
}
topics = append(topics, NewTopicStats(t, channels))
}
return topics
}
stats.go的更多相关文章
- [转] MemCached 的 stats 命令
Memcached有个stats命令,通过它可以查看Memcached服务的许多状态信息.使用方法如下:先在命令行直接输入telnet 主机名端口号,连接到memcached服务器,然后再连接成功后, ...
- [原创博文] 用Python做统计分析 (Scipy.stats的文档)
[转自] 用Python做统计分析 (Scipy.stats的文档) 对scipy.stats的详细介绍: 这个文档说了以下内容,对python如何做统计分析感兴趣的人可以看看,毕竟Python的库也 ...
- Process Stats:了解你的APP如何使用内存(转)
原文地址:http://android-developers.blogspot.com/2014/01/process-stats-understanding-how-your.html?m=1 原作 ...
- Unity 5 Stats窗口
Unity5的 Statistics上的统计信息和Unity4 有一些区别, Statistics窗口,全称叫做 Rendering Statistics Window,即渲染统计窗口(或渲染数据统计 ...
- memcached实战系列(四)memcached stats命令 memcached优化
memcached提供一系列的命令进行优化的查看,方便我们调整我们的存储策略,查看我们的使用率,内存的使用率以及浪费情况.常用的命令有stats.stats settings.stats items. ...
- x264 n-th pass编码时候Stats文件的含义
x264 n-th pass(一般是2pass)编码时所用的文件包括下述x264参数生成.stats文件 options: 1280x816 fps=2997/125 timebase=125/299 ...
- Scipy教程 - 统计函数库scipy.stats
http://blog.csdn.net/pipisorry/article/details/49515215 统计函数Statistical functions(scipy.stats) Pytho ...
- dat.gui stats.js 通用参数配置及图像统计工具
在网上看到了一个非常好的JS烟雾效果 https://paveldogreat.github.io/WebGL-Fluid-Simulation/看源码时发现了dat.gui很好用. dat.gui ...
- scipy.stats.multivariate_normal的使用
参考:https://docs.scipy.org/doc/scipy-0.14.0/reference/generated/scipy.stats.multivariate_normal.html ...
随机推荐
- Mybatis 系列8
上篇系列7 介绍了insert.update.delete的用法, 本篇将介绍select.resultMap的用法. select无疑是我们最常用,也是最复杂的,mybatis通过resultMap ...
- Mac下的Bash配置文件冲突问题
Mac下默认的Bash配置文件是~/.profile.有的软件安装时会生成~/.bash_profiel.有了这个文件.之前的.profiel就不会再被加载,需要手动把里面的文件内容转移到.bash_ ...
- vi 常用命令使用說明
vi是一種文字模式全螢幕文字編輯軟體(Text Editor).對初學者來說,vi是個很難用的工具,一般需要2個星期的時間才能得心應手.之所以介紹vi,其理由如下: vi是Unix上的標準文字編輯軟體 ...
- java基本数据类型及其包装类
1.String类 String s1 = "hello world"; String s2 = "hello world"; String s3 = s1 + ...
- oracle 游标简单示例
1.游标的概念以及作用 游标(Cursor)可以使用户想操作数组一样对查询出来的结果集进行操作,可以形象的看做一个变动的光标,其实际行是一个指针,它在一段Oracle存放数据查询结果集或数据 操作集的 ...
- java web 开发实战经典(一)
一.jsp三种Scriptlet(脚本小程序) 1.<% %> :定义局部变量.编写语句等. <% String str = "hello world!";// ...
- RabbitMQ在windows系统安装部署文档
1.RabbitMQ简介 MQ全称为Message Queue, 消息队列(MQ)是一种应用程序对应用程序的通信方法.应用程序通过读写出入队列的消息(针对应用程序的数据)来通信,而无需专用连接来链接它 ...
- Spring Cloud(十二):分布式链路跟踪 Sleuth 与 Zipkin【Finchley 版】
Spring Cloud(十二):分布式链路跟踪 Sleuth 与 Zipkin[Finchley 版] 发表于 2018-04-24 | 随着业务发展,系统拆分导致系统调用链路愈发复杂一个前端请 ...
- JS响应数据
页面中展示的信息都是存储在服务器中的数据,离开数据的页面就像是一块画板的作用,如何通过数据来描述一个页面,又怎么映射数据变化和页面渲染的关系. 当然,最直接的方法就是操作节点,页面加载之后获取节点,再 ...
- 关于html以及js相关格式验证的记录
关于html中禁止输入的一些写法主要是实现实时监听值: 下面的例子实现的事只运行输入数字切小数位数不能超过两位的示例. 1. onkeyup事件是在输的时候在键盘松开的时候进行触发 ...