mirror of
https://git.vectorsigma.ru/public/CasaOS.git
synced 2026-08-04 03:27:49 +00:00
add system notiry
This commit is contained in:
@@ -38,14 +38,21 @@ type NotifyServer interface {
|
||||
SendAllHardwareStatusBySocket(disk model2.Summary, list []model2.DriveUSB, mem map[string]interface{}, cpu map[string]interface{}, netList []model2.IOCountersStat)
|
||||
SendStorageBySocket(message notify.StorageMessage)
|
||||
SendNotify(path string, message map[string]interface{})
|
||||
SettingSystemTempData(message map[string]interface{})
|
||||
}
|
||||
|
||||
type notifyServer struct {
|
||||
db *gorm.DB
|
||||
db *gorm.DB
|
||||
SystemTempMap map[string]interface{}
|
||||
}
|
||||
|
||||
func (i *notifyServer) SettingSystemTempData(message map[string]interface{}) {
|
||||
for k, v := range message {
|
||||
i.SystemTempMap[k] = v
|
||||
}
|
||||
}
|
||||
|
||||
func (i *notifyServer) SendNotify(path string, message map[string]interface{}) {
|
||||
|
||||
msg := gosf.Message{}
|
||||
msg.Body = message
|
||||
msg.Success = true
|
||||
@@ -77,9 +84,6 @@ func (i *notifyServer) SendStorageBySocket(message notify.StorageMessage) {
|
||||
func (i *notifyServer) SendAllHardwareStatusBySocket(disk model2.Summary, list []model2.DriveUSB, mem map[string]interface{}, cpu map[string]interface{}, netList []model2.IOCountersStat) {
|
||||
|
||||
body := make(map[string]interface{})
|
||||
body["sys_disk"] = disk
|
||||
|
||||
body["sys_usb"] = list
|
||||
|
||||
body["sys_mem"] = mem
|
||||
|
||||
@@ -87,6 +91,10 @@ func (i *notifyServer) SendAllHardwareStatusBySocket(disk model2.Summary, list [
|
||||
|
||||
body["sys_net"] = netList
|
||||
|
||||
for k, v := range i.SystemTempMap {
|
||||
body[k] = v
|
||||
}
|
||||
|
||||
msg := gosf.Message{}
|
||||
msg.Body = body
|
||||
msg.Success = true
|
||||
@@ -470,5 +478,5 @@ func SendMeg() {
|
||||
// }
|
||||
|
||||
func NewNotifyService(db *gorm.DB) NotifyServer {
|
||||
return ¬ifyServer{db: db}
|
||||
return ¬ifyServer{db: db, SystemTempMap: make(map[string]interface{})}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user