forked from influxdata/kapacitor
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'master' into feature/jsonpipe
- Loading branch information
Showing
43 changed files
with
1,062 additions
and
333 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -87,7 +87,7 @@ But instead of cloning the main repo, instead clone your fork. Follow the steps | |
export GOPATH=$HOME/go | ||
mkdir -p $GOPATH/src/github.com/influxdata | ||
cd $GOPATH/src/github.com/influxdata | ||
git clone [email protected]:<username>/kapacitor | ||
git clone [email protected]:<username>/kapacitor.git | ||
|
||
Retaining the directory structure `$GOPATH/src/github.com/influxdata` is necessary so that Go imports work correctly. | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,70 @@ | ||
package run_test | ||
|
||
import ( | ||
"bytes" | ||
"io/ioutil" | ||
"os" | ||
"path/filepath" | ||
"testing" | ||
"text/template" | ||
"time" | ||
|
||
"fmt" | ||
|
||
"github.com/influxdata/kapacitor/cmd/kapacitord/run" | ||
) | ||
|
||
func TestCommand_PIDFile(t *testing.T) { | ||
tmpdir, err := ioutil.TempDir(os.TempDir(), "kapacitord-test") | ||
if err != nil { | ||
t.Fatal(err) | ||
} | ||
defer os.RemoveAll(tmpdir) | ||
|
||
// Write out a config file that does not attempt to connect to influxdb. | ||
configFile := filepath.Join(tmpdir, "kapacitor.conf") | ||
configTemplate := template.Must(template.New("config_file").Parse(`data_dir = "{{.TempDir}}/data" | ||
[[influxdb]] | ||
enabled = false | ||
[replay] | ||
dir = "{{.TempDir}}/replay" | ||
[storage] | ||
boltdb = "{{.TempDir}}/kapacitor.db" | ||
[task] | ||
dir = "{{.TempDir}}/tasks" | ||
[load] | ||
dir = "{{.TempDir}}/load" | ||
`)) | ||
var buf bytes.Buffer | ||
if err := configTemplate.Execute(&buf, map[string]string{"TempDir": tmpdir}); err != nil { | ||
t.Fatalf("unable to generate config file: %s", err) | ||
} | ||
fmt.Println(buf.String()) | ||
if err := ioutil.WriteFile(configFile, buf.Bytes(), 0600); err != nil { | ||
t.Fatalf("unable to write %s: %s", configFile, err) | ||
} | ||
|
||
pidFile := filepath.Join(tmpdir, "kapacitor.pid") | ||
|
||
cmd := run.NewCommand() | ||
if err := cmd.Run("-config", configFile, "-pidfile", pidFile); err != nil { | ||
t.Fatalf("unexpected error: %s", err) | ||
} | ||
|
||
if _, err := os.Stat(pidFile); err != nil { | ||
t.Fatalf("could not stat pid file: %s", err) | ||
} | ||
go cmd.Close() | ||
|
||
timeout := time.NewTimer(5 * time.Second) | ||
select { | ||
case <-timeout.C: | ||
t.Fatal("unexpected timeout") | ||
case <-cmd.Closed: | ||
timeout.Stop() | ||
} | ||
|
||
if _, err := os.Stat(pidFile); err == nil { | ||
t.Fatal("expected pid file to be removed") | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
dbrp "telegraf"."autogen" | ||
|
||
stream | ||
|from() | ||
.measurement('cpu') | ||
.groupBy(*) | ||
|alert() | ||
.crit(lambda: "usage_user" > 80) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
dbrp "telegraf"."autogen" | ||
|
||
batch | ||
|query('SELECT mean("usage_user") FROM "telegraf"."autogen"."cpu"') | ||
.period(1m) | ||
.every(10s) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
dbrp "telegraf"."autogen" | ||
|
||
stream | ||
|from() | ||
.measurement('cpu') | ||
.groupBy(*) | ||
|combine(lambda: "cpu" == 'cpu-total', lambda: TRUE) | ||
.as('total', 'cpu') |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
dbrp "telegraf"."autogen" | ||
|
||
stream | ||
|from() | ||
.measurement('cpu') | ||
.groupBy(*) | ||
|default() | ||
.tag('sweet_new_tag', 'this_is') | ||
.field('value', 10.9) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
dbrp "telegraf"."autogen" | ||
|
||
stream | ||
|from() | ||
.measurement('cpu') | ||
.groupBy(*) | ||
|delete() | ||
.tag('cpu') | ||
.field('usuage_idle') |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
dbrp "telegraf"."autogen" | ||
|
||
stream | ||
|from() | ||
.measurement('cpu') | ||
|eval(lambda: 100.0 - "usage_idle") | ||
.as('usage_not_idle') |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
dbrp "telegraf"."autogen" | ||
|
||
stream | ||
|from() | ||
.measurement('cpu') | ||
|flatten() | ||
.on('cpu') |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
dbrp "telegraf"."autogen" | ||
|
||
stream | ||
|from() | ||
.measurement('system') | ||
|groupBy(*) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
dbrp "loopback"."autogen" | ||
|
||
stream | ||
|from() | ||
.measurement('system') | ||
.groupBy(*) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
dbrp "telegraf"."autogen" | ||
|
||
stream | ||
|from() | ||
.measurement('system') | ||
|window() | ||
.period(1m) | ||
.every(10s) | ||
|httpOut('data') |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
dbrp "telegraf"."autogen" | ||
|
||
stream | ||
|from() | ||
.measurement('system') | ||
|window() | ||
.period(1m) | ||
.every(10s) | ||
|httpPost('http://localhost:8080/example') |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
dbrp "telegraf"."autogen" | ||
|
||
stream | ||
|from() | ||
.measurement('system') | ||
|window() | ||
.period(1m) | ||
.every(10s) | ||
|mean('load1') | ||
.as('load1') | ||
|influxDBOut() | ||
.database('mydb') | ||
.measurement('derived_system') |
Oops, something went wrong.