Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .dockerignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Dockerfile
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
tags
statusok
vendor
39 changes: 11 additions & 28 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,33 +1,16 @@
# Donot use this Dockerfile.This is not ready yet.

# Start from a Debian image with the latest version of Go installed
# and a workspace (GOPATH) configured at /go.
FROM golang
FROM golang:1.11

# Copy the local package files to the container's workspace.
ADD . /go/src/github.com/sanathp/StatusOk

# Build the outyet command inside the container.
# (You may fetch or manage dependencies here,
# either manually or with a tool like "godep".)
RUN go get github.com/codegangsta/cli
RUN go get github.com/influxdb/influxdb
RUN go get github.com/mailgun/mailgun-go
RUN go install github.com/sanathp/StatusOk

RUN wget http://influxdb.s3.amazonaws.com/influxdb_0.9.3_amd64.deb
RUN dpkg -i influxdb_0.9.3_amd64.deb
RUN /etc/init.d/influxdb start

RUN wget https://grafanarel.s3.amazonaws.com/builds/grafana_2.1.3_amd64.deb
RUN apt-get update
RUN apt-get install -y adduser libfontconfig
RUN dpkg -i grafana_2.1.3_amd64.deb
RUN service grafana-server start
ADD . /go/src/github.com/sanathp/statusok
WORKDIR /go/src/github.com/sanathp/statusok
RUN CGO_ENABLED=0 GOOS=linux go build -a -installsuffix cgo -o statusok .

#how to connect to localhost inside ?? http://stackoverflow.com/questions/24319662/from-inside-of-a-docker-container-how-do-i-connect-to-the-localhost-of-the-mach
# Production image
FROM alpine:3.6

ENTRYPOINT /go/bin/StatusOk --config /go/src/github.com/sanathp/StatusOk/config.json
RUN apk add --no-cache tzdata ca-certificates gettext
COPY --from=0 /go/src/github.com/sanathp/statusok/statusok /statusok
COPY --from=0 /go/src/github.com/sanathp/statusok/config.template /config.template
COPY --from=0 /go/src/github.com/sanathp/statusok/docker-entrypoint.sh /docker-entrypoint.sh

# Document that the service listens
EXPOSE 80 8083 8086 7321 3000
ENTRYPOINT /docker-entrypoint.sh
26 changes: 26 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,32 @@

Monitor your Website and APIs from your computer.Get notified through Slack or E-mail when your server is down or response time is more than expected.

## Building and running

You can build or run this project via docker or locally. If running Go 1.11 or later, you can vendor the project via:

```
GO111MODULE=on go mod vendor
```

And then build:

```
go build
```

Alternatively, you can build a docker container:

```
docker build -t sanathp/statusok
```

This relies on the config being passed through as an environment variable. For example, support you have your config locally in config.json:

```
CONFIG=$(cat config.json)
docker run --rm -e "CONFIG=$(echo $CONFIG)" sanathp/statusok
```

## Simple Version

Expand Down
1 change: 1 addition & 0 deletions config.template
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
$CONFIG
2 changes: 1 addition & 1 deletion database/database.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@ import (
"reflect"
"strings"

"github.com/Sirupsen/logrus"
"github.com/sanathp/statusok/notify"
"github.com/sirupsen/logrus"
)

