diff options
| author | Paul Buetow <paul@buetow.org> | 2021-10-06 10:55:50 +0300 |
|---|---|---|
| committer | Paul Buetow <paul@buetow.org> | 2021-10-06 10:55:50 +0300 |
| commit | 7306afe9ab073c424ddca0ddc57950f237948118 (patch) | |
| tree | 063c7181425f0657ec97e415c0224d311bafe6c5 /internal/clients/healthclient.go | |
| parent | fab5dc3e70434ea0abc7a0976487a1973b662331 (diff) | |
move health check to separate client binary
Diffstat (limited to 'internal/clients/healthclient.go')
| -rw-r--r-- | internal/clients/healthclient.go | 29 |
1 files changed, 29 insertions, 0 deletions
diff --git a/internal/clients/healthclient.go b/internal/clients/healthclient.go index e2c8ccb..ac1dc20 100644 --- a/internal/clients/healthclient.go +++ b/internal/clients/healthclient.go @@ -1,6 +1,8 @@ package clients import ( + "context" + "fmt" "runtime" "github.com/mimecast/dtail/internal/clients/handlers" @@ -42,3 +44,30 @@ func (c HealthClient) makeCommands() (commands []string) { commands = append(commands, "health") return } + +func (c *HealthClient) Start(ctx context.Context, statsCh <-chan string) int { + status := c.baseClient.Start(ctx, statsCh) + + switch status { + case 0: + if c.Serverless { + fmt.Printf("WARNING: All seems fine but the check only run in serverless mode, please specify a remote server via --server hostname:port\n") + return 1 + } + fmt.Printf("OK: All fine at %s :-)\n", c.ServersStr) + case 2: + if c.Serverless { + fmt.Printf("CRITICAL: DTail server not operating properly (using serverless connction)!\n") + return 2 + } + fmt.Printf("CRITICAL: DTail server not operating properly at %s!\n", c.ServersStr) + default: + if c.Serverless { + fmt.Printf("UNKNOWN: Received unknown status code %d (using serverless connection)\n", status) + return status + } + fmt.Printf("UNKNOWN: Received unknown status code %d from %s!\n", status, c.ServersStr) + } + + return status +} |
