sermoni

"Service monitor" / cronjob status service
Log | Files | Refs

commit ef059e0a3fa10d5d815c1f2617b45d2646b6fd14
parent e1402224e79724f409d6276c9860504448c2b30b
Author: vh <vetle.haflan@gmail.com>
Date:   Wed, 29 Apr 2020 14:08:56 +0200

Server-side timestamps

Using millisecond precision because it's sufficient and can be used directly in JS

Closes #2

Diffstat:
Minternal/http/events.go | 2++
Mreport.sh | 2--
2 files changed, 2 insertions(+), 2 deletions(-)

diff --git a/internal/http/events.go b/internal/http/events.go @@ -9,6 +9,7 @@ import ( "sermoni/internal/events" "sermoni/internal/services" "strconv" + "time" "github.com/gorilla/mux" ) @@ -69,6 +70,7 @@ func reportEvent(w http.ResponseWriter, r *http.Request) { err = json.Unmarshal(content, event) check(err) event.Service = service.ID + event.Timestamp = uint64(time.Now().UnixNano() / 1e6) err = events.Add(event) check(err) log.Printf("New event registered, id = %v\n", event.ID) diff --git a/report.sh b/report.sh @@ -8,12 +8,10 @@ token=$1 status=$2 title=$3 details=$4 -timestamp="$(date +%s)" read -d '' JSONDATA << EOF { \"status\": \"$status\", - \"timestamp\": $timestamp, \"title\": \"$title\", \"details\": \"$details\" }