Merge pull request #211 from AkkiaS7/feat-api
update: 服务器状态API增加上次汇报时间的unix时间戳 Co-authored-by: AkkiaS7 <68485070+AkkiaS7@users.noreply.github.com>
This commit is contained in:
		
						commit
						4d5a6cda29
					
				@ -4,7 +4,7 @@
 | 
				
			|||||||
  <br>
 | 
					  <br>
 | 
				
			||||||
  <small><i>LOGO designed by <a href="https://xio.ng" target="_blank">熊大</a> .</i></small>
 | 
					  <small><i>LOGO designed by <a href="https://xio.ng" target="_blank">熊大</a> .</i></small>
 | 
				
			||||||
  <br><br>
 | 
					  <br><br>
 | 
				
			||||||
<img src="https://img.shields.io/github/workflow/status/naiba/nezha/Dashboard%20image?label=Dash%20v0.13.17&logo=github&style=for-the-badge"> <img src="https://img.shields.io/github/v/release/naiba/nezha?color=brightgreen&label=Agent&style=for-the-badge&logo=github"> <img src="https://img.shields.io/github/workflow/status/naiba/nezha/Agent%20release?label=Agent%20CI&logo=github&style=for-the-badge"> <img src="https://img.shields.io/badge/Installer-v0.10.2-brightgreen?style=for-the-badge&logo=linux">
 | 
					<img src="https://img.shields.io/github/workflow/status/naiba/nezha/Dashboard%20image?label=Dash%20v0.13.18&logo=github&style=for-the-badge"> <img src="https://img.shields.io/github/v/release/naiba/nezha?color=brightgreen&label=Agent&style=for-the-badge&logo=github"> <img src="https://img.shields.io/github/workflow/status/naiba/nezha/Agent%20release?label=Agent%20CI&logo=github&style=for-the-badge"> <img src="https://img.shields.io/badge/Installer-v0.10.2-brightgreen?style=for-the-badge&logo=linux">
 | 
				
			||||||
  <br>
 | 
					  <br>
 | 
				
			||||||
  <br>
 | 
					  <br>
 | 
				
			||||||
  <p>:trollface: <b>Nezha Monitoring</b> self-hosted lightweight monitoring and operation system. Supports system status, HTTP (SSL certificate change, upcoming expiration, expiration), TCP, Ping <b>monitoring</b> and <b>alerting</b>, execute scheduled tasks and <b>web terminal</b>.</p>
 | 
					  <p>:trollface: <b>Nezha Monitoring</b> self-hosted lightweight monitoring and operation system. Supports system status, HTTP (SSL certificate change, upcoming expiration, expiration), TCP, Ping <b>monitoring</b> and <b>alerting</b>, execute scheduled tasks and <b>web terminal</b>.</p>
 | 
				
			||||||
 | 
				
			|||||||
@ -23,12 +23,13 @@ type CommonResponse struct {
 | 
				
			|||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
type CommonServerInfo struct {
 | 
					type CommonServerInfo struct {
 | 
				
			||||||
	ID      uint64 `json:"id"`
 | 
						ID         uint64 `json:"id"`
 | 
				
			||||||
	Name    string `json:"name"`
 | 
						Name       string `json:"name"`
 | 
				
			||||||
	Tag     string `json:"tag"`
 | 
						Tag        string `json:"tag"`
 | 
				
			||||||
	IPV4    string `json:"ipv4"`
 | 
						LastActive int64  `json:"last_active"`
 | 
				
			||||||
	IPV6    string `json:"ipv6"`
 | 
						IPV4       string `json:"ipv4"`
 | 
				
			||||||
	ValidIP string `json:"valid_ip"`
 | 
						IPV6       string `json:"ipv6"`
 | 
				
			||||||
 | 
						ValidIP    string `json:"valid_ip"`
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
// StatusResponse 服务器状态子结构 包含服务器信息与状态信息
 | 
					// StatusResponse 服务器状态子结构 包含服务器信息与状态信息
 | 
				
			||||||
@ -80,12 +81,13 @@ func (s *ServerAPIService) GetStatusByIDList(idList []uint64) *ServerStatusRespo
 | 
				
			|||||||
		}
 | 
							}
 | 
				
			||||||
		ipv4, ipv6, validIP := utils.SplitIPAddr(server.Host.IP)
 | 
							ipv4, ipv6, validIP := utils.SplitIPAddr(server.Host.IP)
 | 
				
			||||||
		info := CommonServerInfo{
 | 
							info := CommonServerInfo{
 | 
				
			||||||
			ID:      server.ID,
 | 
								ID:         server.ID,
 | 
				
			||||||
			Name:    server.Name,
 | 
								Name:       server.Name,
 | 
				
			||||||
			Tag:     server.Tag,
 | 
								Tag:        server.Tag,
 | 
				
			||||||
			IPV4:    ipv4,
 | 
								LastActive: server.LastActive.Unix(),
 | 
				
			||||||
			IPV6:    ipv6,
 | 
								IPV4:       ipv4,
 | 
				
			||||||
			ValidIP: validIP,
 | 
								IPV6:       ipv6,
 | 
				
			||||||
 | 
								ValidIP:    validIP,
 | 
				
			||||||
		}
 | 
							}
 | 
				
			||||||
		res.Result = append(res.Result, &StatusResponse{
 | 
							res.Result = append(res.Result, &StatusResponse{
 | 
				
			||||||
			CommonServerInfo: info,
 | 
								CommonServerInfo: info,
 | 
				
			||||||
@ -119,12 +121,13 @@ func (s *ServerAPIService) GetAllStatus() *ServerStatusResponse {
 | 
				
			|||||||
		}
 | 
							}
 | 
				
			||||||
		ipv4, ipv6, validIP := utils.SplitIPAddr(host.IP)
 | 
							ipv4, ipv6, validIP := utils.SplitIPAddr(host.IP)
 | 
				
			||||||
		info := CommonServerInfo{
 | 
							info := CommonServerInfo{
 | 
				
			||||||
			ID:      v.ID,
 | 
								ID:         v.ID,
 | 
				
			||||||
			Name:    v.Name,
 | 
								Name:       v.Name,
 | 
				
			||||||
			Tag:     v.Tag,
 | 
								Tag:        v.Tag,
 | 
				
			||||||
			IPV4:    ipv4,
 | 
								LastActive: v.LastActive.Unix(),
 | 
				
			||||||
			IPV6:    ipv6,
 | 
								IPV4:       ipv4,
 | 
				
			||||||
			ValidIP: validIP,
 | 
								IPV6:       ipv6,
 | 
				
			||||||
 | 
								ValidIP:    validIP,
 | 
				
			||||||
		}
 | 
							}
 | 
				
			||||||
		res.Result = append(res.Result, &StatusResponse{
 | 
							res.Result = append(res.Result, &StatusResponse{
 | 
				
			||||||
			CommonServerInfo: info,
 | 
								CommonServerInfo: info,
 | 
				
			||||||
@ -153,12 +156,13 @@ func (s *ServerAPIService) GetListByTag(tag string) *ServerInfoResponse {
 | 
				
			|||||||
		}
 | 
							}
 | 
				
			||||||
		ipv4, ipv6, validIP := utils.SplitIPAddr(host.IP)
 | 
							ipv4, ipv6, validIP := utils.SplitIPAddr(host.IP)
 | 
				
			||||||
		info := &CommonServerInfo{
 | 
							info := &CommonServerInfo{
 | 
				
			||||||
			ID:      v,
 | 
								ID:         v,
 | 
				
			||||||
			Name:    ServerList[v].Name,
 | 
								Name:       ServerList[v].Name,
 | 
				
			||||||
			Tag:     ServerList[v].Tag,
 | 
								Tag:        ServerList[v].Tag,
 | 
				
			||||||
			IPV4:    ipv4,
 | 
								LastActive: ServerList[v].LastActive.Unix(),
 | 
				
			||||||
			IPV6:    ipv6,
 | 
								IPV4:       ipv4,
 | 
				
			||||||
			ValidIP: validIP,
 | 
								IPV6:       ipv6,
 | 
				
			||||||
 | 
								ValidIP:    validIP,
 | 
				
			||||||
		}
 | 
							}
 | 
				
			||||||
		res.Result = append(res.Result, info)
 | 
							res.Result = append(res.Result, info)
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
@ -183,12 +187,13 @@ func (s *ServerAPIService) GetAllList() *ServerInfoResponse {
 | 
				
			|||||||
		}
 | 
							}
 | 
				
			||||||
		ipv4, ipv6, validIP := utils.SplitIPAddr(host.IP)
 | 
							ipv4, ipv6, validIP := utils.SplitIPAddr(host.IP)
 | 
				
			||||||
		info := &CommonServerInfo{
 | 
							info := &CommonServerInfo{
 | 
				
			||||||
			ID:      v.ID,
 | 
								ID:         v.ID,
 | 
				
			||||||
			Name:    v.Name,
 | 
								Name:       v.Name,
 | 
				
			||||||
			Tag:     v.Tag,
 | 
								Tag:        v.Tag,
 | 
				
			||||||
			IPV4:    ipv4,
 | 
								LastActive: v.LastActive.Unix(),
 | 
				
			||||||
			IPV6:    ipv6,
 | 
								IPV4:       ipv4,
 | 
				
			||||||
			ValidIP: validIP,
 | 
								IPV6:       ipv6,
 | 
				
			||||||
 | 
								ValidIP:    validIP,
 | 
				
			||||||
		}
 | 
							}
 | 
				
			||||||
		res.Result = append(res.Result, info)
 | 
							res.Result = append(res.Result, info)
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
 | 
				
			|||||||
@ -12,7 +12,7 @@ import (
 | 
				
			|||||||
	"github.com/naiba/nezha/pkg/utils"
 | 
						"github.com/naiba/nezha/pkg/utils"
 | 
				
			||||||
)
 | 
					)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
var Version = "v0.13.17" // !!记得修改 README 中的 badge 版本!!
 | 
					var Version = "v0.13.18" // !!记得修改 README 中的 badge 版本!!
 | 
				
			||||||
 | 
					
 | 
				
			||||||
var (
 | 
					var (
 | 
				
			||||||
	Conf  *model.Config
 | 
						Conf  *model.Config
 | 
				
			||||||
 | 
				
			|||||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user