flapjack 1.0.0rc6 → 1.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/CHANGELOG.md +3 -0
- data/build.sh +5 -7
- data/flapjack.gemspec +1 -1
- data/lib/flapjack/version.rb +1 -1
- data/libexec/httpbroker.go +23 -23
- data/libexec/oneoff.go +18 -18
- data/src/flapjack/event.go +19 -12
- data/src/flapjack/event_test.go +4 -4
- data/src/flapjack/transport.go +7 -8
- metadata +5 -4
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 7ec94faddf6467adf887a6f66d074a4ac8d807ca
|
4
|
+
data.tar.gz: 53f73cc61036a9d014a0438e11fff8df0c549cf3
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: c55a5f75ec5ee9b4121e625867d914180263727ad0009d5827fe45cbcb73ea63d115e83db68bd04b09ee8f47a8bd04da3d74983caf22834f31928c5822adefd2
|
7
|
+
data.tar.gz: dd45f9d97ab302029882dbdd3f3203c03e2c078188d16839c9e18b19ee98482a7fc9b821150c6ac5954cf4620cf54b3fdc292df3e8cb1d4729ad2c6c890f9bfd
|
data/CHANGELOG.md
CHANGED
data/build.sh
CHANGED
@@ -15,20 +15,18 @@ go test flapjack
|
|
15
15
|
go build -x -o libexec/httpbroker libexec/httpbroker.go
|
16
16
|
go build -x -o libexec/oneoff libexec/oneoff.go
|
17
17
|
|
18
|
-
|
19
18
|
if [ ! -z "$CROSSCOMPILE" ]; then
|
20
19
|
for command in httpbroker oneoff; do
|
21
20
|
GOOS=linux GOARCH=amd64 CGOENABLED=0 go build -x -o libexec/$command.linux_amd64 libexec/$command.go
|
22
21
|
GOOS=linux GOARCH=386 CGOENABLED=0 go build -x -o libexec/$command.linux_386 libexec/$command.go
|
23
|
-
done
|
24
|
-
|
22
|
+
done
|
23
|
+
|
25
24
|
pushd src/github.com/oguzbilgic/pandik
|
26
|
-
GOOS=linux GOARCH=amd64 CGOENABLED=0 go build -x -o httpchecker.linux_amd64
|
27
|
-
GOOS=linux GOARCH=386 CGOENABLED=0 go build -x -o httpchecker.linux_386
|
28
|
-
popd
|
25
|
+
GOOS=linux GOARCH=amd64 CGOENABLED=0 go build -x -o httpchecker.linux_amd64
|
26
|
+
GOOS=linux GOARCH=386 CGOENABLED=0 go build -x -o httpchecker.linux_386
|
27
|
+
popd
|
29
28
|
mv src/github.com/oguzbilgic/pandik/httpchecker.linux_amd64 libexec/httpchecker.linux_amd64
|
30
29
|
mv src/github.com/oguzbilgic/pandik/httpchecker.linux_386 libexec/httpchecker.linux_386
|
31
|
-
|
32
30
|
fi
|
33
31
|
|
34
32
|
|
data/flapjack.gemspec
CHANGED
@@ -2,7 +2,7 @@
|
|
2
2
|
require File.expand_path('../lib/flapjack/version', __FILE__)
|
3
3
|
|
4
4
|
Gem::Specification.new do |gem|
|
5
|
-
gem.authors = [ "Lindsay Holmwood", "Jesse Reynolds", "Ali Graham" ]
|
5
|
+
gem.authors = [ "Lindsay Holmwood", "Jesse Reynolds", "Ali Graham", "Sarah Kowalik" ]
|
6
6
|
gem.email = "lindsay@holmwood.id.au"
|
7
7
|
gem.description = "Flapjack is a distributed monitoring notification system that provides a scalable method for processing streams of events from Nagios and deciding who should be notified"
|
8
8
|
gem.summary = "Intelligent, scalable, distributed monitoring notification system."
|
data/lib/flapjack/version.rb
CHANGED
data/libexec/httpbroker.go
CHANGED
@@ -1,16 +1,16 @@
|
|
1
1
|
package main
|
2
2
|
|
3
3
|
import (
|
4
|
+
"encoding/json"
|
5
|
+
"flapjack"
|
4
6
|
"fmt"
|
7
|
+
"github.com/go-martini/martini"
|
8
|
+
"gopkg.in/alecthomas/kingpin.v1"
|
9
|
+
"io/ioutil"
|
5
10
|
"log"
|
11
|
+
"net/http"
|
6
12
|
"os"
|
7
|
-
"io/ioutil"
|
8
13
|
"time"
|
9
|
-
"net/http"
|
10
|
-
"flapjack"
|
11
|
-
"encoding/json"
|
12
|
-
"gopkg.in/alecthomas/kingpin.v1"
|
13
|
-
"github.com/go-martini/martini"
|
14
14
|
)
|
15
15
|
|
16
16
|
// State is a basic representation of a Flapjack event, with some extra field.
|
@@ -18,7 +18,7 @@ import (
|
|
18
18
|
// Find more at http://flapjack.io/docs/1.0/development/DATA_STRUCTURES
|
19
19
|
type State struct {
|
20
20
|
flapjack.Event
|
21
|
-
TTL
|
21
|
+
TTL int64 `json:"ttl"`
|
22
22
|
}
|
23
23
|
|
24
24
|
// handler caches
|
@@ -82,7 +82,7 @@ func submitCachedState(states map[string]State, config Config) {
|
|
82
82
|
|
83
83
|
for {
|
84
84
|
log.Printf("Number of cached states: %d\n", len(states))
|
85
|
-
for id, state := range
|
85
|
+
for id, state := range states {
|
86
86
|
now := time.Now().Unix()
|
87
87
|
event := flapjack.Event{
|
88
88
|
Entity: state.Entity,
|
@@ -110,19 +110,19 @@ func submitCachedState(states map[string]State, config Config) {
|
|
110
110
|
}
|
111
111
|
|
112
112
|
var (
|
113
|
-
port
|
114
|
-
server
|
115
|
-
database
|
116
|
-
interval
|
117
|
-
debug
|
113
|
+
port = kingpin.Flag("port", "Address to bind HTTP server (default 3090)").Default("3090").OverrideDefaultFromEnvar("PORT").String()
|
114
|
+
server = kingpin.Flag("server", "Redis server to connect to (default localhost:6380)").Default("localhost:6380").String()
|
115
|
+
database = kingpin.Flag("database", "Redis database to connect to (default 0)").Int() // .Default("13").Int()
|
116
|
+
interval = kingpin.Flag("interval", "How often to submit events (default 10s)").Default("10s").Duration()
|
117
|
+
debug = kingpin.Flag("debug", "Enable verbose output (default false)").Bool()
|
118
118
|
)
|
119
119
|
|
120
120
|
type Config struct {
|
121
|
-
Port
|
122
|
-
Server
|
123
|
-
Database
|
124
|
-
Interval
|
125
|
-
Debug
|
121
|
+
Port string
|
122
|
+
Server string
|
123
|
+
Database int
|
124
|
+
Interval time.Duration
|
125
|
+
Debug bool
|
126
126
|
}
|
127
127
|
|
128
128
|
func main() {
|
@@ -130,11 +130,11 @@ func main() {
|
|
130
130
|
kingpin.Parse()
|
131
131
|
|
132
132
|
config := Config{
|
133
|
-
Server:
|
134
|
-
Database:
|
135
|
-
Interval:
|
136
|
-
Debug:
|
137
|
-
Port:
|
133
|
+
Server: *server,
|
134
|
+
Database: *database,
|
135
|
+
Interval: *interval,
|
136
|
+
Debug: *debug,
|
137
|
+
Port: ":" + *port,
|
138
138
|
}
|
139
139
|
if config.Debug {
|
140
140
|
log.Printf("Booting with config: %+v\n", config)
|
data/libexec/oneoff.go
CHANGED
@@ -1,23 +1,23 @@
|
|
1
1
|
package main
|
2
2
|
|
3
3
|
import (
|
4
|
-
"
|
5
|
-
"fmt"
|
6
|
-
"time"
|
7
|
-
"strings"
|
4
|
+
"encoding/json"
|
8
5
|
"flapjack"
|
6
|
+
"fmt"
|
9
7
|
"gopkg.in/alecthomas/kingpin.v1"
|
10
|
-
"
|
8
|
+
"os"
|
9
|
+
"strings"
|
10
|
+
"time"
|
11
11
|
)
|
12
12
|
|
13
13
|
var (
|
14
|
-
entity
|
15
|
-
check
|
16
|
-
state
|
17
|
-
summary
|
18
|
-
debug
|
19
|
-
server
|
20
|
-
database
|
14
|
+
entity = kingpin.Arg("entity", "Entity name").Required().String()
|
15
|
+
check = kingpin.Arg("check", "Check name").Required().String()
|
16
|
+
state = kingpin.Arg("state", "Current state").Required().String()
|
17
|
+
summary = kingpin.Arg("summary", "Summary of event").Required().String()
|
18
|
+
debug = kingpin.Flag("debug", "Enable verbose output (default false)").Bool()
|
19
|
+
server = kingpin.Flag("server", "Redis server to connect to (default localhost:6380)").Default("localhost:6380").String()
|
20
|
+
database = kingpin.Flag("database", "Redis database to connect to (default 0)").Int()
|
21
21
|
)
|
22
22
|
|
23
23
|
func main() {
|
@@ -42,12 +42,12 @@ func main() {
|
|
42
42
|
}
|
43
43
|
|
44
44
|
event := flapjack.Event{
|
45
|
-
Entity:
|
46
|
-
Check:
|
47
|
-
Type:
|
48
|
-
State:
|
49
|
-
Summary:
|
50
|
-
Time:
|
45
|
+
Entity: *entity,
|
46
|
+
Check: *check,
|
47
|
+
Type: "service",
|
48
|
+
State: *state,
|
49
|
+
Summary: *summary,
|
50
|
+
Time: time.Now().Unix(),
|
51
51
|
}
|
52
52
|
|
53
53
|
if *debug {
|
data/src/flapjack/event.go
CHANGED
@@ -5,21 +5,28 @@ import "errors"
|
|
5
5
|
// Event is a basic representation of a Flapjack event.
|
6
6
|
// Find more at http://flapjack.io/docs/1.0/development/DATA_STRUCTURES
|
7
7
|
type Event struct {
|
8
|
-
Entity
|
9
|
-
Check
|
10
|
-
Type
|
11
|
-
State
|
12
|
-
Summary
|
13
|
-
Time
|
8
|
+
Entity string `json:"entity"`
|
9
|
+
Check string `json:"check"`
|
10
|
+
Type string `json:"type"`
|
11
|
+
State string `json:"state"`
|
12
|
+
Summary string `json:"summary"`
|
13
|
+
Time int64 `json:"time"`
|
14
14
|
}
|
15
15
|
|
16
16
|
// IsValid performs basic validations on the event data.
|
17
|
-
func (e Event) IsValid()
|
17
|
+
func (e Event) IsValid() error {
|
18
18
|
// FIXME(auxesis): provide validation errors for each failure
|
19
|
-
if len(e.Entity)
|
20
|
-
|
21
|
-
|
22
|
-
if len(e.
|
19
|
+
if len(e.Entity) == 0 {
|
20
|
+
return errors.New("no entity")
|
21
|
+
}
|
22
|
+
if len(e.Check) == 0 {
|
23
|
+
return errors.New("no check")
|
24
|
+
}
|
25
|
+
if len(e.State) == 0 {
|
26
|
+
return errors.New("no state")
|
27
|
+
}
|
28
|
+
if len(e.Summary) == 0 {
|
29
|
+
return errors.New("no summary")
|
30
|
+
}
|
23
31
|
return nil
|
24
32
|
}
|
25
|
-
|
data/src/flapjack/event_test.go
CHANGED
@@ -13,10 +13,10 @@ func TestValidationFails(t *testing.T) {
|
|
13
13
|
|
14
14
|
func TestValidationPasses(t *testing.T) {
|
15
15
|
event := Event{
|
16
|
-
Entity:
|
17
|
-
Check:
|
18
|
-
State:
|
19
|
-
Summary:
|
16
|
+
Entity: "hello",
|
17
|
+
Check: "world",
|
18
|
+
State: "ok",
|
19
|
+
Summary: "hello world",
|
20
20
|
}
|
21
21
|
err := event.IsValid()
|
22
22
|
|
data/src/flapjack/transport.go
CHANGED
@@ -7,13 +7,13 @@ import (
|
|
7
7
|
|
8
8
|
// Transport is a representation of a Redis connection.
|
9
9
|
type Transport struct {
|
10
|
-
Address
|
11
|
-
Database
|
12
|
-
Connection
|
10
|
+
Address string
|
11
|
+
Database int
|
12
|
+
Connection redis.Conn
|
13
13
|
}
|
14
14
|
|
15
15
|
// Dial establishes a connection to Redis, wrapped in a Transport.
|
16
|
-
func Dial(address string, database int) (Transport,error) {
|
16
|
+
func Dial(address string, database int) (Transport, error) {
|
17
17
|
// Connect to Redis
|
18
18
|
conn, err := redis.Dial("tcp", address)
|
19
19
|
if err != nil {
|
@@ -24,9 +24,9 @@ func Dial(address string, database int) (Transport,error) {
|
|
24
24
|
conn.Do("SELECT", database)
|
25
25
|
|
26
26
|
transport := Transport{
|
27
|
-
Address:
|
28
|
-
Database:
|
29
|
-
Connection:
|
27
|
+
Address: address,
|
28
|
+
Database: database,
|
29
|
+
Connection: conn,
|
30
30
|
}
|
31
31
|
return transport, nil
|
32
32
|
}
|
@@ -46,4 +46,3 @@ func (t Transport) Send(event Event) (interface{}, error) {
|
|
46
46
|
return nil, err
|
47
47
|
}
|
48
48
|
}
|
49
|
-
|
metadata
CHANGED
@@ -1,16 +1,17 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: flapjack
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.0.
|
4
|
+
version: 1.0.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Lindsay Holmwood
|
8
8
|
- Jesse Reynolds
|
9
9
|
- Ali Graham
|
10
|
+
- Sarah Kowalik
|
10
11
|
autorequire:
|
11
12
|
bindir: bin
|
12
13
|
cert_chain: []
|
13
|
-
date: 2014-08-
|
14
|
+
date: 2014-08-21 00:00:00.000000000 Z
|
14
15
|
dependencies:
|
15
16
|
- !ruby/object:Gem::Dependency
|
16
17
|
name: dante
|
@@ -624,9 +625,9 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
624
625
|
version: '0'
|
625
626
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
626
627
|
requirements:
|
627
|
-
- - "
|
628
|
+
- - ">="
|
628
629
|
- !ruby/object:Gem::Version
|
629
|
-
version:
|
630
|
+
version: '0'
|
630
631
|
requirements: []
|
631
632
|
rubyforge_project:
|
632
633
|
rubygems_version: 2.2.2
|