mirror of https://github.com/statping/statping
ICMP service types
parent
0826f16f3d
commit
edf3e44798
|
@ -90,12 +90,12 @@
|
|||
version = "v1.1.1"
|
||||
|
||||
[[projects]]
|
||||
digest = "1:ca59b1175189b3f0e9f1793d2c350114be36eaabbe5b9f554b35edee1de50aea"
|
||||
digest = "1:d5f97fc268267ec1b61c3453058c738246fc3e746f14b1ae25161513b7367b0c"
|
||||
name = "github.com/gorilla/mux"
|
||||
packages = ["."]
|
||||
pruneopts = "UT"
|
||||
revision = "a7962380ca08b5a188038c69871b8d3fbdf31e89"
|
||||
version = "v1.7.0"
|
||||
revision = "c5c6c98bc25355028a63748a498942a6398ccd22"
|
||||
version = "v1.7.1"
|
||||
|
||||
[[projects]]
|
||||
digest = "1:e72d1ebb8d395cf9f346fd9cbc652e5ae222dd85e0ac842dc57f175abed6d195"
|
||||
|
@ -121,26 +121,6 @@
|
|||
revision = "66b9c49e59c6c48f0ffce28c2d8b8a5678502c6d"
|
||||
version = "v1.4.0"
|
||||
|
||||
[[projects]]
|
||||
digest = "1:7fbb40f65374cb64a7bf3f1f74e2cb4c4437d93bc3d8921cf7e3d7ad2ab20989"
|
||||
name = "github.com/graphql-go/graphql"
|
||||
packages = [
|
||||
".",
|
||||
"gqlerrors",
|
||||
"language/ast",
|
||||
"language/kinds",
|
||||
"language/lexer",
|
||||
"language/location",
|
||||
"language/parser",
|
||||
"language/printer",
|
||||
"language/source",
|
||||
"language/typeInfo",
|
||||
"language/visitor",
|
||||
]
|
||||
pruneopts = "UT"
|
||||
revision = "2b0b7340d2285b861482047fbf5de0488e021bea"
|
||||
version = "v0.7.8"
|
||||
|
||||
[[projects]]
|
||||
digest = "1:d15ee511aa0f56baacc1eb4c6b922fa1c03b38413b6be18166b996d82a0156ea"
|
||||
name = "github.com/hashicorp/golang-lru"
|
||||
|
@ -153,7 +133,7 @@
|
|||
version = "v0.5.1"
|
||||
|
||||
[[projects]]
|
||||
digest = "1:ff312c4d510c67954a6fc6a11c9ff72a2b2169584776b7419c7b8c729e2b13ac"
|
||||
digest = "1:0731b955911f880c75409845b54203f5127c72e003691e2d34462a0516a9b1f6"
|
||||
name = "github.com/jinzhu/gorm"
|
||||
packages = [
|
||||
".",
|
||||
|
@ -162,8 +142,8 @@
|
|||
"dialects/sqlite",
|
||||
]
|
||||
pruneopts = "UT"
|
||||
revision = "472c70caa40267cb89fd8facb07fe6454b578626"
|
||||
version = "v1.9.2"
|
||||
revision = "e3987fd4b803c16497aa4dfd2e75db7a6a061a4e"
|
||||
version = "v1.9.4"
|
||||
|
||||
[[projects]]
|
||||
branch = "master"
|
||||
|
@ -182,16 +162,17 @@
|
|||
version = "v1.3.0"
|
||||
|
||||
[[projects]]
|
||||
digest = "1:b18ffc558326ebaed3b4a175617f1e12ed4e3f53d6ebfe5ba372a3de16d22278"
|
||||
digest = "1:226be3582c304c347481157049c862924fdd6277256e854781c5ba4728901215"
|
||||
name = "github.com/lib/pq"
|
||||
packages = [
|
||||
".",
|
||||
"hstore",
|
||||
"oid",
|
||||
"scram",
|
||||
]
|
||||
pruneopts = "UT"
|
||||
revision = "4ded0e9383f75c197b3a2aaa6d590ac52df6fd79"
|
||||
version = "v1.0.0"
|
||||
revision = "51e2106eed1cea199c802d2a49e91e2491b02056"
|
||||
version = "v1.1.0"
|
||||
|
||||
[[projects]]
|
||||
digest = "1:4a49346ca45376a2bba679ca0e83bec949d780d4e927931317904bad482943ec"
|
||||
|
@ -233,6 +214,14 @@
|
|||
revision = "ffdc059bfe9ce6a4e144ba849dbedead332c6053"
|
||||
version = "v1.3.0"
|
||||
|
||||
[[projects]]
|
||||
branch = "master"
|
||||
digest = "1:9f3a60def1a1eb5ac184e71dde43c6f99606f54d106db7c95f8b8338629a777b"
|
||||
name = "github.com/tatsushid/go-fastping"
|
||||
packages = ["."]
|
||||
pruneopts = "UT"
|
||||
revision = "d7bb493dee3e090e2ffb6914adddf17c1e7c026c"
|
||||
|
||||
[[projects]]
|
||||
digest = "1:b4e8aaca88f799355f4ac560bce4293fb85ff21003dd0d5741ca503f7a788e91"
|
||||
name = "github.com/vektah/gqlparser"
|
||||
|
@ -258,7 +247,22 @@
|
|||
"blowfish",
|
||||
]
|
||||
pruneopts = "UT"
|
||||
revision = "a5d413f7728c81fb97d96a2b722368945f651e78"
|
||||
revision = "df01cb2cc480549d72034218dd98bf97671450ac"
|
||||
|
||||
[[projects]]
|
||||
branch = "master"
|
||||
digest = "1:18ca16fd6f3c83e931598380b27badbcb669ddd3a690b66fb4a7390467f460ef"
|
||||
name = "golang.org/x/net"
|
||||
packages = [
|
||||
"bpf",
|
||||
"icmp",
|
||||
"internal/iana",
|
||||
"internal/socket",
|
||||
"ipv4",
|
||||
"ipv6",
|
||||
]
|
||||
pruneopts = "UT"
|
||||
revision = "1f3472d942ba824034fb77cab6a6cfc1bc8a2c3c"
|
||||
|
||||
[[projects]]
|
||||
digest = "1:c25289f43ac4a68d88b02245742347c94f1e108c534dda442188015ff80669b3"
|
||||
|
@ -306,7 +310,6 @@
|
|||
"github.com/go-yaml/yaml",
|
||||
"github.com/gorilla/mux",
|
||||
"github.com/gorilla/sessions",
|
||||
"github.com/graphql-go/graphql",
|
||||
"github.com/jinzhu/gorm",
|
||||
"github.com/jinzhu/gorm/dialects/mysql",
|
||||
"github.com/jinzhu/gorm/dialects/postgres",
|
||||
|
@ -314,6 +317,7 @@
|
|||
"github.com/joho/godotenv",
|
||||
"github.com/rendon/testcli",
|
||||
"github.com/stretchr/testify/assert",
|
||||
"github.com/tatsushid/go-fastping",
|
||||
"github.com/vektah/gqlparser",
|
||||
"github.com/vektah/gqlparser/ast",
|
||||
"golang.org/x/crypto/bcrypt",
|
||||
|
|
12
Gopkg.toml
12
Gopkg.toml
|
@ -47,19 +47,15 @@
|
|||
|
||||
[[constraint]]
|
||||
name = "github.com/gorilla/mux"
|
||||
version = "1.7.0"
|
||||
version = "1.7.1"
|
||||
|
||||
[[constraint]]
|
||||
name = "github.com/gorilla/sessions"
|
||||
version = "1.1.3"
|
||||
|
||||
[[constraint]]
|
||||
name = "github.com/graphql-go/graphql"
|
||||
version = "0.7.8"
|
||||
|
||||
[[constraint]]
|
||||
name = "github.com/jinzhu/gorm"
|
||||
version = "1.9.2"
|
||||
version = "1.9.4"
|
||||
|
||||
[[constraint]]
|
||||
name = "github.com/joho/godotenv"
|
||||
|
@ -73,6 +69,10 @@
|
|||
name = "github.com/stretchr/testify"
|
||||
version = "1.3.0"
|
||||
|
||||
[[constraint]]
|
||||
branch = "master"
|
||||
name = "github.com/tatsushid/go-fastping"
|
||||
|
||||
[[constraint]]
|
||||
name = "github.com/vektah/gqlparser"
|
||||
version = "1.1.2"
|
||||
|
|
|
@ -21,6 +21,7 @@ import (
|
|||
"github.com/hunterlong/statping/core/notifier"
|
||||
"github.com/hunterlong/statping/types"
|
||||
"github.com/hunterlong/statping/utils"
|
||||
"github.com/tatsushid/go-fastping"
|
||||
"net"
|
||||
"net/http"
|
||||
"net/url"
|
||||
|
@ -38,6 +39,18 @@ func checkServices() {
|
|||
}
|
||||
}
|
||||
|
||||
// Check will run checkHttp for HTTP services and checkTcp for TCP services
|
||||
func (s *Service) Check(record bool) {
|
||||
switch s.Type {
|
||||
case "http":
|
||||
s.checkHttp(record)
|
||||
case "tcp", "udp":
|
||||
s.checkTcp(record)
|
||||
case "icmp":
|
||||
s.checkIcmp(record)
|
||||
}
|
||||
}
|
||||
|
||||
// CheckQueue is the main go routine for checking a service
|
||||
func (s *Service) CheckQueue(record bool) {
|
||||
s.Checkpoint = time.Now()
|
||||
|
@ -109,6 +122,28 @@ func (s *Service) dnsCheck() (float64, error) {
|
|||
return subTime, err
|
||||
}
|
||||
|
||||
// checkIcmp will send a ICMP ping packet to the service
|
||||
func (s *Service) checkIcmp(record bool) *Service {
|
||||
p := fastping.NewPinger()
|
||||
ra, err := net.ResolveIPAddr("ip4:icmp", s.Domain)
|
||||
if err != nil {
|
||||
recordFailure(s, fmt.Sprintf("Could not send ICMP to service %v, %v", s.Domain, err))
|
||||
return s
|
||||
}
|
||||
p.AddIPAddr(ra)
|
||||
p.OnRecv = func(addr *net.IPAddr, rtt time.Duration) {
|
||||
s.Latency = rtt.Seconds()
|
||||
recordSuccess(s)
|
||||
}
|
||||
err = p.Run()
|
||||
if err != nil {
|
||||
recordFailure(s, fmt.Sprintf("Issue running ICMP to service %v, %v", s.Domain, err))
|
||||
return s
|
||||
}
|
||||
s.LastResponse = ""
|
||||
return s
|
||||
}
|
||||
|
||||
// checkTcp will check a TCP service
|
||||
func (s *Service) checkTcp(record bool) *Service {
|
||||
dnsLookup, err := s.dnsCheck()
|
||||
|
@ -219,16 +254,6 @@ func (s *Service) checkHttp(record bool) *Service {
|
|||
return s
|
||||
}
|
||||
|
||||
// Check will run checkHttp for HTTP services and checkTcp for TCP services
|
||||
func (s *Service) Check(record bool) {
|
||||
switch s.Type {
|
||||
case "http":
|
||||
s.checkHttp(record)
|
||||
case "tcp", "udp":
|
||||
s.checkTcp(record)
|
||||
}
|
||||
}
|
||||
|
||||
// recordSuccess will create a new 'hit' record in the database for a successful/online service
|
||||
func recordSuccess(s *Service) {
|
||||
s.Online = true
|
||||
|
|
|
@ -21,6 +21,7 @@
|
|||
<option value="http" {{if eq .Type "http"}}selected{{end}}>HTTP Service</option>
|
||||
<option value="tcp" {{if eq .Type "tcp"}}selected{{end}}>TCP Service</option>
|
||||
<option value="udp" {{if eq .Type "udp"}}selected{{end}}>UDP Service</option>
|
||||
<option value="icmp" {{if eq .Type "icmp"}}selected{{end}}>ICMP Ping</option>
|
||||
</select>
|
||||
<small class="form-text text-muted">Use HTTP if you are checking a website or use TCP if you are checking a server</small>
|
||||
</div>
|
||||
|
@ -113,7 +114,7 @@
|
|||
<span class="switch float-left">
|
||||
<input type="checkbox" name="allow_notifications-option" class="switch" id="switch-notifications" {{if eq .Id 0}}checked{{end}}{{if .AllowNotifications.Bool}}checked{{end}}>
|
||||
<label for="switch-notifications">Allow notifications to be sent for this service</label>
|
||||
<input type="hidden" name="allow_notifications" id="switch-notifications-value" value="{{if .AllowNotifications.Bool}}true{{else}}false{{end}}">
|
||||
<input type="hidden" name="allow_notifications" id="switch-notifications-value" value="{{if eq .Id 0}}true{{else}}{{if .AllowNotifications.Bool}}true{{else}}false{{end}}{{end}}">
|
||||
</span>
|
||||
</div>
|
||||
</div>
|
||||
|
@ -123,7 +124,7 @@
|
|||
<span class="switch float-left">
|
||||
<input type="checkbox" name="public-option" class="switch" id="switch-public" {{if eq .Id 0}}checked{{else}}{{if .Public.Bool}}checked{{end}}{{end}}>
|
||||
<label for="switch-public">Show service details to the public</label>
|
||||
<input type="hidden" name="public" id="switch-public-value" value="{{if .Public.Bool}}true{{else}}false{{end}}">
|
||||
<input type="hidden" name="public" id="switch-public-value" value="{{if eq .Id 0}}true{{else}}{{if .Public.Bool}}true{{else}}false{{end}}{{end}}">
|
||||
</span>
|
||||
</div>
|
||||
</div>
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
// Code generated by go generate; DO NOT EDIT.
|
||||
// This file was generated by robots at
|
||||
// 2019-04-08 11:09:35.883451 -0700 PDT m=+0.485888071
|
||||
// 2019-04-19 11:45:38.037927 -0700 PDT m=+0.539240775
|
||||
//
|
||||
// This contains the most recently Markdown source for the Statping Wiki.
|
||||
package source
|
||||
|
|
Loading…
Reference in New Issue