Commit c4ae6626 authored by gejun's avatar gejun

Reviewed builtin_service.md

parent 1f4de22d
[English version](../en/builtin_service.md)
# 什么是内置服务?
内置服务以多种形式展现服务器内部状态,提高你开发和调试服务的效率。brpc通过HTTP协议提供内置服务,可通过浏览器或curl访问,服务器会根据User-Agent返回纯文本或html,你也可以添加?console=1要求返回纯文本。我们在自己的开发机上启动了[一个长期运行的例子](http://brpc.baidu.com:8765/),你可以点击后随便看看。对于服务端口被限的情况(比如百度内不是所有的端口都能被笔记本访问到),可以使用[rpc_view](rpc_view.md)转发或在命令行中使用curl \<SERVER-URL\>
内置服务以多种形式展现服务器内部状态,提高你开发和调试服务的效率。brpc通过HTTP协议提供内置服务,可通过浏览器或curl访问,服务器会根据User-Agent返回纯文本或html,你也可以添加?console=1要求返回纯文本。我们在自己的开发机上启动了[一个长期运行的例子](http://brpc.baidu.com:8765/)(只能百度内访问),你可以点击后随便看看。如果服务端口被限(比如百度内不是所有的端口都能被笔记本访问到),可以使用[rpc_view](rpc_view.md)转发
从浏览器访问:
下面是分别从浏览器和终端访问的截图,注意其中的logo是百度内部的名称,在开源版本中是brpc。
![img](../images/builtin_service_more.png)
**从浏览器访问**
从命令行访问:
![img](../images/builtin_service_more.png)
![img](../images/builtin_service_from_console.png)
**从命令行访问** ![img](../images/builtin_service_from_console.png)
# 安全模式
出于安全考虑,直接对外服务需要关闭内置服务(包括经过nginx或其他http server转发流量的),具体方法请阅读[这里](server.md#安全模式)
出于安全考虑,直接对外服务需要隐藏内置服务(包括经过nginx或其他http server转发流量的),具体方法请阅读[这里](server.md#安全模式)
# 主要服务
[status](status.md)
[/status](status.md): 显示所有服务的主要状态。
[vars](vars.md)
[/vars](vars.md): 用户可定制的,描绘各种指标的计数器。
[connections](connections.md)
[/connections](connections.md): 所有连接的统计信息。
[flags](flags.md)
[/flags](flags.md): 所有gflags的状态,可动态修改。
[rpcz](rpcz.md)
[/rpcz](rpcz.md): 查看所有的RPC的细节。
[cpu profiler](cpu_profiler.md)
[cpu profiler](cpu_profiler.md): 分析cpu热点。
[heap profiler](heap_profiler.md)
[heap profiler](heap_profiler.md): 分析内存占用。
[contention profiler](contention_profiler.md)
[contention profiler](contention_profiler.md): 分析锁竞争。
# 其他服务
[version服务](http://brpc.baidu.com:8765/version)可以查看服务器的版本。用户可通过Server::set_version()设置Server的版本,如果用户没有设置,框架会自动为用户生成,规则:`brpc_server_<service-name1>_<service-name2> ...`
[/version](http://brpc.baidu.com:8765/version): 查看服务器的版本。用户可通过Server::set_version()设置Server的版本,如果用户没有设置,框架会自动为用户生成,规则:`brpc_server_<service-name1>_<service-name2> ...`
![img](../images/version_service.png)
[health服务](http://brpc.baidu.com:8765/health)可以探测服务的存活情况。
[/health](http://brpc.baidu.com:8765/health): 探测服务的存活情况。
![img](../images/health_service.png)
[protobufs服务](http://brpc.baidu.com:8765/protobufs)可以查看程序中所有的protobuf结构体。
[/protobufs](http://brpc.baidu.com:8765/protobufs): 查看程序中所有的protobuf结构体。
![img](../images/protobufs_service.png)
[vlog服务](http://brpc.baidu.com:8765/vlog)可以查看程序中当前可开启的[VLOG](streaming_log.md#VLOG)
[/vlog](http://brpc.baidu.com:8765/vlog): 查看程序中当前可开启的[VLOG](streaming_log.md#VLOG) (对glog无效)
![img](../images/vlog_service.png)
dir服务可以浏览服务器上的所有文件,这个服务很敏感,默认关闭也不建议打开
/dir: 浏览服务器上的所有文件,方便但非常危险,默认关闭
threads服务可以查看进程内所有线程的运行状况,调用时对程序性能影响较大,默认关闭。
/threads: 查看进程内所有线程的运行状况,调用时对程序性能影响较大,默认关闭。
\ No newline at end of file
[中文版](../cn/builtin_service.md)
# About Builtin Services
Builtin services expose internal status of servers, making development and debugging more efficient over brpc. brpc serves builting services via `HTTP`, which can be easily accessed through curl and browsers. Servers respond *plain text* or *html* according to `User-Agent` in the request header, or you can append `?console=1` to the *uri* which forces servers to respond *plain text*. Here's an [example](http://brpc.baidu.com:8765/) running on our machine, check it out for more information about the builtin services. If the listen port is filtered(e.g. not all ports can be accessed outside data centers in Baidu), you can run [rpc_view](rpc_view.md) to launch a proxy or run `curl \<SERVER-URL\>` inside data centers.
Builtin services expose internal status of servers in different pespectives, making development and debugging over brpc more efficient. brpc serves builting services via HTTP, which can be easily accessed through curl and web browsers. Servers respond plain text or html according to `User-Agent` in the request header, or you may append `?console=1` to the uri to force the server to respond in plain text. Check the [example](http://brpc.baidu.com:8765/) running on our dev machine(only accessible from Baidu internal) for more details. If the port is forbidden from where you run curl or web browser (e.g. not all ports are accessible from a web browser inside Baidu), you can use [rpc_view](rpc_view.md) for proxying.
Following 2 screenshots show accesses to builtin services from a web browser and a terminal respectively. Note that the logo is the codename inside Baidu, and being modified to brpc in opensourced version.
Accessed through browsers:
**From a web browser**
![img](../images/builtin_service_more.png)
Accessed through terminal:
**From a terminal**
![img](../images/builtin_service_from_console.png)
# Safe Mode
# Security Mode
To stay safe from attack, you **must** disable builtin services in the servers on public network, including the ones accessed by proxies(nginx or other http servers). Click [here](../cn/server.md#安全模式) for more details.
To avoid potential attacks and information leaks, builtin services **must** be hidden on servers that may be accessed from public, including the ones proxied by nginx or other http servers. Click [here](server.md#security-mode) for more details.
# Main services:
[status](status.md)
[/status](status.md): displays brief status of all services.
[vars](vars.md)
[/vars](vars.md): lists user-customizable counters on miscellaneous metrics.
[connections](../cn/connections.md)
[/connections](../cn/connections.md): lists all connections and their stats.
[flags](../cn/flags.md)
[/flags](../cn/flags.md): lists all gflags, some of them are modifiable at run-time.
[rpcz](../cn/rpcz.md)
[/rpcz](../cn/rpcz.md): traces all RPCs.
[cpu profiler](../cn/cpu_profiler.md)
[cpu profiler](../cn/cpu_profiler.md): analyzes CPU hotspots.
[heap profiler](../cn/heap_profiler.md)
[heap profiler](../cn/heap_profiler.md): shows how memory are allocated.
[contention profiler](../cn/contention_profiler.md)
[contention profiler](../cn/contention_profiler.md): analyzes lock contentions.
# Other services
[version service](http://brpc.baidu.com:8765/version) shows the version of the server。Invoke Server::set_version() to specify version of your server, or brpc would generate a default version in like `brpc_server_<service-name1>_<service-name2> ...`
[/version](http://brpc.baidu.com:8765/version) shows version of the server. Call Server::set_version() to specify version of the server, or brpc would generate a default version like `brpc_server_<service-name1>_<service-name2> ...`
![img](../images/version_service.png)
[health service](http://brpc.baidu.com:8765/health) shows whether this server is alive or not.
[/health](http://brpc.baidu.com:8765/health) shows whether this server is alive or not.
![img](../images/health_service.png)
[protobufs service](http://brpc.baidu.com:8765/protobufs) shows scheme of all the protobuf messages insides the server.
[/protobufs](http://brpc.baidu.com:8765/protobufs) shows scheme of all protobuf messages inside the server.
![img](../images/protobufs_service.png)
[vlog service](http://brpc.baidu.com:8765/vlog) shows all the [VLOG](streaming_log.md#VLOG) that can be enable(not work with glog).
[/vlog](http://brpc.baidu.com:8765/vlog) shows all the [VLOG](streaming_log.md#VLOG) that can be enabled(not working with glog).
![img](../images/vlog_service.png)
/dir: browses all files on the server, convenient but too dangerous, disabled by default.
/threads: displays information of all threads of the process, hurting performance significantly when being turned on, disabled by default.
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment