7 Commits

Author SHA1 Message Date
Alan Campbell
5793df7353 Update go install guide 2016-03-07 16:31:24 -05:00
Matej Kramny
fae03e7561 Merge pull request #10 from studiofrenetic/master
Add time interval
2015-12-08 13:02:12 +00:00
Matej Kramny
bcf53f0afc Merge pull request #17 from Soulou/patch-1
Fix configuration example in README
2015-08-24 00:08:36 +01:00
Soulou
3c1e2cd452 Fix configuration example in README 2015-08-22 19:13:27 +02:00
Mathieu Doyon
850f4d237b Update interval to 5 secs 2015-07-19 16:23:49 -04:00
Mathieu Doyon
019bc8c057 Fix merge conflict 2015-07-19 16:23:18 -04:00
Mathieu Doyon
f918ea38cd Add time interval 2015-04-08 14:28:36 -04:00
4 changed files with 11 additions and 7 deletions

View File

@@ -4,13 +4,14 @@ import (
"encoding/json"
"flag"
"fmt"
"github.com/castawaylabs/cachet-monitor/system"
"io"
"io/ioutil"
"log"
"net/http"
"net/url"
"os"
"github.com/castawaylabs/cachet-monitor/system"
)
// Static config
@@ -23,6 +24,7 @@ var Logger *log.Logger
type CachetConfig struct {
APIUrl string `json:"api_url"`
APIToken string `json:"api_token"`
Interval int64 `json:"interval"`
Monitors []*Monitor `json:"monitors"`
SystemName string `json:"system_name"`
LogPath string `json:"log_path"`

View File

@@ -1,6 +1,7 @@
{
"api_url": "https://demo.cachethq.io/api/v1",
"api_token": "9yMHsdioQosnyVK4iCVR",
"interval": 5,
"monitors": [
{
"name": "nodegear frontend",

View File

@@ -9,7 +9,7 @@ func main() {
config := cachet.Config
log := cachet.Logger
log.Printf("System: %s, API: %s\n", config.SystemName, config.APIUrl)
log.Printf("System: %s, Interval: %d second(s), API: %s\n", config.SystemName, config.Interval, config.APIUrl)
log.Printf("Starting %d monitors:\n", len(config.Monitors))
for _, mon := range config.Monitors {
log.Printf(" %s: GET %s & Expect HTTP %d\n", mon.Name, mon.URL, mon.ExpectedStatusCode)
@@ -20,7 +20,7 @@ func main() {
log.Println()
ticker := time.NewTicker(time.Second)
ticker := time.NewTicker(time.Duration(config.Interval)*time.Second)
for range ticker.C {
for _, mon := range config.Monitors {
go mon.Run()

View File

@@ -9,7 +9,7 @@ Features
--------
- [x] Creates & Resolves Incidents
- [x] Posts monitor lag every second
- [x] Posts monitor lag every second * config.Interval
- [x] Updates Component to Partial Outage
- [x] Updates Component to Major Outage if in Partial Outage
- [x] Can be run on multiple servers and geo regions
@@ -34,6 +34,7 @@ Configuration
{
"api_url": "https://demo.cachethq.io/api/v1",
"api_token": "9yMHsdioQosnyVK4iCVR",
"interval": 60,
"monitors": [
{
"name": "nodegear frontend",
@@ -41,7 +42,6 @@ Configuration
"metric_id": 0,
"component_id": 0,
"threshold": 80,
"component_id": null,
"expected_status_code": 200,
"strict_tls": true
}
@@ -66,8 +66,9 @@ How to run
Example:
1. Set up [Go](https://golang.org)
2. `go install github.com/castawaylabs/cachet-monitor`
3. `cachet-monitor -c https://raw.githubusercontent.com/CastawayLabs/cachet-monitor/master/example.config.json`
2. `go get -d github.com/castawaylabs/cachet-monitor`
3. `go install github.com/castawaylabs/cachet-monitor`
4. `cachet-monitor -c https://raw.githubusercontent.com/CastawayLabs/cachet-monitor/master/example.config.json`
Production: