feat(zabbix): 添加 zabbix 自动发现接口
This commit is contained in:
parent
0493c3b1e6
commit
00d2b30658
@ -41,7 +41,7 @@ func CreateConnection(c *gin.Context) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func GetConnections(c *gin.Context) {
|
func GetConnections(c *gin.Context) {
|
||||||
devices := make(map[string]interface{})
|
devices := make(map[string]any)
|
||||||
|
|
||||||
for xaddr, conn := range conns {
|
for xaddr, conn := range conns {
|
||||||
info, err := conn.GetDeviceInfo()
|
info, err := conn.GetDeviceInfo()
|
||||||
@ -56,6 +56,23 @@ func GetConnections(c *gin.Context) {
|
|||||||
response.NewResponse().WithData(devices).Send(c)
|
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) {
|
func GetConnectionByXaddr(c *gin.Context) {
|
||||||
xaddr := c.Param("xaddr")
|
xaddr := c.Param("xaddr")
|
||||||
|
|
||||||
|
@ -9,17 +9,19 @@ import (
|
|||||||
func SetupRoutes(r *gin.Engine) {
|
func SetupRoutes(r *gin.Engine) {
|
||||||
r.GET("/", handler.Hello)
|
r.GET("/", handler.Hello)
|
||||||
|
|
||||||
userGroup := r.Group("/onvif")
|
onvifGroup := r.Group("/onvif")
|
||||||
{
|
{
|
||||||
connectionGroup := userGroup.Group("/connections")
|
connectionGroup := onvifGroup.Group("/connections")
|
||||||
{
|
{
|
||||||
connectionGroup.POST("/", onvif.CreateConnection)
|
connectionGroup.POST("/", onvif.CreateConnection)
|
||||||
connectionGroup.GET("/", onvif.GetConnections)
|
connectionGroup.GET("/", onvif.GetConnections)
|
||||||
connectionGroup.GET("/:xaddr", onvif.GetConnectionByXaddr)
|
connectionGroup.GET("/:xaddr", onvif.GetConnectionByXaddr)
|
||||||
connectionGroup.DELETE("/:xaddr", onvif.DeleteConnection)
|
connectionGroup.DELETE("/:xaddr", onvif.DeleteConnection)
|
||||||
|
|
||||||
|
connectionGroup.POST("/zbxDiscovery", onvif.ZBXConnectionDiscovery)
|
||||||
}
|
}
|
||||||
|
|
||||||
subscriptionGroup := userGroup.Group("/subscriptions")
|
subscriptionGroup := onvifGroup.Group("/subscriptions")
|
||||||
{
|
{
|
||||||
subscriptionGroup.POST("/:xaddr", onvif.CreateEventSubscription)
|
subscriptionGroup.POST("/:xaddr", onvif.CreateEventSubscription)
|
||||||
subscriptionGroup.POST("/:xaddr/callback", onvif.EventNotifyCallback)
|
subscriptionGroup.POST("/:xaddr/callback", onvif.EventNotifyCallback)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user