代码拉取完成,页面将自动刷新
package jmx
import "encoding/json"
type JMXMapping struct {
MBean string
Attributes []Attribute
}
type Attribute struct {
Attr string
Field string
}
// RequestBlock is used to build the request blocks of the following format:
//
// [
// {
// "type":"read",
// "mbean":"java.lang:type=Runtime",
// "attribute":[
// "Uptime"
// ]
// },
// {
// "type":"read",
// "mbean":"java.lang:type=GarbageCollector,name=ConcurrentMarkSweep",
// "attribute":[
// "CollectionTime",
// "CollectionCount"
// ]
// }
// ]
type RequestBlock struct {
Type string `json:"type"`
MBean string `json:"mbean"`
Attribute []string `json:"attribute"`
}
func buildRequestBodyAndMapping(mappings []JMXMapping) ([]byte, map[string]string, error) {
responseMapping := map[string]string{}
var blocks []RequestBlock
for _, mapping := range mappings {
rb := RequestBlock{
Type: "read",
MBean: mapping.MBean,
}
for _, attribute := range mapping.Attributes {
rb.Attribute = append(rb.Attribute, attribute.Attr)
responseMapping[mapping.MBean+"_"+attribute.Attr] = attribute.Field
}
blocks = append(blocks, rb)
}
content, err := json.Marshal(blocks)
return content, responseMapping, err
}
此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。
如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。