tokers commented on a change in pull request #2926:
URL: https://github.com/apache/apisix/pull/2926#discussion_r533998725



##########
File path: doc/zh-cn/plugins/server-info.md
##########
@@ -0,0 +1,116 @@
+<!--
+#
+# 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.
+#
+-->
+
+- [English](../../plugins/server-info.md)
+
+# Summary
+
+- [**插件简介**](#插件简介)
+- [插件属性](#插件属性)
+- [**插件接口**](#插件接口)
+- [启用插件](#启用插件)
+- [如何自定义服务信息上报间隔](#如何自定义服务信息上报间隔)
+- [测试插件](#测试插件)
+- [禁用插件](#禁用插件)
+
+## 插件简介
+
+`server-info` 是一款能够定期将服务基本信息上报至 etcd,同时允许我们通过它提供的 API 在数据面访问到这些数据的插件。
+
+## 插件属性
+
+无
+
+## 插件接口
+
+此插件提供了接口 `/apisix/server_info`,可以通过 [interceptors](../plugin-interceptors.md) 
来保护该接口。
+
+## 启用插件
+
+在配置文件 `apisix/conf/config.yaml` 的插件列表中添加 `server-info`, 即可启用该插件。
+
+```
+plugins:                          # plugin list
+  - example-plugin
+  - limit-req
+  - node-status
+  - server-info
+  - jwt-auth
+  - zipkin
+  ......
+```
+
+在启动 APISIX 之后,即可通过访问 `/apisix/server_info` 来获取服务基本信息。
+
+## 如何自定义服务信息上报间隔
+
+我们可以在 `conf/config.yaml` 文件的 `plugin_attr` 一节中修改上报间隔。
+
+| 名称         | 类型   | 默认值  | 描述                                                
          |
+| ------------ | ------ | -------- | 
-------------------------------------------------------------------- |
+| report_interval | number | 60 | 上报服务信息至 etcd 的间隔(单位:秒)|
+
+下面的例子将服务信息上报间隔修改成了 10 秒:
+
+```yaml
+plugin_attr:
+  server-info:
+    report_interval: 10
+```
+
+
+## 测试插件
+
+```bash
+curl http://127.0.0.1:9080/apisix/admin/server_info -s | jq

Review comment:
       @membphis FIxed.

##########
File path: apisix/plugins/server-info.lua
##########
@@ -0,0 +1,274 @@
+--
+-- 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.
+--
+local require = require
+local core = require("apisix.core")
+
+local ngx_time = ngx.time
+local ngx_timer_at = ngx.timer.at
+local ngx_worker_id = ngx.worker.id
+local type = type
+
+local plugin_name = "server-info"
+local boot_time = os.time()
+local current_timer
+local schema = {
+    type = "object",
+    additionalProperties = false,
+}
+local attr_schema = {
+    type = "object",
+    properties = {
+        report_interval = {
+            type = "integer",
+            description = "server info reporting interval (unit: second)",
+            default = 60,
+            minimum = 5,

Review comment:
       Fixed.




----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


Reply via email to