feat(zabbix): 添加 zabbix 自动发现接口

This commit is contained in:
2024-08-26 12:27:47 +08:00
parent 0493c3b1e6
commit 00d2b30658
2 changed files with 23 additions and 4 deletions

View File

@ -41,7 +41,7 @@ func CreateConnection(c *gin.Context) {
}
func GetConnections(c *gin.Context) {
devices := make(map[string]interface{})
devices := make(map[string]any)
for xaddr, conn := range conns {
info, err := conn.GetDeviceInfo()
@ -56,6 +56,23 @@ func GetConnections(c *gin.Context) {
response.NewResponse().WithData(devices).Send(c)
}
func ZBXConnectionDiscovery(c *gin.Context) {
type ZBXDiscovery struct {
Xaddr string `json:"{#XADDR}"`
}
arr := make([]ZBXDiscovery, 0)
for xaddr := range conns {
arr = append(arr, ZBXDiscovery{
Xaddr: xaddr,
})
}
c.JSON(http.StatusOK, gin.H{
"data": arr,
})
}
func GetConnectionByXaddr(c *gin.Context) {
xaddr := c.Param("xaddr")