1.增加事件录像,事件录像列表接口

2.将下载时间范围内的录像及播放时间范围内的录像参数统一为start和end
3.增加事件录像入数据库功能
This commit is contained in:
pg
2024-08-18 23:28:42 +08:00
parent 699868b602
commit deb8cfedae
8 changed files with 482 additions and 15 deletions

44
exception.go Normal file
View File

@@ -0,0 +1,44 @@
package record
import (
"bytes"
"encoding/json"
"fmt"
"github.com/shirou/gopsutil/v3/disk"
"net/http"
"time"
)
// 向第三方发送异常报警
func SendToThirdPartyAPI(exception *Exception) {
exception.Timestamp = time.Now().Format("20060102150405")
exception.ServerIP = RecordPluginConfig.LocalIp
data, err := json.Marshal(exception)
if err != nil {
fmt.Println("Error marshalling exception:", err)
return
}
resp, err := http.Post(RecordPluginConfig.ExceptionPostUrl, "application/json", bytes.NewBuffer(data))
if err != nil {
fmt.Println("Error sending exception to third party API:", err)
return
}
defer resp.Body.Close()
if resp.StatusCode != http.StatusOK {
fmt.Println("Failed to send exception, status code:", resp.StatusCode)
} else {
fmt.Println("Exception sent successfully!")
}
}
// 磁盘超上限报警
func getDisckException(streamPath string) bool {
d, _ := disk.Usage("/")
if d.UsedPercent >= RecordPluginConfig.DiskMaxPercent {
exceptionChannel <- &Exception{AlarmType: "disk alarm", AlarmDesc: "disk is full", Channel: streamPath}
return true
}
return false
}