diff --git a/stats/cpu.go b/stats/cpu.go index b8d796f..790093e 100644 --- a/stats/cpu.go +++ b/stats/cpu.go @@ -21,20 +21,22 @@ type StatCPU struct { } // Get CPU stats -func CPU() (*StatCPU, error) { +func CPU() (StatCPU, error) { pid := os.Getpid() - sysInfo, err := pidusage.GetStat(pid) - if err != nil { - return nil, err - } - stat := StatCPU{ - Usage: fmt.Sprint(math.Round(sysInfo.CPU*100)/100, "%"), Num: runtime.NumCPU(), Arch: runtime.GOARCH, pid: pid, } - return &stat, nil + sysInfo, err := pidusage.GetStat(pid) + if err != nil { + stat.Usage = "error" + return stat, err + } + + stat.Usage = fmt.Sprint(math.Round(sysInfo.CPU*100)/100, "%") + + return stat, nil } diff --git a/updater/autoupdate.go b/updater/autoupdate.go index b42d2bc..57598e6 100644 --- a/updater/autoupdate.go +++ b/updater/autoupdate.go @@ -1,6 +1,10 @@ package updater -import "time" +import ( + "time" + + "github.com/MedzikUser/go-utils/common" +) /* Auto checks for available updates @@ -9,7 +13,8 @@ import "time" */ func (c *Client) AutoUpdater() { // Check on start - c.Update() + err := c.Update() + common.CheckErr(err, "AutoUpdater") ticker := time.NewTicker(c.CheckEvery) @@ -18,7 +23,8 @@ func (c *Client) AutoUpdater() { for { select { case <-ticker.C: - c.Update() + err := c.Update() + common.CheckErr(err, "AutoUpdater") case <-quit: ticker.Stop()