代码拉取完成,页面将自动刷新
// Package monitor
// @Link https://gitee.com/linngc/central-mirror
// @Copyright Copyright (c) 2024 central-mirror CLI
// @Author linngc
// @License
package monitor
import (
"github.com/shirou/gopsutil/cpu"
"github.com/shirou/gopsutil/disk"
gopsutilnet "github.com/shirou/gopsutil/net"
"github.com/shirou/gopsutil/process"
"net"
"time"
)
// MonitorOutput 服务监控信息
type MonitorOutput struct {
GoVersionOutput *GoVersionOutput `json:"goVersion" dc:"当前服务器go版本信息"` //当前服务器go版本信息
VersionOutput *VersionOutput `json:"version" dc:"当前程序版本信息"` //当前程序版本信息
ServerInfoOutput *ServerOutput `json:"serverInfo" dc:"当前服务器信息"` //当前服务器信息
DisksList []*disk.UsageStat `json:"disksList" dc:"当前磁盘状态"` //当前磁盘状态
}
// VersionOutput 当前程序版本信息
type VersionOutput struct {
Pid int `json:"pid" dc:"项目启动进程号"` //项目启动进程号
StartTime time.Time `json:"startTime" dc:"程序启动时间"` //程序启动时间
Os string `json:"os" dc:"系统版本(Win或Linux)"` //系统版本(Win或Linux)
Arch string `json:"arch" dc:"系统类型(X64或X32)"` //系统类型(X64或X32)
BuildVer string `json:"buildVer" dc:"编译版本"` //编译版本
}
// GoVersionOutput 当前服务器go版本信息
type GoVersionOutput struct {
GoVersion string `json:"goVersion" dc:"Go框架版本"` //Go框架版本
GoHome string `json:"goHome" dc:"安装路径"` //安装路径
GoRunTime int64 `json:"goRunTime" dc:"运行时长"` //运行时长(nano)
}
// ProcessOutput 当前服务器进程状态
type ProcessOutput struct {
Percent float64 `json:"percent" dc:"返回进程的cpu使用率"` //返回进程的cpu使用率
CpuPercent float64 `json:"cpuPercent" dc:"CPU使用率"` //CPU使用率
Status string `json:"status" dc:"返回进程状态"` //返回进程状态
Connections []gopsutilnet.ConnectionStat `json:"connections" dc:"返回进程连接"` //返回进程连接
Times *cpu.TimesStat `json:"times" dc:"返回进程的timeStat信息"` //返回进程的timeStat信息
Name string `json:"name" dc:"进程名称"` //进程名称
CreateTime int64 `json:"createTime" dc:"进程创建时间"` //进程创建时间
Children []*process.Process `json:"children" dc:"获取进程的子进程"` //获取进程的子进程
Cmdline string `json:"cmdline" dc:"获取进程的命令行"` //获取进程的命令行
}
// ServerOutput 当前服务器信息
type ServerOutput struct {
MemAll uint64 `json:"memAll" dc:"所有内存(MB)"` // 所有内存
MemFree uint64 `json:"memFree" dc:"可用内存(MB)"` // 可用内存
MemUsed uint64 `json:"memUsed" dc:"使用内存(MB)"` // 使用内存
MemUsedPercent float64 `json:"memUsedPercent" dc:"内存使用占比(%)"` // 内存使用占比
Minutes int64 `json:"minutes" dc:"开机时间(min分钟)"` // 开机时间(分钟)
CpuUsedPercent float64 `json:"cpuUsedPercent" dc:" CPU使用占比(%,200ms内信息)"` // CPU使用占比
Os string `json:"os" dc:"系统版本(Win或Linux)"` // 系统版本(Win或Linux)
Arch string `json:"arch" dc:"系统类型(X64或X32)"` // 系统类型(X64或X32)
CpuCores int `json:"cpuCores" dc:"CPU内核数"` // CPU内核数
SysTime time.Time `json:"sysTime" dc:"当前系统时间"` // 当前系统时间
Interface []net.Interface `json:"interfaces" dc:"网卡信息"` //网卡信息
}
type VerifyOutput struct {
Uri string `json:"uri" dc:"服务配置uri"` //服务配置uri
Network *HttpTime `json:"network" dc:"网络状态"` //网络状态
}
// HttpTime 请求到响应花费的时间
type HttpTime struct {
DnsTime time.Duration `json:"dnsTime" dc:"dns响应时间"`
ConnectTime time.Duration `json:"connectTime" dc:"链接时间"`
ResponseTime time.Duration `json:"responseTime" dc:"请求响应时间"`
TotalTime time.Duration `json:"totalTime" dc:"总耗时"`
}
此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。
如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。