Created
March 24, 2021 20:42
-
-
Save traetox/4c0fcb23f9f101455f61688cda8edbd1 to your computer and use it in GitHub Desktop.
Simple application to test the status of a Gravwell indexer.
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
// TO BUILD execute the following: | |
// go mod init indexerstatus | |
// CGO_ENABLED=0 go build | |
package main | |
import ( | |
"flag" | |
"log" | |
"github.com/gravwell/gravwell/v3/ingest" | |
) | |
var ( | |
tags = []string{`default`} //tags to use during authentication | |
) | |
var ( | |
fClear = flag.String("clear-conn", "", "Target IP:Port for indexer cleartext ingest listener") | |
fTls = flag.String("tls-conn", "", "Target IP:Port for indexer TLS ingest listener") | |
fPipe = flag.String("pipe-conn", "", "Target IP:Port for indexer TLS ingest listener") | |
fTlsNoValidate = flag.Bool("tls-no-validate", false, "Do not validate TLS certificates") | |
fSecret = flag.String("ingest-secret", "", "Ingest-Secret authentication token") | |
) | |
func main() { | |
flag.Parse() | |
if *fClear == `` && *fTls == `` && *fPipe == `` { | |
log.Fatal("missing ingester targets, provide clear-conn or tls-conn") | |
} else if *fSecret == `` { | |
log.Fatal("missing ingest-secret") | |
} | |
ah, err := ingest.GenAuthHash(*fSecret) | |
if err != nil { | |
log.Fatalf("Failed to generate authentication hash: %v\n", err) | |
} | |
//validate each that is set (TCP, TLS, named pipe) | |
if *fClear != `` { | |
if ic, err := ingest.NewTCPConnection(*fClear, ah, tags); err != nil { | |
log.Fatalf("Failed TCP connection to %v: %v\n", *fClear, err) | |
} else if err = ic.Close(); err != nil { | |
log.Fatalf("Failed to close TCP connection to %v: %v\n", *fClear, err) | |
} | |
} | |
if *fTls != `` { | |
if ic, err := ingest.NewTLSConnection(*fTls, ah, nil, !*fTlsNoValidate, tags); err != nil { | |
log.Fatalf("Failed TLS connection to %v: %v\n", *fTls, err) | |
} else if err = ic.Close(); err != nil { | |
log.Fatalf("Failed to close TLS connection to %v: %v\n", *fTls, err) | |
} | |
} | |
if *fPipe != `` { | |
if ic, err := ingest.NewPipeConnection(*fPipe, ah, tags); err != nil { | |
log.Fatalf("Failed Named Pipe connection to %v: %v\n", *fPipe, err) | |
} else if err = ic.Close(); err != nil { | |
log.Fatalf("Failed to close Named Pipe connection to %v: %v\n", *fPipe, err) | |
} | |
} | |
//all good | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment