Skip to content

Commit

Permalink
output metrics in influxdb line protocol
Browse files Browse the repository at this point in the history
  • Loading branch information
danielb42 committed Aug 5, 2020
1 parent 1db6b44 commit c481e51
Show file tree
Hide file tree
Showing 7 changed files with 16 additions and 10 deletions.
Binary file removed artifacts/sensu-tcp-check_v1.0.2_linux_amd64.tar.gz
Binary file not shown.
1 change: 0 additions & 1 deletion artifacts/sensu-tcp-check_v1.0.2_sha512_checksums.txt

This file was deleted.

Binary file not shown.
1 change: 1 addition & 0 deletions artifacts/sensu-tcp-check_v2.0.0_sha512_checksums.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
25cb9ce78ef4267d046a3da91bce813d01c1d4cc84ad3c0ca7214707a1515dcac634d085e9c3effd483132754076d0fae9683598cedd9a87a85bb96453e56ebc sensu-tcp-check_v2.0.0_linux_amd64.tar.gz
Binary file modified bin/sensu-tcp-check
Binary file not shown.
20 changes: 13 additions & 7 deletions cmd/sensu-tcp-check/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,18 +11,21 @@ import (
func main() {
log.SetOutput(os.Stderr)

if len(os.Args) == 1 {
println("usage: sensu-tcp-check <host>:<port>")
if len(os.Args) != 3 {
println("usage: sensu-tcp-check <metricprefix> <host:port>")
os.Exit(2)
}

timeBegin := time.Now()

conn, err := net.DialTimeout("tcp", os.Args[1], 10*time.Second)
conn, err := net.DialTimeout("tcp", os.Args[2], 10*time.Second)
if err != nil {
log.Printf("ERROR: %s\n\n", err.Error())
fmt.Printf("%s %d %d\n", "sensu.tcp.available", 0, timeBegin.Unix())
fmt.Printf("%s %d %d\n", "sensu.tcp.duration", 0, timeBegin.Unix())
fmt.Printf("%s,check=tcp %s=%d,%s=%d %d\n",
os.Args[1],
"available", 0,
"duration", 0,
timeBegin.Unix())

if conn != nil {
conn.Close()
Expand All @@ -34,8 +37,11 @@ func main() {
responseTime := time.Since(timeBegin).Milliseconds()

log.Printf("OK\n\n")
fmt.Printf("%s %d %d\n", "sensu.tcp.available", 1, timeBegin.Unix())
fmt.Printf("%s %d %d\n", "sensu.tcp.duration", responseTime, timeBegin.Unix())
fmt.Printf("%s,check=tcp %s=%d,%s=%d %d\n",
os.Args[1],
"available", 1,
"duration", responseTime,
timeBegin.Unix())

_ = conn.Close()

Expand Down
4 changes: 2 additions & 2 deletions sensu/asset.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3,5 +3,5 @@ api_version: core/v2
metadata:
name: sensu-tcp-check
spec:
sha512: 9247312038a5e2b7f3294b6e3e6d70ead5b072b9bf6c521416a2c92c24489395a34fa4fd47712719966381c9a5c55cf013109bd8ffeda86fe152ea91a97e5e45
url: https://github.com/DENICeG/sensu-tcp-check/releases/download/v1.0.2/sensu-tcp-check_v1.0.2_linux_amd64.tar.gz
sha512: 25cb9ce78ef4267d046a3da91bce813d01c1d4cc84ad3c0ca7214707a1515dcac634d085e9c3effd483132754076d0fae9683598cedd9a87a85bb96453e56ebc
url: https://github.com/DENICeG/sensu-tcp-check/releases/download/v2.0.0/sensu-tcp-check_v2.0.0_linux_amd64.tar.gz

0 comments on commit c481e51

Please sign in to comment.