mirror of
https://github.com/yusing/godoxy.git
synced 2025-05-20 04:42:33 +02:00
fix system info timestamp
This commit is contained in:
parent
16b046bd44
commit
f2de4692ea
1 changed files with 1 additions and 2 deletions
|
@ -15,7 +15,6 @@ import (
|
|||
"github.com/yusing/go-proxy/internal/gperr"
|
||||
"github.com/yusing/go-proxy/internal/logging"
|
||||
"github.com/yusing/go-proxy/internal/metrics/period"
|
||||
"github.com/yusing/go-proxy/internal/utils/strutils"
|
||||
)
|
||||
|
||||
type SystemInfo struct {
|
||||
|
@ -42,6 +41,7 @@ func _() { // check if this behavior is not changed
|
|||
func getSystemInfo(ctx context.Context, lastResult *SystemInfo) (*SystemInfo, error) {
|
||||
errs := gperr.NewBuilder("failed to get system info")
|
||||
var systemInfo SystemInfo
|
||||
systemInfo.Timestamp = time.Now()
|
||||
|
||||
if !common.MetricsDisableCPU {
|
||||
cpuAverage, err := cpu.PercentWithContext(ctx, 150*time.Millisecond, false)
|
||||
|
@ -124,7 +124,6 @@ func getSystemInfo(ctx context.Context, lastResult *SystemInfo) (*SystemInfo, er
|
|||
func (s *SystemInfo) MarshalJSON() ([]byte, error) {
|
||||
return json.Marshal(map[string]any{
|
||||
"timestamp": s.Timestamp.Unix(),
|
||||
"time": strutils.FormatTime(s.Timestamp),
|
||||
"cpu_average": s.CPUAverage,
|
||||
"memory": map[string]any{
|
||||
"total": s.Memory.Total,
|
||||
|
|
Loading…
Add table
Reference in a new issue