var (
Expand Down
4 changes: 4 additions & 0 deletions docker-entrypoint.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
#!/bin/sh

cat /config.template | envsubst > /config.json
/statusok --config /config.json
9 changes: 9 additions & 0 deletions go.mod
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
module github.com/sanathp/statusok

require (
github.com/codegangsta/cli v1.20.0
github.com/influxdata/influxdb v1.6.4
github.com/mailgun/mailgun-go v1.1.1
github.com/pkg/errors v0.8.0 // indirect
github.com/sirupsen/logrus v1.2.0
)
20 changes: 20 additions & 0 deletions go.sum
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
github.com/codegangsta/cli v1.20.0 h1:iX1FXEgwzd5+XN6wk5cVHOGQj6Q3Dcp20lUeS4lHNTw=
github.com/codegangsta/cli v1.20.0/go.mod h1:/qJNoX69yVSKu5o4jLyXAENLRyk1uhi7zkbQ3slBdOA=
github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
github.com/influxdata/influxdb v1.6.4 h1:K8wPlkrP02HzHTJbbUQQ1CZ2Hw6LtpG4xbNEgnlhMZU=
github.com/influxdata/influxdb v1.6.4/go.mod h1:qZna6X/4elxqT3yI9iZYdZrWWdeFOOprn86kgg4+IzY=
github.com/konsorten/go-windows-terminal-sequences v1.0.1 h1:mweAR1A6xJ3oS2pRaGiHgQ4OO8tzTaLawm8vnODuwDk=
github.com/konsorten/go-windows-terminal-sequences v1.0.1/go.mod h1:T0+1ngSBFLxvqU3pZ+m/2kptfBszLMUkC4ZK/EgS/cQ=
github.com/mailgun/mailgun-go v1.1.1 h1:mjMcm4qz+SbjAYbGJ6DKROViKtO5S0YjpuOUxQfdr2A=
github.com/mailgun/mailgun-go v1.1.1/go.mod h1:NWTyU+O4aczg/nsGhQnvHL6v2n5Gy6Sv5tNDVvC6FbU=
github.com/pkg/errors v0.8.0 h1:WdK/asTD0HN+q6hsWO3/vpuAkAr+tw6aNJNDFFf0+qw=
github.com/pkg/errors v0.8.0/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0=
github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4=
github.com/sirupsen/logrus v1.2.0 h1:juTguoYk5qI21pwyTXY3B3Y5cOTH3ZUyZCg1v/mihuo=
github.com/sirupsen/logrus v1.2.0/go.mod h1:LxeOpSwHxABJmUn/MG1IvRgCAasNZTLOkJPxbbu5VWo=
github.com/stretchr/objx v0.1.1/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME=
github.com/stretchr/testify v1.2.2/go.mod h1:a8OnRcib4nhh0OaRAV+Yts87kKdq0PP7pXfy6kDkUVs=
golang.org/x/crypto v0.0.0-20180904163835-0709b304e793 h1:u+LnwYTOOW7Ukr/fppxEb1Nwz0AtPflrblfvUudpo+I=
golang.org/x/crypto v0.0.0-20180904163835-0709b304e793/go.mod h1:6SG95UA2DQfeDnfUPMdvaQW0Q7yPrPDi9nlGo2tz2b4=
golang.org/x/sys v0.0.0-20180905080454-ebe1bf3edb33 h1:I6FyU15t786LL7oL/hn43zqTuEGr4PN7F4XJ1p4E3Y8=
golang.org/x/sys v0.0.0-20180905080454-ebe1bf3edb33/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
17 changes: 9 additions & 8 deletions notify/dingding.go
Original file line number Diff line number Diff line change
Expand Up @@ -40,16 +40,17 @@ func (dingdingNotify DingdingNotify) SendResponseTimeNotification(responseTimeNo
}
fmt.Printf("%v", msgParam)

if dingdingNotify.Headers[ContentType] == JsonContentType {
if !(dingdingNotify.Headers[ContentType] == JsonContentType) {
return fmt.Errorf("No content provided")
}

jsonBody, jsonErr := getJsonParamsBodyDingding(msgParam)
if jsonErr != nil {
return jsonErr
}
request, reqErr = http.NewRequest(dingdingNotify.RequestType,
dingdingNotify.Url,
jsonBody)
jsonBody, jsonErr := getJsonParamsBodyDingding(msgParam)
if jsonErr != nil {
return jsonErr
}
request, reqErr = http.NewRequest(dingdingNotify.RequestType,
dingdingNotify.Url,
jsonBody)

if reqErr != nil {
return reqErr
Expand Down
2 changes: 1 addition & 1 deletion notify/notify.go
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ func AddNew(notificationTypes NotificationTypes) {
println("Notifications : Failed to Initialize ", value.GetClientName(), ".Please check the details in config file ")
println("Error Details :", initErr.Error())
} else {
println("Notifications :", value.GetClientName(), " Intialized")
println("Notifications :", value.GetClientName(), " Initialized")
}

}
Expand Down
9 changes: 5 additions & 4 deletions statusok.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,16 +3,17 @@ package main
import (
"encoding/json"
"fmt"
"github.com/codegangsta/cli"
"github.com/sanathp/statusok/database"
"github.com/sanathp/statusok/notify"
"github.com/sanathp/statusok/requests"
"io"
"math/rand"
"net/http"
"os"
"strconv"
"time"

"github.com/codegangsta/cli"
"github.com/sanathp/statusok/database"
"github.com/sanathp/statusok/notify"
"github.com/sanathp/statusok/requests"
)

type configParser struct {
Expand Down