|
16 | 16 | -export([ |
17 | 17 | handle_node_req/1, |
18 | 18 | get_stats/0, |
| 19 | + get_versions/0, |
19 | 20 | run_queues/0, |
20 | 21 | message_queues/0, |
21 | 22 | db_pid_stats/0 |
@@ -46,48 +47,10 @@ handle_node_req(#httpd{method = 'GET', path_parts = [_, _Node, <<"_smoosh">>, << |
46 | 47 | handle_node_req(#httpd{path_parts = [_, _Node, <<"_smoosh">>, <<"status">>]} = Req) -> |
47 | 48 | send_method_not_allowed(Req, "GET"); |
48 | 49 | % GET /_node/$node/_versions |
49 | | -handle_node_req(#httpd{method = 'GET', path_parts = [_, _Node, <<"_versions">>]} = Req) -> |
50 | | - IcuVer = couch_ejson_compare:get_icu_version(), |
51 | | - UcaVer = couch_ejson_compare:get_uca_version(), |
52 | | - ColVer = couch_ejson_compare:get_collator_version(), |
53 | | - Hashes = crypto:supports(hashs), |
54 | | - EngineName = couch_server:get_js_engine(), |
55 | | - JsEngine = |
56 | | - case EngineName of |
57 | | - <<"spidermonkey">> -> |
58 | | - #{ |
59 | | - name => EngineName, |
60 | | - version => couch_server:get_spidermonkey_version() |
61 | | - }; |
62 | | - _Other -> |
63 | | - #{name => EngineName} |
64 | | - end, |
65 | | - ClouseauResponse = |
66 | | - case clouseau_rpc:version() of |
67 | | - {ok, Version} -> |
68 | | - #{ |
69 | | - clouseau => #{ |
70 | | - version => Version |
71 | | - } |
72 | | - }; |
73 | | - _ -> |
74 | | - #{} |
75 | | - end, |
76 | | - BaseResponse = #{ |
77 | | - erlang => #{ |
78 | | - version => ?l2b(?COUCHDB_ERLANG_VERSION), |
79 | | - supported_hashes => Hashes |
80 | | - }, |
81 | | - collation_driver => #{ |
82 | | - name => <<"libicu">>, |
83 | | - library_version => couch_util:version_to_binary(IcuVer), |
84 | | - collation_algorithm_version => couch_util:version_to_binary(UcaVer), |
85 | | - collator_version => couch_util:version_to_binary(ColVer) |
86 | | - }, |
87 | | - javascript_engine => JsEngine |
88 | | - }, |
89 | | - Response = maps:merge(BaseResponse, ClouseauResponse), |
90 | | - send_json(Req, 200, Response); |
| 50 | +handle_node_req(#httpd{method = 'GET', path_parts = [_, Node, <<"_versions">>]} = Req) -> |
| 51 | + Versions = call_node(Node, chttpd_node, get_versions, []), |
| 52 | + EJSON = couch_stats_httpd:to_ejson(Versions), |
| 53 | + send_json(Req, EJSON); |
91 | 54 | handle_node_req(#httpd{path_parts = [_, _Node, <<"_versions">>]} = Req) -> |
92 | 55 | send_method_not_allowed(Req, "GET"); |
93 | 56 | % GET /_node/$node/_config |
@@ -339,6 +302,48 @@ get_stats() -> |
339 | 302 | {distribution_events, mem3_distribution:events()} |
340 | 303 | ]. |
341 | 304 |
|
| 305 | +get_versions() -> |
| 306 | + IcuVer = couch_ejson_compare:get_icu_version(), |
| 307 | + UcaVer = couch_ejson_compare:get_uca_version(), |
| 308 | + ColVer = couch_ejson_compare:get_collator_version(), |
| 309 | + Hashes = crypto:supports(hashs), |
| 310 | + EngineName = couch_server:get_js_engine(), |
| 311 | + JsEngine = |
| 312 | + case EngineName of |
| 313 | + <<"spidermonkey">> -> |
| 314 | + #{ |
| 315 | + name => EngineName, |
| 316 | + version => couch_server:get_spidermonkey_version() |
| 317 | + }; |
| 318 | + _Other -> |
| 319 | + #{name => EngineName} |
| 320 | + end, |
| 321 | + ClouseauResponse = |
| 322 | + case clouseau_rpc:version() of |
| 323 | + {ok, Version} when is_binary(Version) -> |
| 324 | + #{ |
| 325 | + clouseau => #{ |
| 326 | + version => Version |
| 327 | + } |
| 328 | + }; |
| 329 | + _ -> |
| 330 | + #{} |
| 331 | + end, |
| 332 | + BaseResponse = #{ |
| 333 | + erlang => #{ |
| 334 | + version => ?l2b(?COUCHDB_ERLANG_VERSION), |
| 335 | + supported_hashes => Hashes |
| 336 | + }, |
| 337 | + collation_driver => #{ |
| 338 | + name => <<"libicu">>, |
| 339 | + library_version => couch_util:version_to_binary(IcuVer), |
| 340 | + collation_algorithm_version => couch_util:version_to_binary(UcaVer), |
| 341 | + collator_version => couch_util:version_to_binary(ColVer) |
| 342 | + }, |
| 343 | + javascript_engine => JsEngine |
| 344 | + }, |
| 345 | + maps:merge(BaseResponse, ClouseauResponse). |
| 346 | + |
342 | 347 | db_pid_stats_formatted() -> |
343 | 348 | {CF, CDU} = db_pid_stats(), |
344 | 349 | {format_pid_stats(CF), format_pid_stats(CDU)}. |
|
0 commit comments