-
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.
- Loading branch information
1 parent
493f214
commit 45dd6b7
Showing
6 changed files
with
128 additions
and
42 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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -42,6 +42,6 @@ linters: | |
linters-settings: | ||
funlen: | ||
ignore-comments: true | ||
lines: 75 | ||
lines: 80 | ||
nestif: | ||
min-complexity: 5 |
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,37 @@ | ||
package metrics | ||
|
||
import ( | ||
"github.com/NETWAYS/support-collector/internal/obfuscate" | ||
"os" | ||
"strings" | ||
"time" | ||
) | ||
|
||
type Metrics struct { | ||
Command string `json:"command"` | ||
Version string `json:"version"` | ||
Timings map[string]time.Duration `json:"timings"` | ||
} | ||
|
||
// New creates new Metrics | ||
func New(version string) (m *Metrics) { | ||
return &Metrics{ | ||
Command: getCommand(), | ||
Version: version, | ||
Timings: make(map[string]time.Duration), | ||
} | ||
} | ||
|
||
// getCommand returns the executed command and obfusactes *--icinga2* arguments | ||
func getCommand() string { | ||
args := os.Args | ||
|
||
// Obfuscate icinga 2 api user and password | ||
for i, arg := range args { | ||
if strings.Contains(arg, "--icinga2") && i+1 < len(args) { | ||
args[i+1] = obfuscate.Replacement | ||
} | ||
} | ||
|
||
return strings.Join(args, " ") | ||
} |
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