package main import ( "bufio" "flag" "fmt" "os" temperature "git.snppla.net/snppla/log_temperature" "git.snppla.net/snppla/log_temperature/array" ) var db *string var username *string var password *string var host *string var locations = array.ArrayFlags{} func main() { db = flag.String("db", "temperature", "Influxdb database") username = flag.String("user", "", "Username") password = flag.String("password", "", "Password") host = flag.String("host", "http://localhost", "Host to connect to") flag.Var(&locations, "location", "Id and location of the sensor (5:conference-room") var reader *bufio.Reader flag.Parse() reader = bufio.NewReader(os.Stdin) parser := temperature.NewJSONParser(reader) writer, err := temperature.NewInfluxWriter(*db, *host, *username, *password, locations) if err != nil { fmt.Println(err.Error()) return } for { measurement, err := parser.Measure() if measurement != nil { writer.Write(*measurement) } if err != nil { fmt.Println(err.Error()) return } } } const ( simpleTestString = ` 2018-04-13 22:57:36 : Acurite 606TX Sensor : -5 Battery: OK Temperature: 21.8 C 2018-04-13 22:58:01 : Acurite 606TX Sensor : 103 Battery: OK Temperature: 24.3 C 2018-04-13 22:58:07 : Acurite 606TX Sensor : -5 Battery: OK Temperature: 21.8 C 2018-04-13 22:58:32 : Acurite 606TX Sensor : 103 Battery: OK Temperature: 24.6 C 2018-04-13 22:58:38 : Acurite 606TX Sensor : -5 Battery: OK Temperature: 21.8 C 2018-04-13 22:59:03 : Acurite 606TX Sensor : 103 Battery: OK Temperature: 24.8 C 2018-04-13 22:59:09 : Acurite 606TX Sensor : -5 Battery: OK Temperature: 21.8 C ` )