feat: send alarminfo through hook

This commit is contained in:
pggiroro
2025-07-02 21:48:28 +08:00
parent baf3640b23
commit cad47aec5c
14 changed files with 1692 additions and 2073 deletions

View File

@@ -6,15 +6,17 @@ import (
// AlarmInfo 报警信息实体,用于存储到数据库
type AlarmInfo struct {
ID uint `gorm:"primaryKey;autoIncrement" json:"id"` // 主键自增ID
ServerInfo string `gorm:"type:varchar(255);not null" json:"server_info"` // 服务器信息
StreamName string `gorm:"type:varchar(255);index" json:"stream_name"` // 流名称
StreamPath string `gorm:"type:varchar(500)" json:"stream_path"` // 流的streampath
AlarmDesc string `gorm:"type:varchar(500);not null" json:"alarm_desc"` // 报警描述
AlarmType int `gorm:"not null;index" json:"alarm_type"` // 报警类型(对应之前定义的常量)
IsSent bool `gorm:"default:false" json:"is_sent"` // 是否已成功发送
CreatedAt time.Time `gorm:"autoCreateTime" json:"created_at"` // 创建时间,报警时间
UpdatedAt time.Time `gorm:"autoUpdateTime" json:"updated_at"` // 更新时间
ID uint `gorm:"primaryKey;autoIncrement" json:"id"` // 主键自增ID
ServerInfo string `gorm:"type:varchar(255);not null" json:"serverInfo"` // 服务器信息
StreamName string `gorm:"type:varchar(255);index" json:"streamName"` // 流名称
StreamPath string `gorm:"type:varchar(500)" json:"streamPath"` // 流的streampath
AlarmName string `gorm:"type:varchar(255);not null" json:"alarmName"` // 报警名称
AlarmDesc string `gorm:"type:varchar(500);not null" json:"alarmDesc"` // 报警描述
AlarmType int `gorm:"not null;index" json:"alarmType"` // 报警类型(对应之前定义的常量)
IsSent bool `gorm:"default:false" json:"isSent"` // 是否已成功发送
CreatedAt time.Time `gorm:"autoCreateTime" json:"createdAt"` // 创建时间,报警时间
UpdatedAt time.Time `gorm:"autoUpdateTime" json:"updatedAt"` // 更新时间
FilePath string `gorm:"type:varchar(255)" json:"filePath"` // 文件路径
}
// TableName 指定表名

113
api.go
View File

@@ -942,3 +942,116 @@ func (s *Server) GetTransformList(ctx context.Context, req *emptypb.Empty) (res
})
return
}
func (s *Server) GetAlarmList(ctx context.Context, req *pb.AlarmListRequest) (res *pb.AlarmListResponse, err error) {
// 初始化响应对象
res = &pb.AlarmListResponse{
Code: 0,
Message: "success",
PageNum: req.PageNum,
PageSize: req.PageSize,
}
// 检查数据库连接是否可用
if s.DB == nil {
res.Code = 500
res.Message = "数据库连接不可用"
return res, nil
}
// 构建查询条件
query := s.DB.Model(&AlarmInfo{})
// 添加时间范围过滤
startTime, endTime, err := util.TimeRangeQueryParse(url.Values{
"range": []string{req.Range},
"start": []string{req.Start},
"end": []string{req.End},
})
if err == nil {
if !startTime.IsZero() {
query = query.Where("created_at >= ?", startTime)
}
if !endTime.IsZero() {
query = query.Where("created_at <= ?", endTime)
}
}
// 添加告警类型过滤
if req.AlarmType != 0 {
query = query.Where("alarm_type = ?", req.AlarmType)
}
// 添加 StreamPath 过滤
if req.StreamPath != "" {
if strings.Contains(req.StreamPath, "*") {
// 支持通配符搜索
query = query.Where("stream_path LIKE ?", strings.ReplaceAll(req.StreamPath, "*", "%"))
} else {
query = query.Where("stream_path = ?", req.StreamPath)
}
}
// 添加 StreamName 过滤
if req.StreamName != "" {
if strings.Contains(req.StreamName, "*") {
// 支持通配符搜索
query = query.Where("stream_name LIKE ?", strings.ReplaceAll(req.StreamName, "*", "%"))
} else {
query = query.Where("stream_name = ?", req.StreamName)
}
}
// 计算总记录数
var total int64
if err = query.Count(&total).Error; err != nil {
res.Code = 500
res.Message = "查询告警信息总数失败: " + err.Error()
return res, nil
}
res.Total = int32(total)
// 如果没有记录,直接返回
if total == 0 {
return res, nil
}
// 处理分页参数
if req.PageNum <= 0 {
req.PageNum = 1
}
if req.PageSize <= 0 {
req.PageSize = 10
}
// 查询分页数据
var alarmInfoList []AlarmInfo
offset := (req.PageNum - 1) * req.PageSize
if err = query.Order("created_at DESC").
Offset(int(offset)).
Limit(int(req.PageSize)).
Find(&alarmInfoList).Error; err != nil {
res.Code = 500
res.Message = "查询告警信息失败: " + err.Error()
return res, nil
}
// 转换为 protobuf 格式
res.Data = make([]*pb.AlarmInfo, len(alarmInfoList))
for i, alarm := range alarmInfoList {
res.Data[i] = &pb.AlarmInfo{
Id: uint32(alarm.ID),
ServerInfo: alarm.ServerInfo,
StreamName: alarm.StreamName,
StreamPath: alarm.StreamPath,
AlarmDesc: alarm.AlarmDesc,
AlarmType: int32(alarm.AlarmType),
IsSent: alarm.IsSent,
CreatedAt: timestamppb.New(alarm.CreatedAt),
UpdatedAt: timestamppb.New(alarm.UpdatedAt),
FilePath: alarm.FilePath,
}
}
return res, nil
}

View File

