Skip to content

Commit

Permalink
finish exporter exporter
Browse files Browse the repository at this point in the history
  • Loading branch information
sni committed Oct 22, 2023
1 parent 4c718a2 commit 49aa485
Show file tree
Hide file tree
Showing 7 changed files with 504 additions and 23 deletions.
2 changes: 1 addition & 1 deletion .golangci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ linters-settings:
min-len: 8
min-occurrences: 12
lll:
line-length: 165
line-length: 170
funlen:
lines: 80
gomoddirectives:
Expand Down
14 changes: 14 additions & 0 deletions docs/exporterexporter/_index.md
Original file line number Diff line number Diff line change
Expand Up @@ -42,3 +42,17 @@ exporter_modules/http.yaml:
http:
port: 9100
path: '/metrics'

## Incompatibilities

### No Verification

This module basically works the same as the standalone exporter exporter, except
it does not implement verification. Files and requests are passed through as is
and not checked if it contains valid prometheus metrics.

### Changed Index Path

Since this exporter exporter (optionally) shares the web server with the rest of
the SNClient+, the `/` url path is in use already. The available exporter
modules can therefore be requested with the `/list` path.
3 changes: 3 additions & 0 deletions packaging/snclient.ini
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,9 @@ url prefix = /
; modules dir - set folder with yaml module definitions
modules dir = ${shared-path}/exporter_modules

; default module - set default module if no specific module is requested
default module =

; use default web attributes here, ex.: password, allowed hosts, certificates, etc...


Expand Down
4 changes: 2 additions & 2 deletions pkg/snclient/check_service_linux.go
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ func (l *CheckService) Check(ctx context.Context, snc *Agent, check *CheckData,
l.snc = snc

if len(l.services) == 0 || slices.Contains(l.services, "*") {
output, stderr, _, _, err := snc.runExternalCommand(ctx, "systemctl --type=service --plain --no-pager --quiet", systemctlTimeout)
output, stderr, _, _, err := snc.runExternalCommandString(ctx, "systemctl --type=service --plain --no-pager --quiet", systemctlTimeout)
if err != nil {
return &CheckResult{
State: CheckExitUnknown,
Expand Down Expand Up @@ -118,7 +118,7 @@ func (l *CheckService) Check(ctx context.Context, snc *Agent, check *CheckData,
}

func (l *CheckService) addService(ctx context.Context, check *CheckData, service string, services, excludes []string) error {
output, stderr, _, _, err := l.snc.runExternalCommand(ctx, fmt.Sprintf("systemctl status %s.service", service), systemctlTimeout)
output, stderr, _, _, err := l.snc.runExternalCommandString(ctx, fmt.Sprintf("systemctl status %s.service", service), systemctlTimeout)
if err != nil {
return fmt.Errorf("systemctl failed: %s\n%s", err.Error(), stderr)
}
Expand Down
2 changes: 1 addition & 1 deletion pkg/snclient/check_wrap.go
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ func (l *CheckWrap) Check(ctx context.Context, snc *Agent, check *CheckData, _ [
timeoutSeconds = 60
}

stdout, stderr, exitCode, procState, err := l.snc.runExternalCommand(ctx, command, timeoutSeconds)
stdout, stderr, exitCode, procState, err := l.snc.runExternalCommandString(ctx, command, timeoutSeconds)
if err != nil {
exitCode = CheckExitUnknown
switch {
Expand Down
Loading

0 comments on commit 49aa485

Please sign in to comment.