diff --git a/.idea/$CACHE_FILE$ b/.idea/$CACHE_FILE$
new file mode 100644
index 00000000..71fc98db
--- /dev/null
+++ b/.idea/$CACHE_FILE$
@@ -0,0 +1,20 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+ CSS
+
+
+
+
+
+
\ No newline at end of file
diff --git a/.idea/$PRODUCT_WORKSPACE_FILE$ b/.idea/$PRODUCT_WORKSPACE_FILE$
new file mode 100644
index 00000000..3163e936
--- /dev/null
+++ b/.idea/$PRODUCT_WORKSPACE_FILE$
@@ -0,0 +1,76 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+ groovy-2.4.12
+
+
+
+
+
+
+
+
+
+
+
+ 1.8
+
+
+
+
+
+
+
+
+
+
+
+ 1.8
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/.idea/.gitignore b/.idea/.gitignore
new file mode 100644
index 00000000..5c98b428
--- /dev/null
+++ b/.idea/.gitignore
@@ -0,0 +1,2 @@
+# Default ignored files
+/workspace.xml
\ No newline at end of file
diff --git a/.idea/dictionaries b/.idea/dictionaries
new file mode 100644
index 00000000..65d60022
--- /dev/null
+++ b/.idea/dictionaries
@@ -0,0 +1,6 @@
+
+
+
+
+
+
\ No newline at end of file
diff --git a/.idea/gatus.iml b/.idea/gatus.iml
new file mode 100644
index 00000000..c956989b
--- /dev/null
+++ b/.idea/gatus.iml
@@ -0,0 +1,8 @@
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/.idea/misc.xml b/.idea/misc.xml
new file mode 100644
index 00000000..17865bfe
--- /dev/null
+++ b/.idea/misc.xml
@@ -0,0 +1,14 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/.idea/modules.xml b/.idea/modules.xml
new file mode 100644
index 00000000..41462523
--- /dev/null
+++ b/.idea/modules.xml
@@ -0,0 +1,8 @@
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/.idea/vcs.xml b/.idea/vcs.xml
new file mode 100644
index 00000000..94a25f7f
--- /dev/null
+++ b/.idea/vcs.xml
@@ -0,0 +1,6 @@
+
+
+
+
+
+
\ No newline at end of file
diff --git a/README.md b/README.md
index 43318010..51ff7bd3 100644
--- a/README.md
+++ b/README.md
@@ -1,2 +1,17 @@
# gatus
+
A service health dashboard in Go
+
+
+config should look something like
+
+```yaml
+services:
+ - name: twinnation
+ url: https://twinnation.org/actuator/health
+ interval: 10
+ failure-threshold: 3
+ conditions:
+ - "$STATUS == 200"
+ - "IP == 200"
+```
\ No newline at end of file
diff --git a/go.mod b/go.mod
new file mode 100644
index 00000000..9c43d44b
--- /dev/null
+++ b/go.mod
@@ -0,0 +1,5 @@
+module github.com/TwinProduction/gatus
+
+go 1.12
+
+require k8s.io/helm v2.14.3+incompatible
diff --git a/go.sum b/go.sum
new file mode 100644
index 00000000..b1f34353
--- /dev/null
+++ b/go.sum
@@ -0,0 +1,2 @@
+k8s.io/helm v2.14.3+incompatible h1:uzotTcZXa/b2SWVoUzM1xiCXVjI38TuxMujS/1s+3Gw=
+k8s.io/helm v2.14.3+incompatible/go.mod h1:LZzlS4LQBHfciFOurYBFkCMTaZ0D1l+p0teMg7TSULI=
diff --git a/main.go b/main.go
new file mode 100644
index 00000000..16b7f9e9
--- /dev/null
+++ b/main.go
@@ -0,0 +1,14 @@
+package main
+
+import (
+ "fmt"
+ "github.com/TwinProduction/gatus/watchdog"
+)
+
+func main() {
+ request := watchdog.Request{Url: "https://twinnation.org/actuator/health"}
+ result := &watchdog.Result{}
+ request.GetIp(result)
+ request.GetStatus(result)
+ fmt.Println(result)
+}
diff --git a/watchdog/watchdog.go b/watchdog/watchdog.go
new file mode 100644
index 00000000..8ae4c024
--- /dev/null
+++ b/watchdog/watchdog.go
@@ -0,0 +1,49 @@
+package watchdog
+
+import (
+ "net"
+ "net/http"
+ "net/url"
+ "time"
+)
+
+type Request struct {
+ Url string
+}
+
+type Result struct {
+ HttpStatus int
+ Hostname string
+ Ip string
+ Duration time.Duration
+ Errors []error
+}
+
+func (request *Request) GetIp(result *Result) {
+ urlObject, err := url.Parse(request.Url)
+ if err != nil {
+ result.Errors = append(result.Errors, err)
+ return
+ }
+ result.Hostname = urlObject.Hostname()
+ ips, err := net.LookupIP(urlObject.Hostname())
+ if err != nil {
+ result.Errors = append(result.Errors, err)
+ return
+ }
+ result.Ip = ips[0].String()
+}
+
+func (request *Request) GetStatus(result *Result) {
+ client := &http.Client{
+ Timeout: time.Second * 10,
+ }
+ startTime := time.Now()
+ response, err := client.Get(request.Url)
+ if err != nil {
+ result.Errors = append(result.Errors, err)
+ return
+ }
+ result.Duration = time.Now().Sub(startTime)
+ result.HttpStatus = response.StatusCode
+}