mirror of
https://github.com/PoetryInCode/system-reporting.git
synced 2025-04-19 10:47:14 -04:00
Removed unnecessary crap
This commit is contained in:
parent
93107a39c2
commit
046d49ebdc
@ -4,7 +4,6 @@ import (
|
|||||||
"bytes"
|
"bytes"
|
||||||
"context"
|
"context"
|
||||||
"fmt"
|
"fmt"
|
||||||
"io"
|
|
||||||
"net/http"
|
"net/http"
|
||||||
"os"
|
"os"
|
||||||
"os/signal"
|
"os/signal"
|
||||||
@ -57,21 +56,6 @@ func recordMeasurement() string {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func main() {
|
func main() {
|
||||||
logPath := os.Getenv("LOGFILE")
|
|
||||||
if logPath == "" {
|
|
||||||
logPath = "/var/log/system-reporting.json"
|
|
||||||
}
|
|
||||||
|
|
||||||
logFile, err := os.OpenFile(
|
|
||||||
logPath,
|
|
||||||
os.O_WRONLY|os.O_CREATE|os.O_APPEND,
|
|
||||||
0o644,
|
|
||||||
)
|
|
||||||
if err != nil {
|
|
||||||
log.Fatal("Could't open log file!", "err", err)
|
|
||||||
}
|
|
||||||
defer logFile.Close()
|
|
||||||
|
|
||||||
if ih := os.Getenv("INFLUX_HOST"); ih != "" {
|
if ih := os.Getenv("INFLUX_HOST"); ih != "" {
|
||||||
config.InfluxHost = ih
|
config.InfluxHost = ih
|
||||||
}
|
}
|
||||||
@ -79,17 +63,14 @@ func main() {
|
|||||||
log.Fatal("InfluxHost is unset!")
|
log.Fatal("InfluxHost is unset!")
|
||||||
}
|
}
|
||||||
|
|
||||||
mwriter := io.MultiWriter(os.Stdout, logFile)
|
|
||||||
|
|
||||||
log.SetOutput(mwriter)
|
|
||||||
log.SetFormatter(log.LogfmtFormatter)
|
|
||||||
log.SetLevel(log.InfoLevel)
|
log.SetLevel(log.InfoLevel)
|
||||||
|
|
||||||
if hostname = os.Getenv("DEVICE"); hostname == "" {
|
if hostname = os.Getenv("DEVICE"); hostname == "" {
|
||||||
hostname, err = os.Hostname()
|
h, err := os.Hostname()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.Fatal("Error getting device hostname", "err", err)
|
log.Fatal("Error getting device hostname", "err", err)
|
||||||
}
|
}
|
||||||
|
hostname = h
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -97,7 +78,7 @@ func main() {
|
|||||||
|
|
||||||
reqs := make(chan *http.Request)
|
reqs := make(chan *http.Request)
|
||||||
|
|
||||||
ticker := time.NewTicker(5 * time.Second)
|
ticker := time.NewTicker(60 * time.Second)
|
||||||
go func() { for {
|
go func() { for {
|
||||||
select {
|
select {
|
||||||
case <-ctx.Done():
|
case <-ctx.Done():
|
||||||
|
Loading…
x
Reference in New Issue
Block a user