package stat import ( "io" "bufio" "strings" ) type Uptime struct { } func (upt Uptime) Command() string { return "uptime -s" } func (upt Uptime) Read(r io.Reader) (*map[string]string, error) { var ( scanner = bufio.NewScanner(r) resMap = make(map[string]string) ) for scanner.Scan() { line := scanner.Text() parts := strings.Fields(line) resMap["system.uptime.date"] = parts[0] resMap["system.uptime.time"]= parts[1] } return &resMap, scanner.Err() }