// Collect populates Uptimestat by reading /proc/uptime func (s *UptimeStat) Collect() { file, err := os.Open(root + "proc/uptime") if err != nil { return } scanner := bufio.NewScanner(file) for scanner.Scan() { f := strings.Split(scanner.Text(), " ") if len(f) == 2 { s.Uptime.Set(misc.ParseFloat(f[0])) s.Idle.Set(misc.ParseFloat(f[1])) } break } }
// Collect populates Loadstat by reading /proc/loadavg func (s *LoadStat) Collect() { file, err := os.Open(root + "proc/loadavg") if err != nil { return } scanner := bufio.NewScanner(file) for scanner.Scan() { f := strings.Split(scanner.Text(), " ") if len(f) > 2 { s.OneMinute.Set(misc.ParseFloat(f[0])) s.FiveMinute.Set(misc.ParseFloat(f[1])) s.FifteenMinute.Set(misc.ParseFloat(f[2])) } break } }