diff --git a/gala-ops/server/httphandler/component.go b/gala-ops/server/httphandler/component.go index 901f1f80063eeab1baa9948182cc17c933e4eb2b..504c0441dc4d03bffbed65b511e6aef1fce808b1 100644 --- a/gala-ops/server/httphandler/component.go +++ b/gala-ops/server/httphandler/component.go @@ -1,6 +1,10 @@ package httphandler -import "gitee.com/openeuler/PilotGo-plugins/sdk/plugin/client" +import ( + "time" + + "gitee.com/openeuler/PilotGo-plugins/sdk/plugin/client" +) type Opsclient struct { Sdkmethod *client.Client @@ -8,3 +12,13 @@ type Opsclient struct { } var Galaops *Opsclient + +func (o *Opsclient) UnixTimeStartandEnd(timerange time.Duration) (int64, int64) { + now := time.Now() + past5Minutes := now.Add(timerange * time.Minute) + startOfPast5Minutes := time.Date(past5Minutes.Year(), past5Minutes.Month(), past5Minutes.Day(), + past5Minutes.Hour(), past5Minutes.Minute(), 0, 0, past5Minutes.Location()) + timestamp := startOfPast5Minutes.Unix() + return timestamp, now.Unix() +} +