@@ -26,12 +26,216 @@ usage() {
2626 echo " reip | js-reload | erl-reload | wait-for-service | "
2727 echo " ringready | transfers | force-remove | down |"
2828 echo " cluster-info | member-status | ring-status | vnode-status |"
29- echo " aae-status | diag | status | transfer-limit | reformat-indexes |"
29+ echo " aae-status | diag | stat | status | transfer-limit | reformat-indexes |"
3030 echo " top [-interval N] [-sort reductions|memory|msg_q] [-lines N] |"
3131 echo " downgrade-objects | security | bucket-type | repair-2i |"
3232 echo " search | services | ensemble-status }"
3333}
3434
35+ stat_admin ()
36+ {
37+ case " $1 " in
38+ show)
39+ shift
40+ node_up_check
41+ $NODETOOL rpc riak_core_console stat_show " $* "
42+ ;;
43+ info)
44+ shift
45+ node_up_check
46+ $NODETOOL rpc riak_core_console stat_info " $* "
47+ ;;
48+ enable)
49+ shift
50+ node_up_check
51+ $NODETOOL rpc riak_core_console stat_enable " $* "
52+ ;;
53+ disable)
54+ shift
55+ node_up_check
56+ $NODETOOL rpc riak_core_console stat_disable " $* "
57+ ;;
58+ reset)
59+ shift
60+ node_up_check
61+ $NODETOOL rpc riak_core_console stat_reset " $* "
62+ ;;
63+ help)
64+ shift
65+ case $1 in
66+ show)
67+ stat_show_help
68+ ;;
69+ enable)
70+ stat_enable_help
71+ ;;
72+ disable)
73+ stat_enable_help
74+ ;;
75+ info)
76+ stat_info_help
77+ ;;
78+ * )
79+ stat_help
80+ esac
81+ ;;
82+ * )
83+ stat_help
84+ esac
85+ }
86+
87+ stat_help ()
88+ {
89+ echo " \
90+ Usage: $SCRIPT stat <command>
91+
92+ The following commands display, enable/disable and reset statistics.
93+ A statistics entry is given either as a 'dotted' exometer name -
94+ Identifiers separated by periods, '.', e.g. riak.riak_kv.node.gets,
95+ or as a 'legacy' name (same as in riak-admin status) - e.g. node_gets.
96+ When a legacy name is listed, the corresponding exometer name is shown as well.
97+
98+ Two kinds of wildcard are suppored:
99+ * - matches anything up to the next separator ('.' or '_') or end of name;
100+ ** - matches anything including separators.
101+ Quoting is permitted.
102+
103+ Use \` $SCRIPT stat help <command>\` for more details.
104+
105+ show <entry> Show the value(s) of a specific entry or entries
106+ enable <entry> Enable entry or entries
107+ disable <entry> Disable entry or entries
108+ reset <entry> Reset entry or entries
109+ info [ -name | -type | Display information about the entry or entries.
110+ | -module The attributes are described in the Exometer docs
111+ | -value | -cache
112+ | -status | -timestamp
113+ | -options | -ref
114+ | -datapoints ] <entry>
115+ "
116+ }
117+
118+ stat_show_help ()
119+ {
120+ echo " \
121+ Usage: $SCRIPT stat show <entry>[/type=<type>][/status=<status>][/<dp>[,<dp>]]
122+
123+ Show matching stats entries together with corresponding values
124+
125+ The format of <entry> can be one of:
126+ - 'Dotted exometer name': In Exometer, entries are represented as [A,B,...].
127+ These names can be emulated on the command-line as A.B.... Wildcards are
128+ supported: '*' will match anything between deliminators (dots), whereas
129+ '**' will match anything including deliminators. Thus \` stat show \" *.**\"\`
130+ will match all stats entries. All Riak stat entry names start with 'riak',
131+ so \` stat show riak.**\` will match all riak stat entries.
132+
133+ Example:
134+ \$ bin/riak-admin stat show riak.riak_kv.node.gets
135+ [riak,riak_kv,node,gets]: [{count,0},{one,0}]
136+
137+ - 'Legacy name': The stat names used e.g. in \` $SCRIPT status\` can be used
138+ here, but also with wildcard support. The corresponding Exometer name and
139+ datapoint will be shown as well.
140+
141+ Example:
142+ \$ bin/riak-admin stat show node_gets
143+ == node_gets (Legacy pattern): ==
144+ node_gets: 0 ([riak,riak_kv,node,gets]/one)
145+
146+ (Note: A single '*' is treated as a legacy name and would match all such
147+ names that contain no underscores; to match all exometer names, a '.' must
148+ be present, so '*.**' would work as a catch-all expression.)
149+
150+ Each Exometer entry has a type and a set of datapoints. A filter can be
151+ given on the command line, selecting only a subset of datapoints:
152+
153+ \$ bin/riak-admin stat show riak.riak_kv.node.gets/one
154+ [riak,riak_kv,node,gets]: [{one,0}]
155+
156+ The type can also be restricted:
157+ \$ bin/riak-admin stat show *.**/type=duration/mean,max
158+ [riak,riak_core,converge_delay]: [{mean,0},{max,0}]
159+ [riak,riak_core,rebalance_delay]: [{mean,0},{max,0}]
160+
161+ Note how multiple datapoints are separated by comma (no space).
162+
163+ Showing disabled entries:
164+ \$ bin/riak-admin stat show riak.riak_kv.node.gets
165+ No matching stats
166+ \$ bin/riak-admin stat show riak.riak_kv.node.gets/status=*
167+ [riak,riak_kv,node,gets]: disabled
168+ \$ bin/riak-admin stat show riak.riak_kv.node.gets/status=disabled
169+ [riak,riak_kv,node,gets]: disabled
170+ "
171+ }
172+
173+ stat_enable_help ()
174+ {
175+ echo " \
176+ Exometer stats can be disabled and enabled, and this can be done from $SCRIPT
177+ using \` $SCRIPT enable|disable <entry>\` . Disabled entries are not actively
178+ updated, and have no value.
179+
180+ The same syntax can be used as in \` stat show\` . The requested action will be
181+ performed on the matching entries.
182+
183+ \$ bin/riak-admin stat disable node_gets
184+ == node_gets (Legacy pattern): ==
185+ [riak,riak_kv,node,gets]: disabled
186+ \$ bin/riak-admin stat enable node_gets
187+ == node_gets (Legacy pattern): ==
188+ [riak,riak_kv,node,gets]: enabled
189+
190+ Wildcards can be used:
191+
192+ \$ bin/riak-admin stat disable riak.riak_kv.node.*
193+ [riak,riak_kv,node,gets]: disabled
194+ [riak,riak_kv,node,puts]: disabled
195+ "
196+ }
197+
198+ stat_info_help ()
199+ {
200+ echo " \
201+ Display Exometer meta-data for matching entries. Type of data can be controlled
202+ with options:
203+
204+ info [ -name | -type
205+ | -module
206+ | -value | -cache
207+ | -status | -timestamp
208+ | -options | -ref
209+ | -datapoints ] <entry>
210+
211+ The same entry formats can be used as for all other stat subcommands.
212+
213+ Example:
214+ \$ bin/riak-admin stat info riak.riak_kv.node.gets
215+ [riak,riak_kv,node,gets]: name = [riak,riak_kv,node,gets]
216+ type = spiral
217+ module = exometer_spiral
218+ value = disabled
219+ cache = 0
220+ status = disabled
221+ timestamp = undefined
222+ options = [{status,disabled}]
223+
224+ \$ bin/riak-admin stat info -type -status riak.riak_kv.node.gets
225+ [riak,riak_kv,node,gets]: type = spiral
226+ status = disabled
227+ "
228+ }
229+
230+ stat_reset_help ()
231+ {
232+ echo " \
233+ Usage: $SCRIPT stat reset <entry>
234+
235+ Reset matching stat entries. Only enabled entries can be reset.
236+ "
237+ }
238+
35239cluster_admin ()
36240{
37241 case " $1 " in
@@ -824,6 +1028,10 @@ case "$1" in
8241028 shift
8251029 cluster_admin " $@ "
8261030 ;;
1031+ stat)
1032+ shift
1033+ stat_admin " $@ "
1034+ ;;
8271035 bucket-type)
8281036 shift
8291037 btype_admin " $@ "
0 commit comments