@@ -10,6 +10,7 @@ package pb
import (
"context"
"errors"
"io"
"net/http"
@@ -24,116 +25,110 @@ import (
)
// Suppress "imported and not used" errors
var _ codes.Code
var _ io.Reader
var _ status.Status
var _ = runtime.String
var _ = utilities.NewDoubleArray
var _ = metadata.Join
var (
_ codes.Code
_ io.Reader
_ status.Status
_ = errors.New
_ = runtime.String
_ = utilities.NewDoubleArray
_ = metadata.Join
)
func request_Auth_Login_0(ctx context.Context, marshaler runtime.Marshaler, client AuthClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) {
var protoReq LoginRequest
var metadata runtime.ServerMetadata
if err := marshaler.NewDecoder(req.Body).Decode(&protoReq); err != nil && err != io.EOF {
var (
protoReq LoginRequest
metadata runtime.ServerMetadata
)
if err := marshaler.NewDecoder(req.Body).Decode(&protoReq); err != nil && !errors.Is(err, io.EOF) {
return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err)
}
msg, err := client.Login(ctx, &protoReq, grpc.Header(&metadata.HeaderMD), grpc.Trailer(&metadata.TrailerMD))
return msg, metadata, err
}
func local_request_Auth_Login_0(ctx context.Context, marshaler runtime.Marshaler, server AuthServer, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) {
var protoReq LoginRequest
var metadata runtime.ServerMetadata
if err := marshaler.NewDecoder(req.Body).Decode(&protoReq); err != nil && err != io.EOF {
var (
protoReq LoginRequest
metadata runtime.ServerMetadata
)
if err := marshaler.NewDecoder(req.Body).Decode(&protoReq); err != nil && !errors.Is(err, io.EOF) {
return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err)
}
msg, err := server.Login(ctx, &protoReq)
return msg, metadata, err
}
func request_Auth_Logout_0(ctx context.Context, marshaler runtime.Marshaler, client AuthClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) {
var protoReq LogoutRequest
var metadata runtime.ServerMetadata
if err := marshaler.NewDecoder(req.Body).Decode(&protoReq); err != nil && err != io.EOF {
var (
protoReq LogoutRequest
metadata runtime.ServerMetadata
)
if err := marshaler.NewDecoder(req.Body).Decode(&protoReq); err != nil && !errors.Is(err, io.EOF) {
return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err)
}
msg, err := client.Logout(ctx, &protoReq, grpc.Header(&metadata.HeaderMD), grpc.Trailer(&metadata.TrailerMD))
return msg, metadata, err
}
func local_request_Auth_Logout_0(ctx context.Context, marshaler runtime.Marshaler, server AuthServer, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) {
var protoReq LogoutRequest
var metadata runtime.ServerMetadata
if err := marshaler.NewDecoder(req.Body).Decode(&protoReq); err != nil && err != io.EOF {
var (
protoReq LogoutRequest
metadata runtime.ServerMetadata
)
if err := marshaler.NewDecoder(req.Body).Decode(&protoReq); err != nil && !errors.Is(err, io.EOF) {
return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err)
}
msg, err := server.Logout(ctx, &protoReq)
return msg, metadata, err
}
var (
filter_Auth_GetUserInfo_0 = &utilities.DoubleArray{Encoding: map[string]int{}, Base: []int(nil), Check: []int(nil)}
)
var filter_Auth_GetUserInfo_0 = &utilities.DoubleArray{Encoding: map[string]int{}, Base: []int(nil), Check: []int(nil)}
func request_Auth_GetUserInfo_0(ctx context.Context, marshaler runtime.Marshaler, client AuthClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) {
var protoReq UserInfoRequest
var metadata runtime.ServerMetadata
var (
protoReq UserInfoRequest
metadata runtime.ServerMetadata
)
io.Copy(io.Discard, req.Body)
if err := req.ParseForm(); err != nil {
return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err)
}
if err := runtime.PopulateQueryParameters(&protoReq, req.Form, filter_Auth_GetUserInfo_0); err != nil {
return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err)
}
msg, err := client.GetUserInfo(ctx, &protoReq, grpc.Header(&metadata.HeaderMD), grpc.Trailer(&metadata.TrailerMD))
return msg, metadata, err
}
func local_request_Auth_GetUserInfo_0(ctx context.Context, marshaler runtime.Marshaler, server AuthServer, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) {
var protoReq UserInfoRequest
var metadata runtime.ServerMetadata
var (
protoReq UserInfoRequest
metadata runtime.ServerMetadata
)
if err := req.ParseForm(); err != nil {
return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err)
}
if err := runtime.PopulateQueryParameters(&protoReq, req.Form, filter_Auth_GetUserInfo_0); err != nil {
return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err)
}
msg, err := server.GetUserInfo(ctx, &protoReq)
return msg, metadata, err
}
// RegisterAuthHandlerServer registers the http handlers for service Auth to "mux".
// UnaryRPC :call AuthServer directly.
// StreamingRPC :currently unsupported pending https://github.com/grpc/grpc-go/issues/906.
// Note that using this registration option will cause many gRPC library features to stop working. Consider using RegisterAuthHandlerFromEndpoint instead.
// GRPC interceptors will not work for this type of registration. To use interceptors, you must use the "runtime.WithMiddlewares" option in the "runtime.NewServeMux" call.
func RegisterAuthHandlerServer(ctx context.Context, mux *runtime.ServeMux, server AuthServer) error {
mux.Handle("POST", pattern_Auth_Login_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) {
mux.Handle(http.MethodPost, pattern_Auth_Login_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) {
ctx, cancel := context.WithCancel(req.Context())
defer cancel()
var stream runtime.ServerTransportStream
ctx = grpc.NewContextWithServerTransportStream(ctx, &stream)
inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req)
var err error
var annotatedContext context.Context
annotatedContext, err = runtime.AnnotateIncomingContext(ctx, mux, req, "/pb.Auth/Login", runtime.WithHTTPPathPattern("/api/auth/login"))
annotatedContext, err := runtime.AnnotateIncomingContext(ctx, mux, req, "/pb.Auth/Login", runtime.WithHTTPPathPattern("/api/auth/login"))
if err != nil {
runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err)
return
@@ -145,20 +140,15 @@ func RegisterAuthHandlerServer(ctx context.Context, mux *runtime.ServeMux, serve
runtime.HTTPError(annotatedContext, mux, outboundMarshaler, w, req, err)
return
}
forward_Auth_Login_0(annotatedContext, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...)
})
mux.Handle("POST", pattern_Auth_Logout_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) {
mux.Handle(http.MethodPost, pattern_Auth_Logout_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) {
ctx, cancel := context.WithCancel(req.Context())
defer cancel()
var stream runtime.ServerTransportStream
ctx = grpc.NewContextWithServerTransportStream(ctx, &stream)
inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req)
var err error
var annotatedContext context.Context
annotatedContext, err = runtime.AnnotateIncomingContext(ctx, mux, req, "/pb.Auth/Logout", runtime.WithHTTPPathPattern("/api/auth/logout"))
annotatedContext, err := runtime.AnnotateIncomingContext(ctx, mux, req, "/pb.Auth/Logout", runtime.WithHTTPPathPattern("/api/auth/logout"))
if err != nil {
runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err)
return
@@ -170,20 +160,15 @@ func RegisterAuthHandlerServer(ctx context.Context, mux *runtime.ServeMux, serve
runtime.HTTPError(annotatedContext, mux, outboundMarshaler, w, req, err)
return
}
forward_Auth_Logout_0(annotatedContext, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...)
})
mux.Handle("GET", pattern_Auth_GetUserInfo_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) {
mux.Handle(http.MethodGet, pattern_Auth_GetUserInfo_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) {
ctx, cancel := context.WithCancel(req.Context())
defer cancel()
var stream runtime.ServerTransportStream
ctx = grpc.NewContextWithServerTransportStream(ctx, &stream)
inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req)
var err error
var annotatedContext context.Context
annotatedContext, err = runtime.AnnotateIncomingContext(ctx, mux, req, "/pb.Auth/GetUserInfo", runtime.WithHTTPPathPattern("/api/auth/userinfo"))
annotatedContext, err := runtime.AnnotateIncomingContext(ctx, mux, req, "/pb.Auth/GetUserInfo", runtime.WithHTTPPathPattern("/api/auth/userinfo"))
if err != nil {
runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err)
return
@@ -195,9 +180,7 @@ func RegisterAuthHandlerServer(ctx context.Context, mux *runtime.ServeMux, serve
runtime.HTTPError(annotatedContext, mux, outboundMarshaler, w, req, err)
return
}
forward_Auth_GetUserInfo_0(annotatedContext, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...)
})
return nil
@@ -206,25 +189,24 @@ func RegisterAuthHandlerServer(ctx context.Context, mux *runtime.ServeMux, serve
// RegisterAuthHandlerFromEndpoint is same as RegisterAuthHandler but
// automatically dials to "endpoint" and closes the connection when "ctx" gets done.
func RegisterAuthHandlerFromEndpoint(ctx context.Context, mux *runtime.ServeMux, endpoint string, opts []grpc.DialOption) (err error) {
conn, err := grpc.DialContext(ctx, endpoint, opts...)
conn, err := grpc.NewClient(endpoint, opts...)
if err != nil {
return err
}
defer func() {
if err != nil {
if cerr := conn.Close(); cerr != nil {
grpclog.Infof("Failed to close conn to %s: %v", endpoint, cerr)
grpclog.Errorf("Failed to close conn to %s: %v", endpoint, cerr)
}
return
}
go func() {
<-ctx.Done()
if cerr := conn.Close(); cerr != nil {
grpclog.Infof("Failed to close conn to %s: %v", endpoint, cerr)
grpclog.Errorf("Failed to close conn to %s: %v", endpoint, cerr)
}
}()
}()
return RegisterAuthHandler(ctx, mux, conn)
}
@@ -238,16 +220,13 @@ func RegisterAuthHandler(ctx context.Context, mux *runtime.ServeMux, conn *grpc.
// to "mux". The handlers forward requests to the grpc endpoint over the given implementation of "AuthClient".
// Note: the gRPC framework executes interceptors within the gRPC handler. If the passed in "AuthClient"
// doesn't go through the normal gRPC flow (creating a gRPC client etc.) then it will be up to the passed in
// "AuthClient" to call the correct interceptors.
// "AuthClient" to call the correct interceptors. This client ignores the HTTP middlewares.
func RegisterAuthHandlerClient(ctx context.Context, mux *runtime.ServeMux, client AuthClient) error {
mux.Handle("POST", pattern_Auth_Login_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) {
mux.Handle(http.MethodPost, pattern_Auth_Login_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) {
ctx, cancel := context.WithCancel(req.Context())
defer cancel()
inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req)
var err error
var annotatedContext context.Context
annotatedContext, err = runtime.AnnotateContext(ctx, mux, req, "/pb.Auth/Login", runtime.WithHTTPPathPattern("/api/auth/login"))
annotatedContext, err := runtime.AnnotateContext(ctx, mux, req, "/pb.Auth/Login", runtime.WithHTTPPathPattern("/api/auth/login"))
if err != nil {
runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err)
return
@@ -258,18 +237,13 @@ func RegisterAuthHandlerClient(ctx context.Context, mux *runtime.ServeMux, clien
runtime.HTTPError(annotatedContext, mux, outboundMarshaler, w, req, err)
return
}
forward_Auth_Login_0(annotatedContext, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...)
})
mux.Handle("POST", pattern_Auth_Logout_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) {
mux.Handle(http.MethodPost, pattern_Auth_Logout_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) {
ctx, cancel := context.WithCancel(req.Context())
defer cancel()
inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req)
var err error
var annotatedContext context.Context
annotatedContext, err = runtime.AnnotateContext(ctx, mux, req, "/pb.Auth/Logout", runtime.WithHTTPPathPattern("/api/auth/logout"))
annotatedContext, err := runtime.AnnotateContext(ctx, mux, req, "/pb.Auth/Logout", runtime.WithHTTPPathPattern("/api/auth/logout"))
if err != nil {
runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err)
return
@@ -280,18 +254,13 @@ func RegisterAuthHandlerClient(ctx context.Context, mux *runtime.ServeMux, clien
runtime.HTTPError(annotatedContext, mux, outboundMarshaler, w, req, err)
return
}
forward_Auth_Logout_0(annotatedContext, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...)
})
mux.Handle("GET", pattern_Auth_GetUserInfo_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) {
mux.Handle(http.MethodGet, pattern_Auth_GetUserInfo_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) {
ctx, cancel := context.WithCancel(req.Context())
defer cancel()
inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req)
var err error
var annotatedContext context.Context
annotatedContext, err = runtime.AnnotateContext(ctx, mux, req, "/pb.Auth/GetUserInfo", runtime.WithHTTPPathPattern("/api/auth/userinfo"))
annotatedContext, err := runtime.AnnotateContext(ctx, mux, req, "/pb.Auth/GetUserInfo", runtime.WithHTTPPathPattern("/api/auth/userinfo"))
if err != nil {
runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err)
return
@@ -302,26 +271,19 @@ func RegisterAuthHandlerClient(ctx context.Context, mux *runtime.ServeMux, clien
runtime.HTTPError(annotatedContext, mux, outboundMarshaler, w, req, err)
return
}
forward_Auth_GetUserInfo_0(annotatedContext, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...)
})
return nil
}
var (
pattern_Auth_Login_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2}, []string{"api", "auth", "login"}, ""))
pattern_Auth_Logout_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2}, []string{"api", "auth", "logout"}, ""))
pattern_Auth_Login_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2}, []string{"api", "auth", "login"}, ""))
pattern_Auth_Logout_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2}, []string{"api", "auth", "logout"}, ""))
pattern_Auth_GetUserInfo_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2}, []string{"api", "auth", "userinfo"}, ""))
)
var (
forward_Auth_Login_0 = runtime.ForwardResponseMessage
forward_Auth_Logout_0 = runtime.ForwardResponseMessage
forward_Auth_Login_0 = runtime.ForwardResponseMessage
forward_Auth_Logout_0 = runtime.ForwardResponseMessage
forward_Auth_GetUserInfo_0 = runtime.ForwardResponseMessage
)

View File

