[jira] [Commented] (CASSANDRA-13665) nodetool clientlist
[ https://issues.apache.org/jira/browse/CASSANDRA-13665?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16420673#comment-16420673 ] ASF GitHub Bot commented on CASSANDRA-13665: Github user clohfink closed the pull request at: https://github.com/apache/cassandra/pull/190 > nodetool clientlist > --- > > Key: CASSANDRA-13665 > URL: https://issues.apache.org/jira/browse/CASSANDRA-13665 > Project: Cassandra > Issue Type: Improvement > Components: Tools >Reporter: Jon Haddad >Assignee: Chris Lohfink >Priority: Major > > There should exist a nodetool command that lists each client connection. > Ideally it would display the following: > * host > * protocol version > * user logged in as > * current keyspace > * total queries executed > * ssl connections -- This message was sent by Atlassian JIRA (v7.6.3#76005) - To unsubscribe, e-mail: commits-unsubscr...@cassandra.apache.org For additional commands, e-mail: commits-h...@cassandra.apache.org
[jira] [Commented] (CASSANDRA-13665) nodetool clientlist
[ https://issues.apache.org/jira/browse/CASSANDRA-13665?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16420351#comment-16420351 ] ASF GitHub Bot commented on CASSANDRA-13665: Github user mhartopo commented on a diff in the pull request: https://github.com/apache/cassandra/pull/190#discussion_r178269292 --- Diff: src/java/org/apache/cassandra/tools/nodetool/ClientStats.java --- @@ -0,0 +1,69 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.apache.cassandra.tools.nodetool; + +import java.util.List; +import java.util.Map; +import java.util.Map.Entry; + +import org.apache.cassandra.tools.NodeProbe; +import org.apache.cassandra.tools.NodeTool.NodeToolCmd; +import org.apache.cassandra.tools.nodetool.formatter.TableBuilder; + +import io.airlift.airline.Command; +import io.airlift.airline.Option; + +@Command(name = "clientstats", description = "Print information about connected clients") +public class ClientStats extends NodeToolCmd +{ +@Option(title = "list_connections", name = "--all", description = "Lists all connections") +private boolean listConnections = false; + +@Override +public void execute(NodeProbe probe) +{ +if (listConnections) +{ +List> clients = (List>) probe.getClientMetric("connections"); +if (!clients.isEmpty()) +{ +TableBuilder table = new TableBuilder(); +table.add("Address", "SSL", "Version", "User", "Keyspace", "Requests"); +for (Map conn : clients) +{ +table.add(conn.get("address"), conn.get("ssl"), conn.get("version"), + conn.get("user"), conn.get("keyspace"), conn.get("requests")); +} +table.printTo(System.out); +System.out.println(); +} +} + +Map connectionsByUser = (Map) probe.getClientMetric("connectedNativeClientsByUser"); +int total = connectionsByUser.values().stream().reduce(0, Integer::sum); +System.out.println("Total connected clients: " + total); +System.out.println(); +TableBuilder table = new TableBuilder(); +table.add("User", "Connections"); +for (Entry entry : connectionsByUser.entrySet()) +{ +table.add(entry.getKey(), entry.getValue().toString()); +} +table.printTo(System.out); +} +} --- End diff -- don't forget newline at the EOF > nodetool clientlist > --- > > Key: CASSANDRA-13665 > URL: https://issues.apache.org/jira/browse/CASSANDRA-13665 > Project: Cassandra > Issue Type: Improvement > Components: Tools >Reporter: Jon Haddad >Assignee: Chris Lohfink >Priority: Major > > There should exist a nodetool command that lists each client connection. > Ideally it would display the following: > * host > * protocol version > * user logged in as > * current keyspace > * total queries executed > * ssl connections -- This message was sent by Atlassian JIRA (v7.6.3#76005) - To unsubscribe, e-mail: commits-unsubscr...@cassandra.apache.org For additional commands, e-mail: commits-h...@cassandra.apache.org
[jira] [Commented] (CASSANDRA-13665) nodetool clientlist
[ https://issues.apache.org/jira/browse/CASSANDRA-13665?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16350824#comment-16350824 ] Jason Brown commented on CASSANDRA-13665: - {quote}The method was named incorrectly before, {{addCounter}} in {{ClientMetric}} actually created a Gauge, not a Counter {quote} Ahh, I see that now; thanks for clarifying. Can you fix the nits, then I can +1 and commit. > nodetool clientlist > --- > > Key: CASSANDRA-13665 > URL: https://issues.apache.org/jira/browse/CASSANDRA-13665 > Project: Cassandra > Issue Type: Improvement > Components: Tools >Reporter: Jon Haddad >Assignee: Chris Lohfink >Priority: Major > > There should exist a nodetool command that lists each client connection. > Ideally it would display the following: > * host > * protocol version > * user logged in as > * current keyspace > * total queries executed > * ssl connections -- This message was sent by Atlassian JIRA (v7.6.3#76005) - To unsubscribe, e-mail: commits-unsubscr...@cassandra.apache.org For additional commands, e-mail: commits-h...@cassandra.apache.org
[jira] [Commented] (CASSANDRA-13665) nodetool clientlist
[ https://issues.apache.org/jira/browse/CASSANDRA-13665?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16349581#comment-16349581 ] Chris Lohfink commented on CASSANDRA-13665: --- The method was named incorrectly before, {{addCounter}} in {{ClientMetric}} actually created a Gauge, not a Counter. The JMX attribute name will remain "Value" so no difference to existing tooling. > nodetool clientlist > --- > > Key: CASSANDRA-13665 > URL: https://issues.apache.org/jira/browse/CASSANDRA-13665 > Project: Cassandra > Issue Type: Improvement > Components: Tools >Reporter: Jon Haddad >Assignee: Chris Lohfink >Priority: Major > > There should exist a nodetool command that lists each client connection. > Ideally it would display the following: > * host > * protocol version > * user logged in as > * current keyspace > * total queries executed > * ssl connections -- This message was sent by Atlassian JIRA (v7.6.3#76005) - To unsubscribe, e-mail: commits-unsubscr...@cassandra.apache.org For additional commands, e-mail: commits-h...@cassandra.apache.org
[jira] [Commented] (CASSANDRA-13665) nodetool clientlist
[ https://issues.apache.org/jira/browse/CASSANDRA-13665?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16349548#comment-16349548 ] Jason Brown commented on CASSANDRA-13665: - Thanks for the patch. Overall it looks fine, but a few things: - in {{NativeTransportService}}, you've changed the metric type for {{connectedNativeClients}} from a counter to a gauge. Why? will this break existing tooling? nits: - NodeProbe - when you hit the {{default}} case, please log the metric name that was not found - ClientStats - missing apache license header - Server - replace the {{""+conn.getVersion().asInt()}} string conversion to {{String.valueOf()}} - {{CassandraDaemon}} - {{getNativeTransportService()}} doesn't seem to be used anywhere. Should it be deleted? > nodetool clientlist > --- > > Key: CASSANDRA-13665 > URL: https://issues.apache.org/jira/browse/CASSANDRA-13665 > Project: Cassandra > Issue Type: Improvement > Components: Tools >Reporter: Jon Haddad >Assignee: Chris Lohfink >Priority: Major > > There should exist a nodetool command that lists each client connection. > Ideally it would display the following: > * host > * protocol version > * user logged in as > * current keyspace > * total queries executed > * ssl connections -- This message was sent by Atlassian JIRA (v7.6.3#76005) - To unsubscribe, e-mail: commits-unsubscr...@cassandra.apache.org For additional commands, e-mail: commits-h...@cassandra.apache.org
[jira] [Commented] (CASSANDRA-13665) nodetool clientlist
[ https://issues.apache.org/jira/browse/CASSANDRA-13665?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16348152#comment-16348152 ] Chris Lohfink commented on CASSANDRA-13665: --- Looks like: {code}# nodetool clientstats --all Address SSL Version User Keyspace Requests /127.0.0.1:54320 false 4 anonymous system 5 /127.0.0.1:54327 false 4 anonymous 14 Total connected clients: 2 User Connections anonymous 2 {code} {code} # nodetool clientstats Total connected clients: 2 User Connections anonymous 2 {code} > nodetool clientlist > --- > > Key: CASSANDRA-13665 > URL: https://issues.apache.org/jira/browse/CASSANDRA-13665 > Project: Cassandra > Issue Type: Improvement > Components: Tools >Reporter: Jon Haddad >Assignee: Chris Lohfink >Priority: Major > > There should exist a nodetool command that lists each client connection. > Ideally it would display the following: > * host > * protocol version > * user logged in as > * current keyspace > * total queries executed > * ssl connections -- This message was sent by Atlassian JIRA (v7.6.3#76005) - To unsubscribe, e-mail: commits-unsubscr...@cassandra.apache.org For additional commands, e-mail: commits-h...@cassandra.apache.org
[jira] [Commented] (CASSANDRA-13665) nodetool clientlist
[ https://issues.apache.org/jira/browse/CASSANDRA-13665?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16348150#comment-16348150 ] ASF GitHub Bot commented on CASSANDRA-13665: GitHub user clohfink opened a pull request: https://github.com/apache/cassandra/pull/190 [CASSANDRA-13665] Add client list nodetool command You can merge this pull request into a Git repository by running: $ git pull https://github.com/clohfink/cassandra 13665-trunk Alternatively you can review and apply these changes as the patch at: https://github.com/apache/cassandra/pull/190.patch To close this pull request, make a commit to your master/trunk branch with (at least) the following in the commit message: This closes #190 commit 445cda37fc74b751ff0852ea0f0a49c606d54197 Author: Chris Lohfink Date: 2018-02-01T07:50:53Z Add client list nodetool command for CASSANDRA-13665 > nodetool clientlist > --- > > Key: CASSANDRA-13665 > URL: https://issues.apache.org/jira/browse/CASSANDRA-13665 > Project: Cassandra > Issue Type: Improvement > Components: Tools >Reporter: Jon Haddad >Assignee: Chris Lohfink >Priority: Major > > There should exist a nodetool command that lists each client connection. > Ideally it would display the following: > * host > * protocol version > * user logged in as > * current keyspace > * total queries executed > * ssl connections -- This message was sent by Atlassian JIRA (v7.6.3#76005) - To unsubscribe, e-mail: commits-unsubscr...@cassandra.apache.org For additional commands, e-mail: commits-h...@cassandra.apache.org
[jira] [Commented] (CASSANDRA-13665) nodetool clientlist
[ https://issues.apache.org/jira/browse/CASSANDRA-13665?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16347151#comment-16347151 ] Jon Haddad commented on CASSANDRA-13665: It would also be nice to know how many queries are in flight, but fine if we punt that to a later patch if it proves to be non-trivial. > nodetool clientlist > --- > > Key: CASSANDRA-13665 > URL: https://issues.apache.org/jira/browse/CASSANDRA-13665 > Project: Cassandra > Issue Type: Improvement > Components: Tools >Reporter: Jon Haddad >Assignee: Chris Lohfink >Priority: Major > > There should exist a nodetool command that lists each client connection. > Ideally it would display the following: > * host > * protocol version > * user logged in as > * current keyspace > * total queries executed -- This message was sent by Atlassian JIRA (v7.6.3#76005) - To unsubscribe, e-mail: commits-unsubscr...@cassandra.apache.org For additional commands, e-mail: commits-h...@cassandra.apache.org