Skip to content

Commit

Permalink
Merge pull request #386 from jehiah/nsqadmin_auth_data_386
Browse files Browse the repository at this point in the history
nsqadmin: display connection auth state, and remote address
  • Loading branch information
mreiferson committed Jun 26, 2014
2 parents 1d45d24 + ab79582 commit f85596c
Show file tree
Hide file tree
Showing 5 changed files with 14 additions and 1 deletion.
5 changes: 4 additions & 1 deletion nsqadmin/templates/channel.html.go
Original file line number Diff line number Diff line change
Expand Up @@ -200,7 +200,7 @@ func init() {
{{range .ChannelStats.Clients}}
<tr>
<td>{{.ClientID}}</td>
<td title="{{.RemoteAddress}}">{{.ClientID}}</td>
<td>{{.Version}} {{if .HasUserAgent}}({{.UserAgent}}){{end}}</td>
<td>
{{if .HasSampleRate}}
Expand All @@ -215,6 +215,9 @@ func init() {
{{if .Snappy}}
<span class="label label-primary">Snappy</span>
{{end}}
{{if .Authed}}
<span class="label label-success">{{if .AuthIdentityUrl}}<a href="{{.AuthIdentityUrl}}">{{end}}<i class="icon-user icon-white" title="Authed{{if .AuthIdentity}} Identity:{{.AuthIdentity}}{{end}}"></i>{{if .AuthIdentityUrl}}</a>{{end}}</span>
{{end}}
</td>
<td><a href="/node/{{.HostAddress}}">{{.HostAddress}}</a></td>
<td>{{.InFlightCount | commafy}}</td>
Expand Down
1 change: 1 addition & 0 deletions nsqd/client_v2.go
Original file line number Diff line number Diff line change
Expand Up @@ -249,6 +249,7 @@ func (c *clientV2) Stats() ClientStats {
TLS: atomic.LoadInt32(&c.TLS) == 1,
Deflate: atomic.LoadInt32(&c.Deflate) == 1,
Snappy: atomic.LoadInt32(&c.Snappy) == 1,
Authed: c.HasAuthorizations(),
AuthIdentity: identity,
AuthIdentityURL: identityUrl,
}
Expand Down
1 change: 1 addition & 0 deletions nsqd/stats.go
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,7 @@ type ClientStats struct {
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"`
}
Expand Down
4 changes: 4 additions & 0 deletions util/lookupd/lookupd.go
Original file line number Diff line number Diff line change
Expand Up @@ -439,6 +439,7 @@ func GetNSQDStats(nsqdHTTPAddrs []string, selectedTopic string) ([]*TopicStats,

clientStats := &ClientStats{
HostAddress: addr,
RemoteAddress: client.Get("remote_address").MustString(),
Version: client.Get("version").MustString(),
ClientID: clientId,
Hostname: client.Get("hostname").MustString(),
Expand All @@ -453,6 +454,9 @@ func GetNSQDStats(nsqdHTTPAddrs []string, selectedTopic string) ([]*TopicStats,
TLS: client.Get("tls").MustBool(),
Deflate: client.Get("deflate").MustBool(),
Snappy: client.Get("snappy").MustBool(),
Authed: client.Get("authed").MustBool(),
AuthIdentity: client.Get("auth_identity").MustString(),
AuthIdentityUrl: client.Get("auth_identity_url").MustString(),
}
hostChannelStats.Clients = append(hostChannelStats.Clients, clientStats)
channelStats.Clients = append(channelStats.Clients, clientStats)
Expand Down
4 changes: 4 additions & 0 deletions util/lookupd/types.go
Original file line number Diff line number Diff line change
Expand Up @@ -155,6 +155,7 @@ func (c *ChannelStats) Host() string {

type ClientStats struct {
HostAddress string
RemoteAddress string
Version string
ClientID string
Hostname string
Expand All @@ -169,6 +170,9 @@ type ClientStats struct {
TLS bool
Deflate bool
Snappy bool
Authed bool
AuthIdentity string
AuthIdentityUrl string
}

func (c *ClientStats) HasUserAgent() bool {
Expand Down

0 comments on commit f85596c

Please sign in to comment.