@@ -4770,6 +4770,306 @@ func (x *ReqRecordCatalog) GetType() string {
return ""
}
type AlarmInfo struct {
state protoimpl.MessageState `protogen:"open.v1"`
Id uint32 `protobuf:"varint,1,opt,name=id,proto3" json:"id,omitempty"`
ServerInfo string `protobuf:"bytes,2,opt,name=serverInfo,proto3" json:"serverInfo,omitempty"`
StreamName string `protobuf:"bytes,3,opt,name=streamName,proto3" json:"streamName,omitempty"`
StreamPath string `protobuf:"bytes,4,opt,name=streamPath,proto3" json:"streamPath,omitempty"`
AlarmDesc string `protobuf:"bytes,5,opt,name=alarmDesc,proto3" json:"alarmDesc,omitempty"`
AlarmType int32 `protobuf:"varint,6,opt,name=alarmType,proto3" json:"alarmType,omitempty"`
IsSent bool `protobuf:"varint,7,opt,name=isSent,proto3" json:"isSent,omitempty"`
FilePath string `protobuf:"bytes,8,opt,name=filePath,proto3" json:"filePath,omitempty"`
CreatedAt *timestamppb.Timestamp `protobuf:"bytes,9,opt,name=createdAt,proto3" json:"createdAt,omitempty"`
UpdatedAt *timestamppb.Timestamp `protobuf:"bytes,10,opt,name=updatedAt,proto3" json:"updatedAt,omitempty"`
unknownFields protoimpl.UnknownFields
sizeCache protoimpl.SizeCache
}
func (x *AlarmInfo) Reset() {
*x = AlarmInfo{}
mi := &file_global_proto_msgTypes[66]
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
ms.StoreMessageInfo(mi)
}
func (x *AlarmInfo) String() string {
return protoimpl.X.MessageStringOf(x)
}
func (*AlarmInfo) ProtoMessage() {}
func (x *AlarmInfo) ProtoReflect() protoreflect.Message {
mi := &file_global_proto_msgTypes[66]
if x != nil {
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
if ms.LoadMessageInfo() == nil {
ms.StoreMessageInfo(mi)
}
return ms
}
return mi.MessageOf(x)
}
// Deprecated: Use AlarmInfo.ProtoReflect.Descriptor instead.
func (*AlarmInfo) Descriptor() ([]byte, []int) {
return file_global_proto_rawDescGZIP(), []int{66}
}
func (x *AlarmInfo) GetId() uint32 {
if x != nil {
return x.Id
}
return 0
}
func (x *AlarmInfo) GetServerInfo() string {
if x != nil {
return x.ServerInfo
}
return ""
}
func (x *AlarmInfo) GetStreamName() string {
if x != nil {
return x.StreamName
}
return ""
}
func (x *AlarmInfo) GetStreamPath() string {
if x != nil {
return x.StreamPath
}
return ""
}
func (x *AlarmInfo) GetAlarmDesc() string {
if x != nil {
return x.AlarmDesc
}
return ""
}
func (x *AlarmInfo) GetAlarmType() int32 {
if x != nil {
return x.AlarmType
}
return 0
}
func (x *AlarmInfo) GetIsSent() bool {
if x != nil {
return x.IsSent
}
return false
}
func (x *AlarmInfo) GetFilePath() string {
if x != nil {
return x.FilePath
}
return ""
}
func (x *AlarmInfo) GetCreatedAt() *timestamppb.Timestamp {
if x != nil {
return x.CreatedAt
}
return nil
}
func (x *AlarmInfo) GetUpdatedAt() *timestamppb.Timestamp {
if x != nil {
return x.UpdatedAt
}
return nil
}
type AlarmListRequest struct {
state protoimpl.MessageState `protogen:"open.v1"`
PageNum int32 `protobuf:"varint,1,opt,name=pageNum,proto3" json:"pageNum,omitempty"`
PageSize int32 `protobuf:"varint,2,opt,name=pageSize,proto3" json:"pageSize,omitempty"`
Range string `protobuf:"bytes,3,opt,name=range,proto3" json:"range,omitempty"`
Start string `protobuf:"bytes,4,opt,name=start,proto3" json:"start,omitempty"`
End string `protobuf:"bytes,5,opt,name=end,proto3" json:"end,omitempty"`
AlarmType int32 `protobuf:"varint,6,opt,name=alarmType,proto3" json:"alarmType,omitempty"`
StreamPath string `protobuf:"bytes,7,opt,name=streamPath,proto3" json:"streamPath,omitempty"`
StreamName string `protobuf:"bytes,8,opt,name=streamName,proto3" json:"streamName,omitempty"`
unknownFields protoimpl.UnknownFields
sizeCache protoimpl.SizeCache
}
func (x *AlarmListRequest) Reset() {
*x = AlarmListRequest{}
mi := &file_global_proto_msgTypes[67]
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
ms.StoreMessageInfo(mi)
}
func (x *AlarmListRequest) String() string {
return protoimpl.X.MessageStringOf(x)
}
func (*AlarmListRequest) ProtoMessage() {}
func (x *AlarmListRequest) ProtoReflect() protoreflect.Message {
mi := &file_global_proto_msgTypes[67]
if x != nil {
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
if ms.LoadMessageInfo() == nil {
ms.StoreMessageInfo(mi)
}
return ms
}
return mi.MessageOf(x)
}
// Deprecated: Use AlarmListRequest.ProtoReflect.Descriptor instead.
func (*AlarmListRequest) Descriptor() ([]byte, []int) {
return file_global_proto_rawDescGZIP(), []int{67}
}
func (x *AlarmListRequest) GetPageNum() int32 {
if x != nil {
return x.PageNum
}
return 0
}
func (x *AlarmListRequest) GetPageSize() int32 {
if x != nil {
return x.PageSize
}
return 0
}
func (x *AlarmListRequest) GetRange() string {
if x != nil {
return x.Range
}
return ""
}
func (x *AlarmListRequest) GetStart() string {
if x != nil {
return x.Start
}
return ""
}
func (x *AlarmListRequest) GetEnd() string {
if x != nil {
return x.End
}
return ""
}
func (x *AlarmListRequest) GetAlarmType() int32 {
if x != nil {
return x.AlarmType
}
return 0
}
func (x *AlarmListRequest) GetStreamPath() string {
if x != nil {
return x.StreamPath
}
return ""
}
func (x *AlarmListRequest) GetStreamName() string {
if x != nil {
return x.StreamName
}
return ""
}
type AlarmListResponse struct {
state protoimpl.MessageState `protogen:"open.v1"`
Code int32 `protobuf:"varint,1,opt,name=code,proto3" json:"code,omitempty"`
Message string `protobuf:"bytes,2,opt,name=message,proto3" json:"message,omitempty"`
Total int32 `protobuf:"varint,3,opt,name=total,proto3" json:"total,omitempty"`
PageNum int32 `protobuf:"varint,4,opt,name=pageNum,proto3" json:"pageNum,omitempty"`
PageSize int32 `protobuf:"varint,5,opt,name=pageSize,proto3" json:"pageSize,omitempty"`
Data []*AlarmInfo `protobuf:"bytes,6,rep,name=data,proto3" json:"data,omitempty"`
unknownFields protoimpl.UnknownFields
sizeCache protoimpl.SizeCache
}
func (x *AlarmListResponse) Reset() {
*x = AlarmListResponse{}
mi := &file_global_proto_msgTypes[68]
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
ms.StoreMessageInfo(mi)
}
func (x *AlarmListResponse) String() string {
return protoimpl.X.MessageStringOf(x)
}
func (*AlarmListResponse) ProtoMessage() {}
func (x *AlarmListResponse) ProtoReflect() protoreflect.Message {
mi := &file_global_proto_msgTypes[68]
if x != nil {
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
if ms.LoadMessageInfo() == nil {
ms.StoreMessageInfo(mi)
}
return ms
}
return mi.MessageOf(x)
}
// Deprecated: Use AlarmListResponse.ProtoReflect.Descriptor instead.
func (*AlarmListResponse) Descriptor() ([]byte, []int) {
return file_global_proto_rawDescGZIP(), []int{68}
}
func (x *AlarmListResponse) GetCode() int32 {
if x != nil {
return x.Code
}
return 0
}
func (x *AlarmListResponse) GetMessage() string {
if x != nil {
return x.Message
}
return ""
}
func (x *AlarmListResponse) GetTotal() int32 {
if x != nil {
return x.Total
}
return 0
}
func (x *AlarmListResponse) GetPageNum() int32 {
if x != nil {
return x.PageNum
}
return 0
}
func (x *AlarmListResponse) GetPageSize() int32 {
if x != nil {
return x.PageSize
}
return 0
}
func (x *AlarmListResponse) GetData() []*AlarmInfo {
if x != nil {
return x.Data
}
return nil
}
var File_global_proto protoreflect.FileDescriptor
const file_global_proto_rawDesc = "" +
@@ -5251,7 +5551,45 @@ const file_global_proto_rawDesc = "" +
"\amessage\x18\x02 \x01(\tR\amessage\x12&\n" +
"\x04data\x18\x03 \x03(\v2\x12.global.RecordFileR\x04data\"&\n" +
"\x10ReqRecordCatalog\x12\x12\n" +
"\x04type\x18\x01 \x01(\tR\x04type2\xba\"\n" +
"\x04type\x18\x01 \x01(\tR\x04type\"\xdf\x02\n" +
"\tAlarmInfo\x12\x0e\n" +
"\x02id\x18\x01 \x01(\rR\x02id\x12\x1e\n" +
"\n" +
"serverInfo\x18\x02 \x01(\tR\n" +
"serverInfo\x12\x1e\n" +
"\n" +
"streamName\x18\x03 \x01(\tR\n" +
"streamName\x12\x1e\n" +
"\n" +
"streamPath\x18\x04 \x01(\tR\n" +
"streamPath\x12\x1c\n" +
"\talarmDesc\x18\x05 \x01(\tR\talarmDesc\x12\x1c\n" +
"\talarmType\x18\x06 \x01(\x05R\talarmType\x12\x16\n" +
"\x06isSent\x18\a \x01(\bR\x06isSent\x12\x1a\n" +
"\bfilePath\x18\b \x01(\tR\bfilePath\x128\n" +
"\tcreatedAt\x18\t \x01(\v2\x1a.google.protobuf.TimestampR\tcreatedAt\x128\n" +
"\tupdatedAt\x18\n" +
" \x01(\v2\x1a.google.protobuf.TimestampR\tupdatedAt\"\xe4\x01\n" +
"\x10AlarmListRequest\x12\x18\n" +
"\apageNum\x18\x01 \x01(\x05R\apageNum\x12\x1a\n" +
"\bpageSize\x18\x02 \x01(\x05R\bpageSize\x12\x14\n" +
"\x05range\x18\x03 \x01(\tR\x05range\x12\x14\n" +
"\x05start\x18\x04 \x01(\tR\x05start\x12\x10\n" +
"\x03end\x18\x05 \x01(\tR\x03end\x12\x1c\n" +
"\talarmType\x18\x06 \x01(\x05R\talarmType\x12\x1e\n" +
"\n" +
"streamPath\x18\a \x01(\tR\n" +
"streamPath\x12\x1e\n" +
"\n" +
"streamName\x18\b \x01(\tR\n" +
"streamName\"\xb4\x01\n" +
"\x11AlarmListResponse\x12\x12\n" +
"\x04code\x18\x01 \x01(\x05R\x04code\x12\x18\n" +
"\amessage\x18\x02 \x01(\tR\amessage\x12\x14\n" +
"\x05total\x18\x03 \x01(\x05R\x05total\x12\x18\n" +
"\apageNum\x18\x04 \x01(\x05R\apageNum\x12\x1a\n" +
"\bpageSize\x18\x05 \x01(\x05R\bpageSize\x12%\n" +
"\x04data\x18\x06 \x03(\v2\x11.global.AlarmInfoR\x04data2\x98#\n" +
"\x03api\x12P\n" +
"\aSysInfo\x12\x16.google.protobuf.Empty\x1a\x17.global.SysInfoResponse\"\x14\x82\xd3\xe4\x93\x02\x0e\x12\f/api/sysinfo\x12i\n" +
"\x0fDisabledPlugins\x12\x16.google.protobuf.Empty\x1a\x1f.global.DisabledPluginsResponse\"\x1d\x82\xd3\xe4\x93\x02\x17\x12\x15/api/plugins/disabled\x12P\n" +
@@ -5297,7 +5635,8 @@ const file_global_proto_rawDesc = "" +
"\rGetRecordList\x12\x15.global.ReqRecordList\x1a\x1a.global.RecordResponseList\"/\x82\xd3\xe4\x93\x02)\x12'/api/record/{type}/list/{streamPath=**}\x12\x83\x01\n" +
"\x12GetEventRecordList\x12\x15.global.ReqRecordList\x1a\x1f.global.EventRecordResponseList\"5\x82\xd3\xe4\x93\x02/\x12-/api/record/{type}/event/list/{streamPath=**}\x12i\n" +
"\x10GetRecordCatalog\x12\x18.global.ReqRecordCatalog\x1a\x17.global.ResponseCatalog\"\"\x82\xd3\xe4\x93\x02\x1c\x12\x1a/api/record/{type}/catalog\x12u\n" +
"\fDeleteRecord\x12\x17.global.ReqRecordDelete\x1a\x16.global.ResponseDelete\"4\x82\xd3\xe4\x93\x02.:\x01*\")/api/record/{type}/delete/{streamPath=**}B\x10Z\x0em7s.live/v5/pbb\x06proto3"
"\fDeleteRecord\x12\x17.global.ReqRecordDelete\x1a\x16.global.ResponseDelete\"4\x82\xd3\xe4\x93\x02.:\x01*\")/api/record/{type}/delete/{streamPath=**}\x12\\\n" +
"\fGetAlarmList\x12\x18.global.AlarmListRequest\x1a\x19.global.AlarmListResponse\"\x17\x82\xd3\xe4\x93\x02\x11\x12\x0f/api/alarm/listB\x10Z\x0em7s.live/v5/pbb\x06proto3"
var (
file_global_proto_rawDescOnce sync.Once
@@ -5311,7 +5650,7 @@ func file_global_proto_rawDescGZIP() []byte {
return file_global_proto_rawDescData
}
var file_global_proto_msgTypes = make([]protoimpl.MessageInfo, 73)
var file_global_proto_msgTypes = make([]protoimpl.MessageInfo, 76)
var file_global_proto_goTypes = []any{
(*DisabledPluginsResponse)(nil), // 0: global.DisabledPluginsResponse
(*GetConfigRequest)(nil), // 1: global.GetConfigRequest
@@ -5379,170 +5718,178 @@ var file_global_proto_goTypes = []any{
(*ReqRecordDelete)(nil), // 63: global.ReqRecordDelete
(*ResponseDelete)(nil), // 64: global.ResponseDelete
(*ReqRecordCatalog)(nil), // 65: global.ReqRecordCatalog
nil, // 66: global.Formily.PropertiesEntry
nil, // 67: global.Formily.ComponentPropsEntry
nil, // 68: global.FormilyResponse.PropertiesEntry
nil, // 69: global.PluginInfo.DescriptionEntry
nil, // 70: global.TaskTreeData.DescriptionEntry
nil, // 71: global.StreamWaitListResponse.ListEntry
nil, // 72: global.TrackSnapShotData.ReaderEntry
(*timestamppb.Timestamp)(nil), // 73: google.protobuf.Timestamp
(*durationpb.Duration)(nil), // 74: google.protobuf.Duration
(*anypb.Any)(nil), // 75: google.protobuf.Any
(*emptypb.Empty)(nil), // 76: google.protobuf.Empty
(*AlarmInfo)(nil), // 66: global.AlarmInfo
(*AlarmListRequest)(nil), // 67: global.AlarmListRequest
(*AlarmListResponse)(nil), // 68: global.AlarmListResponse
nil, // 69: global.Formily.PropertiesEntry
nil, // 70: global.Formily.ComponentPropsEntry
nil, // 71: global.FormilyResponse.PropertiesEntry
nil, // 72: global.PluginInfo.DescriptionEntry
nil, // 73: global.TaskTreeData.DescriptionEntry
nil, // 74: global.StreamWaitListResponse.ListEntry
nil, // 75: global.TrackSnapShotData.ReaderEntry
(*timestamppb.Timestamp)(nil), // 76: google.protobuf.Timestamp
(*durationpb.Duration)(nil), // 77: google.protobuf.Duration
(*anypb.Any)(nil), // 78: google.protobuf.Any
(*emptypb.Empty)(nil), // 79: google.protobuf.Empty
}
var file_global_proto_depIdxs = []int32{
12, // 0: global.DisabledPluginsResponse.data:type_name -> global.PluginInfo
66, // 1: global.Formily.properties:type_name -> global.Formily.PropertiesEntry
67, // 2: global.Formily.componentProps:type_name -> global.Formily.ComponentPropsEntry
68, // 3: global.FormilyResponse.properties:type_name -> global.FormilyResponse.PropertiesEntry
69, // 1: global.Formily.properties:type_name -> global.Formily.PropertiesEntry
70, // 2: global.Formily.componentProps:type_name -> global.Formily.ComponentPropsEntry
71, // 3: global.FormilyResponse.properties:type_name -> global.FormilyResponse.PropertiesEntry
4, // 4: global.GetConfigResponse.data:type_name -> global.ConfigData
10, // 5: global.SummaryResponse.memory:type_name -> global.Usage
10, // 6: global.SummaryResponse.hardDisk:type_name -> global.Usage
9, // 7: global.SummaryResponse.netWork:type_name -> global.NetWorkInfo
69, // 8: global.PluginInfo.description:type_name -> global.PluginInfo.DescriptionEntry
73, // 9: global.SysInfoData.startTime:type_name -> google.protobuf.Timestamp
72, // 8: global.PluginInfo.description:type_name -> global.PluginInfo.DescriptionEntry
76, // 9: global.SysInfoData.startTime:type_name -> google.protobuf.Timestamp
12, // 10: global.SysInfoData.plugins:type_name -> global.PluginInfo
13, // 11: global.SysInfoResponse.data:type_name -> global.SysInfoData
73, // 12: global.TaskTreeData.startTime:type_name -> google.protobuf.Timestamp
70, // 13: global.TaskTreeData.description:type_name -> global.TaskTreeData.DescriptionEntry
76, // 12: global.TaskTreeData.startTime:type_name -> google.protobuf.Timestamp
73, // 13: global.TaskTreeData.description:type_name -> global.TaskTreeData.DescriptionEntry
15, // 14: global.TaskTreeData.children:type_name -> global.TaskTreeData
15, // 15: global.TaskTreeData.blocked:type_name -> global.TaskTreeData
15, // 16: global.TaskTreeResponse.data:type_name -> global.TaskTreeData
22, // 17: global.StreamListResponse.data:type_name -> global.StreamInfo
71, // 18: global.StreamWaitListResponse.list:type_name -> global.StreamWaitListResponse.ListEntry
74, // 18: global.StreamWaitListResponse.list:type_name -> global.StreamWaitListResponse.ListEntry
22, // 19: global.StreamInfoResponse.data:type_name -> global.StreamInfo
28, // 20: global.StreamInfo.audioTrack:type_name -> global.AudioTrackInfo
31, // 21: global.StreamInfo.videoTrack:type_name -> global.VideoTrackInfo
73, // 22: global.StreamInfo.startTime:type_name -> google.protobuf.Timestamp
74, // 23: global.StreamInfo.bufferTime:type_name -> google.protobuf.Duration
76, // 22: global.StreamInfo.startTime:type_name -> google.protobuf.Timestamp
77, // 23: global.StreamInfo.bufferTime:type_name -> google.protobuf.Duration
23, // 24: global.StreamInfo.recording:type_name -> global.RecordingDetail
74, // 25: global.RecordingDetail.fragment:type_name -> google.protobuf.Duration
73, // 26: global.TrackSnapShot.writeTime:type_name -> google.protobuf.Timestamp
77, // 25: global.RecordingDetail.fragment:type_name -> google.protobuf.Duration
76, // 26: global.TrackSnapShot.writeTime:type_name -> google.protobuf.Timestamp
24, // 27: global.TrackSnapShot.wrap:type_name -> global.Wrap
26, // 28: global.MemoryBlockGroup.list:type_name -> global.MemoryBlock
25, // 29: global.TrackSnapShotData.ring:type_name -> global.TrackSnapShot
72, // 30: global.TrackSnapShotData.reader:type_name -> global.TrackSnapShotData.ReaderEntry
75, // 30: global.TrackSnapShotData.reader:type_name -> global.TrackSnapShotData.ReaderEntry
27, // 31: global.TrackSnapShotData.memory:type_name -> global.MemoryBlockGroup
29, // 32: global.TrackSnapShotResponse.data:type_name -> global.TrackSnapShotData
73, // 33: global.SubscriberSnapShot.startTime:type_name -> google.protobuf.Timestamp
76, // 33: global.SubscriberSnapShot.startTime:type_name -> google.protobuf.Timestamp
37, // 34: global.SubscriberSnapShot.audioReader:type_name -> global.RingReaderSnapShot
37, // 35: global.SubscriberSnapShot.videoReader:type_name -> global.RingReaderSnapShot
74, // 36: global.SubscriberSnapShot.bufferTime:type_name -> google.protobuf.Duration
77, // 36: global.SubscriberSnapShot.bufferTime:type_name -> google.protobuf.Duration
38, // 37: global.SubscribersResponse.data:type_name -> global.SubscriberSnapShot
41, // 38: global.PullProxyListResponse.data:type_name -> global.PullProxyInfo
73, // 39: global.PullProxyInfo.createTime:type_name -> google.protobuf.Timestamp
73, // 40: global.PullProxyInfo.updateTime:type_name -> google.protobuf.Timestamp
74, // 41: global.PullProxyInfo.recordFragment:type_name -> google.protobuf.Duration
73, // 42: global.PushProxyInfo.createTime:type_name -> google.protobuf.Timestamp
73, // 43: global.PushProxyInfo.updateTime:type_name -> google.protobuf.Timestamp
76, // 39: global.PullProxyInfo.createTime:type_name -> google.protobuf.Timestamp
76, // 40: global.PullProxyInfo.updateTime:type_name -> google.protobuf.Timestamp
77, // 41: global.PullProxyInfo.recordFragment:type_name -> google.protobuf.Duration
76, // 42: global.PushProxyInfo.createTime:type_name -> google.protobuf.Timestamp
76, // 43: global.PushProxyInfo.updateTime:type_name -> google.protobuf.Timestamp
42, // 44: global.PushProxyListResponse.data:type_name -> global.PushProxyInfo
45, // 45: global.StreamAliasListResponse.data:type_name -> global.StreamAlias
73, // 46: global.Recording.startTime:type_name -> google.protobuf.Timestamp
76, // 46: global.Recording.startTime:type_name -> google.protobuf.Timestamp
49, // 47: global.RecordingListResponse.data:type_name -> global.Recording
73, // 48: global.PushInfo.startTime:type_name -> google.protobuf.Timestamp
76, // 48: global.PushInfo.startTime:type_name -> google.protobuf.Timestamp
51, // 49: global.PushListResponse.data:type_name -> global.PushInfo
54, // 50: global.TransformListResponse.data:type_name -> global.Transform
73, // 51: global.RecordFile.startTime:type_name -> google.protobuf.Timestamp
73, // 52: global.RecordFile.endTime:type_name -> google.protobuf.Timestamp
73, // 53: global.EventRecordFile.startTime:type_name -> google.protobuf.Timestamp
73, // 54: global.EventRecordFile.endTime:type_name -> google.protobuf.Timestamp
76, // 51: global.RecordFile.startTime:type_name -> google.protobuf.Timestamp
76, // 52: global.RecordFile.endTime:type_name -> google.protobuf.Timestamp
76, // 53: global.EventRecordFile.startTime:type_name -> google.protobuf.Timestamp
76, // 54: global.EventRecordFile.endTime:type_name -> google.protobuf.Timestamp
57, // 55: global.RecordResponseList.data:type_name -> global.RecordFile
58, // 56: global.EventRecordResponseList.data:type_name -> global.EventRecordFile
73, // 57: global.Catalog.startTime:type_name -> google.protobuf.Timestamp
73, // 58: global.Catalog.endTime:type_name -> google.protobuf.Timestamp
76, // 57: global.Catalog.startTime:type_name -> google.protobuf.Timestamp
76, // 58: global.Catalog.endTime:type_name -> google.protobuf.Timestamp
61, // 59: global.ResponseCatalog.data:type_name -> global.Catalog
57, // 60: global.ResponseDelete.data:type_name -> global.RecordFile
2, // 61: global.Formily.PropertiesEntry.value:type_name -> global.Formily
75, // 62: global.Formily.ComponentPropsEntry.value:type_name -> google.protobuf.Any
2, // 63: global.FormilyResponse.PropertiesEntry.value:type_name -> global.Formily
76, // 64: global.api.SysInfo:input_type -> google.protobuf.Empty
76, // 65: global.api.DisabledPlugins:input_type -> google.protobuf.Empty
76, // 66: global.api.Summary:input_type -> google.protobuf.Empty
33, // 67: global.api.Shutdown:input_type -> global.RequestWithId
33, // 68: global.api.Restart:input_type -> global.RequestWithId
76, // 69: global.api.TaskTree:input_type -> google.protobuf.Empty
34, // 70: global.api.StopTask:input_type -> global.RequestWithId64
34, // 71: global.api.RestartTask:input_type -> global.RequestWithId64
17, // 72: global.api.StreamList:input_type -> global.StreamListRequest
76, // 73: global.api.WaitList:input_type -> google.protobuf.Empty
20, // 74: global.api.StreamInfo:input_type -> global.StreamSnapRequest
20, // 75: global.api.PauseStream:input_type -> global.StreamSnapRequest
20, // 76: global.api.ResumeStream:input_type -> global.StreamSnapRequest
47, // 77: global.api.SetStreamSpeed:input_type -> global.SetStreamSpeedRequest
48, // 78: global.api.SeekStream:input_type -> global.SeekStreamRequest
36, // 79: global.api.GetSubscribers:input_type -> global.SubscribersRequest
20, // 80: global.api.AudioTrackSnap:input_type -> global.StreamSnapRequest
20, // 81: global.api.VideoTrackSnap:input_type -> global.StreamSnapRequest
35, // 82: global.api.ChangeSubscribe:input_type -> global.ChangeSubscribeRequest
76, // 83: global.api.GetStreamAlias:input_type -> google.protobuf.Empty
44, // 84: global.api.SetStreamAlias:input_type -> global.SetStreamAliasRequest
20, // 85: global.api.StopPublish:input_type -> global.StreamSnapRequest
33, // 86: global.api.StopSubscribe:input_type -> global.RequestWithId
76, // 87: global.api.GetConfigFile:input_type -> google.protobuf.Empty
7, // 88: global.api.UpdateConfigFile:input_type -> global.UpdateConfigFileRequest
1, // 89: global.api.GetConfig:input_type -> global.GetConfigRequest
1, // 90: global.api.GetFormily:input_type -> global.GetConfigRequest
76, // 91: global.api.GetPullProxyList:input_type -> google.protobuf.Empty
41, // 92: global.api.AddPullProxy:input_type -> global.PullProxyInfo
33, // 93: global.api.RemovePullProxy:input_type -> global.RequestWithId
41, // 94: global.api.UpdatePullProxy:input_type -> global.PullProxyInfo
76, // 95: global.api.GetPushProxyList:input_type -> google.protobuf.Empty
42, // 96: global.api.AddPushProxy:input_type -> global.PushProxyInfo
33, // 97: global.api.RemovePushProxy:input_type -> global.RequestWithId
42, // 98: global.api.UpdatePushProxy:input_type -> global.PushProxyInfo
76, // 99: global.api.GetRecording:input_type -> google.protobuf.Empty
76, // 100: global.api.GetTransformList:input_type -> google.protobuf.Empty
56, // 101: global.api.GetRecordList:input_type -> global.ReqRecordList
56, // 102: global.api.GetEventRecordList:input_type -> global.ReqRecordList
65, // 103: global.api.GetRecordCatalog:input_type -> global.ReqRecordCatalog
63, // 104: global.api.DeleteRecord:input_type -> global.ReqRecordDelete
14, // 105: global.api.SysInfo:output_type -> global.SysInfoResponse
0, // 106: global.api.DisabledPlugins:output_type -> global.DisabledPluginsResponse
11, // 107: global.api.Summary:output_type -> global.SummaryResponse
32, // 108: global.api.Shutdown:output_type -> global.SuccessResponse
32, // 109: global.api.Restart:output_type -> global.SuccessResponse
16, // 110: global.api.TaskTree:output_type -> global.TaskTreeResponse
32, // 111: global.api.StopTask:output_type -> global.SuccessResponse
32, // 112: global.api.RestartTask:output_type -> global.SuccessResponse
18, // 113: global.api.StreamList:output_type -> global.StreamListResponse
19, // 114: global.api.WaitList:output_type -> global.StreamWaitListResponse
21, // 115: global.api.StreamInfo:output_type -> global.StreamInfoResponse
32, // 116: global.api.PauseStream:output_type -> global.SuccessResponse
32, // 117: global.api.ResumeStream:output_type -> global.SuccessResponse
32, // 118: global.api.SetStreamSpeed:output_type -> global.SuccessResponse
32, // 119: global.api.SeekStream:output_type -> global.SuccessResponse
39, // 120: global.api.GetSubscribers:output_type -> global.SubscribersResponse
30, // 121: global.api.AudioTrackSnap:output_type -> global.TrackSnapShotResponse
30, // 122: global.api.VideoTrackSnap:output_type -> global.TrackSnapShotResponse
32, // 123: global.api.ChangeSubscribe:output_type -> global.SuccessResponse
46, // 124: global.api.GetStreamAlias:output_type -> global.StreamAliasListResponse
32, // 125: global.api.SetStreamAlias:output_type -> global.SuccessResponse
32, // 126: global.api.StopPublish:output_type -> global.SuccessResponse
32, // 127: global.api.StopSubscribe:output_type -> global.SuccessResponse
5, // 128: global.api.GetConfigFile:output_type -> global.GetConfigFileResponse
32, // 129: global.api.UpdateConfigFile:output_type -> global.SuccessResponse
6, // 130: global.api.GetConfig:output_type -> global.GetConfigResponse
6, // 131: global.api.GetFormily:output_type -> global.GetConfigResponse
40, // 132: global.api.GetPullProxyList:output_type -> global.PullProxyListResponse
32, // 133: global.api.AddPullProxy:output_type -> global.SuccessResponse
32, // 134: global.api.RemovePullProxy:output_type -> global.SuccessResponse
32, // 135: global.api.UpdatePullProxy:output_type -> global.SuccessResponse
43, // 136: global.api.GetPushProxyList:output_type -> global.PushProxyListResponse
32, // 137: global.api.AddPushProxy:output_type -> global.SuccessResponse
32, // 138: global.api.RemovePushProxy:output_type -> global.SuccessResponse
32, // 139: global.api.UpdatePushProxy:output_type -> global.SuccessResponse
50, // 140: global.api.GetRecording:output_type -> global.RecordingListResponse
55, // 141: global.api.GetTransformList:output_type -> global.TransformListResponse
59, // 142: global.api.GetRecordList:output_type -> global.RecordResponseList
60, // 143: global.api.GetEventRecordList:output_type -> global.EventRecordResponseList
62, // 144: global.api.GetRecordCatalog:output_type -> global.ResponseCatalog
64, // 145: global.api.DeleteRecord:output_type -> global.ResponseDelete
105, // [105:146] is the sub-list for method output_type
64, // [64:105] is the sub-list for method input_type
64, // [64:64] is the sub-list for extension type_name
64, // [64:64] is the sub-list for extension extendee
0, // [0:64] is the sub-list for field type_name
76, // 61: global.AlarmInfo.createdAt:type_name -> google.protobuf.Timestamp
76, // 62: global.AlarmInfo.updatedAt:type_name -> google.protobuf.Timestamp
66, // 63: global.AlarmListResponse.data:type_name -> global.AlarmInfo
2, // 64: global.Formily.PropertiesEntry.value:type_name -> global.Formily
78, // 65: global.Formily.ComponentPropsEntry.value:type_name -> google.protobuf.Any
2, // 66: global.FormilyResponse.PropertiesEntry.value:type_name -> global.Formily
79, // 67: global.api.SysInfo:input_type -> google.protobuf.Empty
79, // 68: global.api.DisabledPlugins:input_type -> google.protobuf.Empty
79, // 69: global.api.Summary:input_type -> google.protobuf.Empty
33, // 70: global.api.Shutdown:input_type -> global.RequestWithId
33, // 71: global.api.Restart:input_type -> global.RequestWithId
79, // 72: global.api.TaskTree:input_type -> google.protobuf.Empty
34, // 73: global.api.StopTask:input_type -> global.RequestWithId64
34, // 74: global.api.RestartTask:input_type -> global.RequestWithId64
17, // 75: global.api.StreamList:input_type -> global.StreamListRequest
79, // 76: global.api.WaitList:input_type -> google.protobuf.Empty
20, // 77: global.api.StreamInfo:input_type -> global.StreamSnapRequest
20, // 78: global.api.PauseStream:input_type -> global.StreamSnapRequest
20, // 79: global.api.ResumeStream:input_type -> global.StreamSnapRequest
47, // 80: global.api.SetStreamSpeed:input_type -> global.SetStreamSpeedRequest
48, // 81: global.api.SeekStream:input_type -> global.SeekStreamRequest
36, // 82: global.api.GetSubscribers:input_type -> global.SubscribersRequest
20, // 83: global.api.AudioTrackSnap:input_type -> global.StreamSnapRequest
20, // 84: global.api.VideoTrackSnap:input_type -> global.StreamSnapRequest
35, // 85: global.api.ChangeSubscribe:input_type -> global.ChangeSubscribeRequest
79, // 86: global.api.GetStreamAlias:input_type -> google.protobuf.Empty
44, // 87: global.api.SetStreamAlias:input_type -> global.SetStreamAliasRequest
20, // 88: global.api.StopPublish:input_type -> global.StreamSnapRequest
33, // 89: global.api.StopSubscribe:input_type -> global.RequestWithId
79, // 90: global.api.GetConfigFile:input_type -> google.protobuf.Empty
7, // 91: global.api.UpdateConfigFile:input_type -> global.UpdateConfigFileRequest
1, // 92: global.api.GetConfig:input_type -> global.GetConfigRequest
1, // 93: global.api.GetFormily:input_type -> global.GetConfigRequest
79, // 94: global.api.GetPullProxyList:input_type -> google.protobuf.Empty
41, // 95: global.api.AddPullProxy:input_type -> global.PullProxyInfo
33, // 96: global.api.RemovePullProxy:input_type -> global.RequestWithId
41, // 97: global.api.UpdatePullProxy:input_type -> global.PullProxyInfo
79, // 98: global.api.GetPushProxyList:input_type -> google.protobuf.Empty
42, // 99: global.api.AddPushProxy:input_type -> global.PushProxyInfo
33, // 100: global.api.RemovePushProxy:input_type -> global.RequestWithId
42, // 101: global.api.UpdatePushProxy:input_type -> global.PushProxyInfo
79, // 102: global.api.GetRecording:input_type -> google.protobuf.Empty
79, // 103: global.api.GetTransformList:input_type -> google.protobuf.Empty
56, // 104: global.api.GetRecordList:input_type -> global.ReqRecordList
56, // 105: global.api.GetEventRecordList:input_type -> global.ReqRecordList
65, // 106: global.api.GetRecordCatalog:input_type -> global.ReqRecordCatalog
63, // 107: global.api.DeleteRecord:input_type -> global.ReqRecordDelete
67, // 108: global.api.GetAlarmList:input_type -> global.AlarmListRequest
14, // 109: global.api.SysInfo:output_type -> global.SysInfoResponse
0, // 110: global.api.DisabledPlugins:output_type -> global.DisabledPluginsResponse
11, // 111: global.api.Summary:output_type -> global.SummaryResponse
32, // 112: global.api.Shutdown:output_type -> global.SuccessResponse
32, // 113: global.api.Restart:output_type -> global.SuccessResponse
16, // 114: global.api.TaskTree:output_type -> global.TaskTreeResponse
32, // 115: global.api.StopTask:output_type -> global.SuccessResponse
32, // 116: global.api.RestartTask:output_type -> global.SuccessResponse
18, // 117: global.api.StreamList:output_type -> global.StreamListResponse
19, // 118: global.api.WaitList:output_type -> global.StreamWaitListResponse
21, // 119: global.api.StreamInfo:output_type -> global.StreamInfoResponse
32, // 120: global.api.PauseStream:output_type -> global.SuccessResponse
32, // 121: global.api.ResumeStream:output_type -> global.SuccessResponse
32, // 122: global.api.SetStreamSpeed:output_type -> global.SuccessResponse
32, // 123: global.api.SeekStream:output_type -> global.SuccessResponse
39, // 124: global.api.GetSubscribers:output_type -> global.SubscribersResponse
30, // 125: global.api.AudioTrackSnap:output_type -> global.TrackSnapShotResponse
30, // 126: global.api.VideoTrackSnap:output_type -> global.TrackSnapShotResponse
32, // 127: global.api.ChangeSubscribe:output_type -> global.SuccessResponse
46, // 128: global.api.GetStreamAlias:output_type -> global.StreamAliasListResponse
32, // 129: global.api.SetStreamAlias:output_type -> global.SuccessResponse
32, // 130: global.api.StopPublish:output_type -> global.SuccessResponse
32, // 131: global.api.StopSubscribe:output_type -> global.SuccessResponse
5, // 132: global.api.GetConfigFile:output_type -> global.GetConfigFileResponse
32, // 133: global.api.UpdateConfigFile:output_type -> global.SuccessResponse
6, // 134: global.api.GetConfig:output_type -> global.GetConfigResponse
6, // 135: global.api.GetFormily:output_type -> global.GetConfigResponse
40, // 136: global.api.GetPullProxyList:output_type -> global.PullProxyListResponse
32, // 137: global.api.AddPullProxy:output_type -> global.SuccessResponse
32, // 138: global.api.RemovePullProxy:output_type -> global.SuccessResponse
32, // 139: global.api.UpdatePullProxy:output_type -> global.SuccessResponse
43, // 140: global.api.GetPushProxyList:output_type -> global.PushProxyListResponse
32, // 141: global.api.AddPushProxy:output_type -> global.SuccessResponse
32, // 142: global.api.RemovePushProxy:output_type -> global.SuccessResponse
32, // 143: global.api.UpdatePushProxy:output_type -> global.SuccessResponse
50, // 144: global.api.GetRecording:output_type -> global.RecordingListResponse
55, // 145: global.api.GetTransformList:output_type -> global.TransformListResponse
59, // 146: global.api.GetRecordList:output_type -> global.RecordResponseList
60, // 147: global.api.GetEventRecordList:output_type -> global.EventRecordResponseList
62, // 148: global.api.GetRecordCatalog:output_type -> global.ResponseCatalog
64, // 149: global.api.DeleteRecord:output_type -> global.ResponseDelete
68, // 150: global.api.GetAlarmList:output_type -> global.AlarmListResponse
109, // [109:151] is the sub-list for method output_type
67, // [67:109] is the sub-list for method input_type
67, // [67:67] is the sub-list for extension type_name
67, // [67:67] is the sub-list for extension extendee
0, // [0:67] is the sub-list for field type_name
}
func init() { file_global_proto_init() }
@@ -5556,7 +5903,7 @@ func file_global_proto_init() {
GoPackagePath: reflect.TypeOf(x{}).PkgPath(),
RawDescriptor: unsafe.Slice(unsafe.StringData(file_global_proto_rawDesc), len(file_global_proto_rawDesc)),
NumEnums: 0,
NumMessages: 73,
NumMessages: 76,
NumExtensions: 0,
NumServices: 1,
},

File diff suppressed because it is too large Load Diff

View File

@@ -245,6 +245,11 @@ service api {
body: "*"
};
}
rpc GetAlarmList (AlarmListRequest) returns (AlarmListResponse) {
option (google.api.http) = {
get: "/api/alarm/list"
};
}
}
message DisabledPluginsResponse {
@@ -741,4 +746,37 @@ message ResponseDelete {
message ReqRecordCatalog {
string type = 1;
}
message AlarmInfo {
uint32 id = 1;
string serverInfo = 2;
string streamName = 3;
string streamPath = 4;
string alarmDesc = 5;
int32 alarmType = 6;
bool isSent = 7;
string filePath = 8;
google.protobuf.Timestamp createdAt = 9;
google.protobuf.Timestamp updatedAt = 10;
}
message AlarmListRequest {
int32 pageNum = 1;
int32 pageSize = 2;
string range = 3;
string start = 4;
string end = 5;
int32 alarmType = 6;
string streamPath = 7;
string streamName = 8;
}
message AlarmListResponse {
int32 code = 1;
string message = 2;
int32 total = 3;
int32 pageNum = 4;
int32 pageSize = 5;
repeated AlarmInfo data = 6;
}

View File

@@ -61,6 +61,7 @@ const (
Api_GetEventRecordList_FullMethodName = "/global.api/GetEventRecordList"
Api_GetRecordCatalog_FullMethodName = "/global.api/GetRecordCatalog"
Api_DeleteRecord_FullMethodName = "/global.api/DeleteRecord"
Api_GetAlarmList_FullMethodName = "/global.api/GetAlarmList"
)
// ApiClient is the client API for Api service.
@@ -108,6 +109,7 @@ type ApiClient interface {
GetEventRecordList(ctx context.Context, in *ReqRecordList, opts ...grpc.CallOption) (*EventRecordResponseList, error)
GetRecordCatalog(ctx context.Context, in *ReqRecordCatalog, opts ...grpc.CallOption) (*ResponseCatalog, error)
DeleteRecord(ctx context.Context, in *ReqRecordDelete, opts ...grpc.CallOption) (*ResponseDelete, error)
GetAlarmList(ctx context.Context, in *AlarmListRequest, opts ...grpc.CallOption) (*AlarmListResponse, error)
}
type apiClient struct {
@@ -528,6 +530,16 @@ func (c *apiClient) DeleteRecord(ctx context.Context, in *ReqRecordDelete, opts
return out, nil
}
func (c *apiClient) GetAlarmList(ctx context.Context, in *AlarmListRequest, opts ...grpc.CallOption) (*AlarmListResponse, error) {
cOpts := append([]grpc.CallOption{grpc.StaticMethod()}, opts...)
out := new(AlarmListResponse)
err := c.cc.Invoke(ctx, Api_GetAlarmList_FullMethodName, in, out, cOpts...)
if err != nil {
return nil, err
}
return out, nil
}
// ApiServer is the server API for Api service.
// All implementations must embed UnimplementedApiServer
// for forward compatibility.
@@ -573,6 +585,7 @@ type ApiServer interface {
GetEventRecordList(context.Context, *ReqRecordList) (*EventRecordResponseList, error)
GetRecordCatalog(context.Context, *ReqRecordCatalog) (*ResponseCatalog, error)
DeleteRecord(context.Context, *ReqRecordDelete) (*ResponseDelete, error)
GetAlarmList(context.Context, *AlarmListRequest) (*AlarmListResponse, error)
mustEmbedUnimplementedApiServer()
}
@@ -706,6 +719,9 @@ func (UnimplementedApiServer) GetRecordCatalog(context.Context, *ReqRecordCatalo
func (UnimplementedApiServer) DeleteRecord(context.Context, *ReqRecordDelete) (*ResponseDelete, error) {
return nil, status.Errorf(codes.Unimplemented, "method DeleteRecord not implemented")
}
func (UnimplementedApiServer) GetAlarmList(context.Context, *AlarmListRequest) (*AlarmListResponse, error) {
return nil, status.Errorf(codes.Unimplemented, "method GetAlarmList not implemented")
}
func (UnimplementedApiServer) mustEmbedUnimplementedApiServer() {}
func (UnimplementedApiServer) testEmbeddedByValue() {}
@@ -1465,6 +1481,24 @@ func _Api_DeleteRecord_Handler(srv interface{}, ctx context.Context, dec func(in
return interceptor(ctx, in, info, handler)
}
func _Api_GetAlarmList_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) {
in := new(AlarmListRequest)
if err := dec(in); err != nil {
return nil, err
}
if interceptor == nil {
return srv.(ApiServer).GetAlarmList(ctx, in)
}
info := &grpc.UnaryServerInfo{
Server: srv,
FullMethod: Api_GetAlarmList_FullMethodName,
}
handler := func(ctx context.Context, req interface{}) (interface{}, error) {
return srv.(ApiServer).GetAlarmList(ctx, req.(*AlarmListRequest))
}
return interceptor(ctx, in, info, handler)
}
// Api_ServiceDesc is the grpc.ServiceDesc for Api service.
// It's only intended for direct use with grpc.RegisterService,
// and not to be introspected or modified (even as a copy)
@@ -1636,6 +1670,10 @@ var Api_ServiceDesc = grpc.ServiceDesc{
MethodName: "DeleteRecord",
Handler: _Api_DeleteRecord_Handler,
},
{
MethodName: "GetAlarmList",
Handler: _Api_GetAlarmList_Handler,
},
},
Streams: []grpc.StreamDesc{},
Metadata: "global.proto",

View File

@@ -44,6 +44,15 @@ const (
AlarmPullRecover = 0x10013 // 拉流恢复
AlarmDiskSpaceFull = 0x10014 // 磁盘空间满,磁盘占有率,超出最大磁盘空间使用率,触发报警。
AlarmStartupRunning = 0x10015 // 启动运行
AlarmPublishOffline = 0x10016 // 发布者异常,触发一次报警。
AlarmPublishRecover = 0x10017 // 发布者恢复
AlarmSubscribeOffline = 0x10018 // 订阅者异常,触发一次报警。
AlarmSubscribeRecover = 0x10019 // 订阅者恢复
AlarmPushOffline = 0x10020 // 推流异常,触发一次报警。
AlarmPushRecover = 0x10021 // 推流恢复
AlarmTransformOffline = 0x10022 // 转换异常,触发一次报警。
AlarmTransformRecover = 0x10023 // 转换恢复
AlarmKeepAliveOnline = 0x10024 // 保活正常,触发一次报警。
)
type (

136
plugin.go
View File

@@ -7,6 +7,7 @@ import (
"encoding/hex"
"encoding/json"
"fmt"
"gopkg.in/yaml.v3"
"net"
"net/http"
"net/url"
@@ -25,7 +26,6 @@ import (
gatewayRuntime "github.com/grpc-ecosystem/grpc-gateway/v2/runtime"
myip "github.com/husanpao/ip"
"google.golang.org/grpc"
"gopkg.in/yaml.v3"
"gorm.io/gorm"
. "m7s.live/v5/pkg"
@@ -395,16 +395,8 @@ func (t *WebHookTask) Start() error {
return task.ErrTaskComplete
}
// 将t.data转换为AlarmInfo格式的JSON
var alarmInfo AlarmInfo
// 处理AlarmInfo数据
if t.data != nil {
// 先转成JSON再转成AlarmInfo结构体
jsonData, err := json.Marshal(t.data)
if err != nil {
return fmt.Errorf("marshal data to json: %w", err)
}
// 获取主机名和IP地址
hostname, err := os.Hostname()
if err != nil {
@@ -428,26 +420,32 @@ func (t *WebHookTask) Start() error {
ipAddr = "unknown"
}
// 将jsonData反序列化为map添加ServerInfo字段然后重新序列化
var dataMap map[string]interface{}
if err := json.Unmarshal(jsonData, &dataMap); err == nil {
dataMap["server_info"] = fmt.Sprintf("%s (%s)", hostname, ipAddr)
// 添加ISO格式的createAt字段
dataMap["createAt"] = time.Now().UTC().Format(time.RFC3339)
if newJsonData, err := json.Marshal(dataMap); err == nil {
jsonData = newJsonData
}
// 直接使用t.data作为AlarmInfo
alarmInfo, ok := t.data.(AlarmInfo)
if !ok {
return fmt.Errorf("data is not of type AlarmInfo")
}
// 更新服务器信息
if alarmInfo.ServerInfo == "" {
alarmInfo.ServerInfo = fmt.Sprintf("%s (%s)", hostname, ipAddr)
}
// 确保时间戳已设置
if alarmInfo.CreatedAt.IsZero() {
alarmInfo.CreatedAt = time.Now()
}
if alarmInfo.UpdatedAt.IsZero() {
alarmInfo.UpdatedAt = time.Now()
}
// 将AlarmInfo序列化为JSON
jsonData, err := json.Marshal(alarmInfo)
if err != nil {
return fmt.Errorf("marshal AlarmInfo to json: %w", err)
}
t.jsonData = jsonData
err = json.Unmarshal(jsonData, &alarmInfo)
if err != nil {
return fmt.Errorf("unmarshal json to AlarmInfo: %w", err)
}
alarmInfo.CreatedAt = time.Now()
alarmInfo.UpdatedAt = time.Now()
t.alarm = alarmInfo
}
@@ -635,27 +633,22 @@ func (p *Plugin) PublishWithConfig(ctx context.Context, streamPath string, conf
if err == nil {
if sender, webhook := p.getHookSender(config.HookOnPublishEnd); sender != nil {
publisher.OnDispose(func() {
webhookData := map[string]interface{}{
"alarmType": config.AlarmPullOffline,
"streamPath": publisher.StreamPath,
"publishId": publisher.ID,
"alarmDesc": publisher.StopReason().Error(),
alarmInfo := AlarmInfo{
AlarmName: string(config.HookOnPublishEnd),
AlarmDesc: publisher.StopReason().Error(),
AlarmType: config.AlarmPublishOffline,
StreamPath: publisher.StreamPath,
}
sender(webhook, webhookData)
sender(webhook, alarmInfo)
})
}
if sender, webhook := p.getHookSender(config.HookOnPublishStart); sender != nil {
webhookData := map[string]interface{}{
"alarmType": config.AlarmPullRecover,
"alarmDesc": config.HookOnPublishStart,
"streamPath": publisher.StreamPath,
"args": publisher.Args,
"publishId": publisher.ID,
"remoteAddr": publisher.RemoteAddr,
"type": publisher.Type,
"pluginName": p.Meta.Name,
alarmInfo := AlarmInfo{
AlarmName: string(config.HookOnPublishStart),
AlarmType: config.AlarmPublishRecover,
StreamPath: publisher.StreamPath,
}
sender(webhook, webhookData)
sender(webhook, alarmInfo)
}
}
return
@@ -698,31 +691,22 @@ func (p *Plugin) SubscribeWithConfig(ctx context.Context, streamPath string, con
if err == nil {
if sender, webhook := p.getHookSender(config.HookOnSubscribeEnd); sender != nil {
subscriber.OnDispose(func() {
webhookData := map[string]interface{}{
"event": config.HookOnSubscribeEnd,
"streamPath": subscriber.StreamPath,
"subscriberId": subscriber.ID,
"reason": subscriber.StopReason().Error(),
"timestamp": time.Now().Unix(),
alarmInfo := AlarmInfo{
AlarmName: string(config.HookOnSubscribeEnd),
AlarmDesc: subscriber.StopReason().Error(),
AlarmType: config.AlarmSubscribeOffline,
StreamPath: subscriber.StreamPath,
}
if subscriber.Publisher != nil {
webhookData["publishId"] = subscriber.Publisher.ID
}
sender(webhook, webhookData)
sender(webhook, alarmInfo)
})
}
if sender, webhook := p.getHookSender(config.HookOnSubscribeStart); sender != nil {
webhookData := map[string]interface{}{
"event": config.HookOnSubscribeStart,
"streamPath": subscriber.StreamPath,
"publishId": subscriber.Publisher.ID,
"subscriberId": subscriber.ID,
"remoteAddr": subscriber.RemoteAddr,
"type": subscriber.Type,
"args": subscriber.Args,
"timestamp": time.Now().Unix(),
alarmInfo := AlarmInfo{
AlarmName: string(config.HookOnSubscribeStart),
AlarmType: config.AlarmSubscribeRecover,
StreamPath: subscriber.StreamPath,
}
sender(webhook, webhookData)
sender(webhook, alarmInfo)
}
}
return
@@ -870,15 +854,21 @@ func (t *ServerKeepAliveTask) Tick(now any) {
if sender == nil {
return
}
s := t.plugin.Server
webhookData := map[string]interface{}{
"event": config.HookOnServerKeepAlive,
"timestamp": time.Now().Unix(),
"streams": s.Streams.Length,
"subscribers": s.Subscribers.Length,
"publisherCount": s.Streams.Length,
"subscriberCount": s.Subscribers.Length,
"uptime": time.Since(s.StartTime).Seconds(),
//s := t.plugin.Server
alarmInfo := AlarmInfo{
AlarmName: string(config.HookOnServerKeepAlive),
AlarmType: config.AlarmKeepAliveOnline,
StreamPath: "",
}
sender(webhook, webhookData)
sender(webhook, alarmInfo)
//webhookData := map[string]interface{}{
// "event": config.HookOnServerKeepAlive,
// "timestamp": time.Now().Unix(),
// "streams": s.Streams.Length,
// "subscribers": s.Subscribers.Length,
// "publisherCount": s.Streams.Length,
// "subscriberCount": s.Subscribers.Length,
// "uptime": time.Since(s.StartTime).Seconds(),
//}
//sender(webhook, webhookData)
}

View File

@@ -123,31 +123,24 @@ func (p *PullJob) Init(puller IPuller, plugin *Plugin, streamPath string, conf c
if sender, webhook := plugin.getHookSender(config.HookOnPullStart); sender != nil {
puller.OnStart(func() {
webhookData := map[string]interface{}{
"alarmDesc": config.HookOnPullStart,
"event": config.HookOnPullStart,
"streamPath": streamPath,
"url": conf.URL,
"args": conf.Args,
"pluginName": plugin.Meta.Name,
"timestamp": time.Now().Unix(),
"alarmType": config.AlarmPullRecover,
alarmInfo := AlarmInfo{
AlarmName: string(config.HookOnPullStart),
StreamPath: streamPath,
AlarmType: config.AlarmPullRecover,
}
sender(webhook, webhookData)
sender(webhook, alarmInfo)
})
}
if sender, webhook := plugin.getHookSender(config.HookOnPullEnd); sender != nil {
puller.OnDispose(func() {
webhookData := map[string]interface{}{
"alarmDesc": puller.StopReason().Error(),
"event": config.HookOnPullEnd,
"streamPath": streamPath,
"reason": puller.StopReason().Error(),
"timestamp": time.Now().Unix(),
"alarmType": config.AlarmPullOffline,
alarmInfo := AlarmInfo{
AlarmName: string(config.HookOnPullEnd),
AlarmDesc: puller.StopReason().Error(),
StreamPath: streamPath,
AlarmType: config.AlarmPullOffline,
}
sender(webhook, webhookData)
sender(webhook, alarmInfo)
})
}

View File

@@ -1,8 +1,6 @@
package m7s
import (
"time"
"m7s.live/v5/pkg"
"m7s.live/v5/pkg/task"
@@ -45,26 +43,25 @@ func (p *PushJob) Init(pusher IPusher, plugin *Plugin, streamPath string, conf c
pusher.SetRetry(conf.MaxRetry, conf.RetryInterval)
if sender, webhook := plugin.getHookSender(config.HookOnPushStart); sender != nil {
pusher.OnStart(func() {
webhookData := map[string]interface{}{
"event": config.HookOnPushStart,
"streamPath": streamPath,
"url": conf.URL,
"pluginName": plugin.Meta.Name,
"timestamp": time.Now().Unix(),
alarmInfo := AlarmInfo{
AlarmName: string(config.HookOnPushStart),
AlarmDesc: "start push",
AlarmType: config.AlarmPushRecover,
StreamPath: streamPath,
}
sender(webhook, webhookData)
sender(webhook, alarmInfo)
})
}
if sender, webhook := plugin.getHookSender(config.HookOnPushEnd); sender != nil {
pusher.OnDispose(func() {
webhookData := map[string]interface{}{
"event": config.HookOnPullEnd,
"streamPath": streamPath,
"reason": pusher.StopReason().Error(),
"timestamp": time.Now().Unix(),
alarmInfo := AlarmInfo{
AlarmName: string(config.HookOnPushEnd),
AlarmDesc: pusher.StopReason().Error(),
AlarmType: config.AlarmPushOffline,
StreamPath: streamPath,
}
sender(webhook, webhookData)
sender(webhook, alarmInfo)
})
}
plugin.Server.Pushs.Add(p, plugin.Logger.With("pushURL", conf.URL, "streamPath", streamPath))

View File

@@ -142,27 +142,26 @@ func (p *RecordJob) Init(recorder IRecorder, plugin *Plugin, streamPath string,
recorder.SetRetry(-1, time.Second)
if sender, webhook := plugin.getHookSender(config.HookOnRecordStart); sender != nil {
recorder.OnStart(func() {
webhookData := map[string]interface{}{
"event": config.HookOnRecordStart,
"streamPath": streamPath,
"filePath": conf.FilePath,
"pluginName": plugin.Meta.Name,
"timestamp": time.Now().Unix(),
alarmInfo := AlarmInfo{
AlarmName: string(config.HookOnRecordStart),
AlarmType: config.AlarmStorageExceptionRecover,
StreamPath: streamPath,
FilePath: conf.FilePath,
}
sender(webhook, webhookData)
sender(webhook, alarmInfo)
})
}
if sender, webhook := plugin.getHookSender(config.HookOnRecordEnd); sender != nil {
recorder.OnDispose(func() {
webhookData := map[string]interface{}{
"event": config.HookOnRecordEnd,
"streamPath": streamPath,
"filePath": conf.FilePath,
"reason": recorder.StopReason().Error(),
"timestamp": time.Now().Unix(),
alarmInfo := AlarmInfo{
AlarmType: config.AlarmStorageException,
AlarmDesc: recorder.StopReason().Error(),
AlarmName: string(config.HookOnRecordEnd),
StreamPath: streamPath,
FilePath: conf.FilePath,
}
sender(webhook, webhookData)
sender(webhook, alarmInfo)
})
}

View File

@@ -439,12 +439,11 @@ func (s *Server) Start() (err error) {
return nil
}, "serverStart")
if sender, webhook := s.getHookSender(config.HookOnSystemStart); sender != nil {
webhookData := map[string]interface{}{
"alarmDesc": config.HookOnSystemStart,
"streamPath": "",
"alarmType": config.AlarmStartupRunning,
alarmInfo := AlarmInfo{
AlarmName: string(config.HookOnSystemStart),
AlarmType: config.AlarmStartupRunning,
}
sender(webhook, webhookData)
sender(webhook, alarmInfo)
}
return
}

View File

@@ -107,24 +107,23 @@ func (p *TransformJob) Init(transformer ITransformer, plugin *Plugin, pub *Publi
transformer.SetRetry(-1, time.Second*2)
if sender, webhook := plugin.getHookSender(config.HookOnTransformStart); sender != nil {
transformer.OnStart(func() {
webhookData := map[string]interface{}{
"event": config.HookOnTransformStart,
"streamPath": pub.StreamPath,
"pluginName": plugin.Meta.Name,
"timestamp": time.Now().Unix(),
alarmInfo := AlarmInfo{
AlarmName: string(config.HookOnTransformStart),
AlarmType: config.AlarmTransformRecover,
StreamPath: pub.StreamPath,
}
sender(webhook, webhookData)
sender(webhook, alarmInfo)
})
}
if sender, webhook := plugin.getHookSender(config.HookOnTransformEnd); sender != nil {
transformer.OnDispose(func() {
webhookData := map[string]interface{}{
"event": config.HookOnTransformEnd,
"streamPath": pub.StreamPath,
"reason": transformer.StopReason().Error(),
"timestamp": time.Now().Unix(),
alarmInfo := AlarmInfo{
AlarmName: string(config.HookOnTransformEnd),
AlarmType: config.AlarmTransformOffline,
StreamPath: pub.StreamPath,
AlarmDesc: transformer.StopReason().Error(),
}
sender(webhook, webhookData)
sender(webhook, alarmInfo)
})
}
plugin.Server.Transforms.AddTask(p, plugin.Logger.With("streamPath", pub.StreamPath))