From ca85fcb43e286131434cefeef1454df1bf7e8edb Mon Sep 17 00:00:00 2001 From: ibrahimkk-moideen Date: Tue, 23 Apr 2024 09:50:25 -0400 Subject: [PATCH 1/4] fix types and update readme --- README.md | 10 +++++----- cmd/fishymetrics/main.go | 24 ++++++++++++++++++++---- 2 files changed, 25 insertions(+), 9 deletions(-) diff --git a/README.md b/README.md index 83aac47..2a83b98 100644 --- a/README.md +++ b/README.md @@ -27,9 +27,9 @@ Flags: alternative method for logging in addition to stdout --log.file-path="/var/log/fishymetrics" directory path where log files are written if log-method is file - --log.file-max-size=256 max file size in megabytes if log-method is file - --log.file-max-backups=1 max file backups before they are rotated if log-method is file - --log.file-max-age=1 max file age in days before they are rotated if log-method is file + --log.file-max-size="256" max file size in megabytes if log-method is file + --log.file-max-backups="1" max file backups before they are rotated if log-method is file + --log.file-max-age="1" max file age in days before they are rotated if log-method is file --vector.endpoint="http://0.0.0.0:4444" vector endpoint to send structured json logs to --port="9533" exporter port @@ -37,7 +37,7 @@ Flags: Vault instance address to get chassis credentials from --vault.role-id="" Vault Role ID for AppRole --vault.secret-id="" Vault Secret ID for AppRole - --collector.drives.module-exclude="" + --collector.drives.modules-exclude="" regex of drive module(s) to exclude from the scrape --credentials.profiles=CREDENTIALS.PROFILES profile(s) with all necessary parameters to obtain BMC credential from secrets backend, i.e. @@ -82,7 +82,7 @@ Since some hosts can contain many dozens of drives, this can cause a scrape to t Example: ```bash ---collector.drives.module-exclude="(?i)(FlexUtil|(SBMezz|IOEMezz)[0-9]+)" +--collector.drives.modules-exclude="(?i)(FlexUtil|(SBMezz|IOEMezz)[0-9]+)" ``` | Collector | Scope | Include Flag | Exclude Flag | diff --git a/cmd/fishymetrics/main.go b/cmd/fishymetrics/main.go index 636e37d..13fde6e 100644 --- a/cmd/fishymetrics/main.go +++ b/cmd/fishymetrics/main.go @@ -27,6 +27,7 @@ import ( "os" "os/signal" "regexp" + "strconv" "strings" "sync" "syscall" @@ -195,7 +196,7 @@ func main() { _, err = a.Parse(os.Args[1:]) if err != nil { - panic(fmt.Errorf("Error parsing argument flags - %s", err.Error())) + panic(fmt.Errorf("error parsing argument flags - %s", err.Error())) } // populate excludes map @@ -215,15 +216,30 @@ func main() { } } + logfilemax_size, err := strconv.Atoi(*logFileMaxSize) + if err != nil { + panic(fmt.Errorf("error converting type - %s", err.Error())) + } + + logfilemax_backups, err := strconv.Atoi(*logFileMaxBackups) + if err != nil { + panic(fmt.Errorf("error converting type - %s", err.Error())) + } + + logfilemax_age, err := strconv.Atoi(*logFileMaxAge) + if err != nil { + panic(fmt.Errorf("error converting type - %s", err.Error())) + } + // init logger config logConfig := logger.LoggerConfig{ LogLevel: *logLevel, LogMethod: *logMethod, LogFile: logger.LogFile{ Path: *logFilePath, - MaxSize: *logFileMaxSize, - MaxBackups: *logFileMaxBackups, - MaxAge: *logFileMaxAge, + MaxSize: logfilemax_size, + MaxBackups: logfilemax_backups, + MaxAge: logfilemax_age, }, VectorEndpoint: *vectorEndpoint, } From 4704fb761120bf99cb0e761a84a897b421e8d405 Mon Sep 17 00:00:00 2001 From: ibrahimkk-moideen Date: Tue, 23 Apr 2024 09:56:00 -0400 Subject: [PATCH 2/4] update variable names --- cmd/fishymetrics/main.go | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/cmd/fishymetrics/main.go b/cmd/fishymetrics/main.go index 13fde6e..1edec32 100644 --- a/cmd/fishymetrics/main.go +++ b/cmd/fishymetrics/main.go @@ -216,17 +216,17 @@ func main() { } } - logfilemax_size, err := strconv.Atoi(*logFileMaxSize) + logfileMaxSize, err := strconv.Atoi(*logFileMaxSize) if err != nil { panic(fmt.Errorf("error converting type - %s", err.Error())) } - logfilemax_backups, err := strconv.Atoi(*logFileMaxBackups) + logfileMaxBackups, err := strconv.Atoi(*logFileMaxBackups) if err != nil { panic(fmt.Errorf("error converting type - %s", err.Error())) } - logfilemax_age, err := strconv.Atoi(*logFileMaxAge) + logfileMaxAge, err := strconv.Atoi(*logFileMaxAge) if err != nil { panic(fmt.Errorf("error converting type - %s", err.Error())) } @@ -237,9 +237,9 @@ func main() { LogMethod: *logMethod, LogFile: logger.LogFile{ Path: *logFilePath, - MaxSize: logfilemax_size, - MaxBackups: logfilemax_backups, - MaxAge: logfilemax_age, + MaxSize: logfileMaxSize, + MaxBackups: logfileMaxBackups, + MaxAge: logfileMaxAge, }, VectorEndpoint: *vectorEndpoint, } From b98155a83de9be6ccfb56d304a144263c216e4aa Mon Sep 17 00:00:00 2001 From: ibrahimkk-moideen Date: Tue, 23 Apr 2024 10:18:04 -0400 Subject: [PATCH 3/4] update error message in logfile attributes conversion --- cmd/fishymetrics/main.go | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/cmd/fishymetrics/main.go b/cmd/fishymetrics/main.go index 1edec32..81a1f5a 100644 --- a/cmd/fishymetrics/main.go +++ b/cmd/fishymetrics/main.go @@ -218,17 +218,17 @@ func main() { logfileMaxSize, err := strconv.Atoi(*logFileMaxSize) if err != nil { - panic(fmt.Errorf("error converting type - %s", err.Error())) + panic(fmt.Errorf("error converting type of logFileMaxSize to integer - %s", err.Error())) } logfileMaxBackups, err := strconv.Atoi(*logFileMaxBackups) if err != nil { - panic(fmt.Errorf("error converting type - %s", err.Error())) + panic(fmt.Errorf("error converting type of logFileMaxBackups to integer - %s", err.Error())) } logfileMaxAge, err := strconv.Atoi(*logFileMaxAge) if err != nil { - panic(fmt.Errorf("error converting type - %s", err.Error())) + panic(fmt.Errorf("error converting type of logFileMaxAge to integer - %s", err.Error())) } // init logger config From 2ca09a5778483db343d7f5bd84c6db87f305e4af Mon Sep 17 00:00:00 2001 From: ibrahimkk-moideen Date: Tue, 23 Apr 2024 10:34:50 -0400 Subject: [PATCH 4/4] error msg in logfile attrib conversion to include flags --- cmd/fishymetrics/main.go | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/cmd/fishymetrics/main.go b/cmd/fishymetrics/main.go index 81a1f5a..8db9bf0 100644 --- a/cmd/fishymetrics/main.go +++ b/cmd/fishymetrics/main.go @@ -218,17 +218,17 @@ func main() { logfileMaxSize, err := strconv.Atoi(*logFileMaxSize) if err != nil { - panic(fmt.Errorf("error converting type of logFileMaxSize to integer - %s", err.Error())) + panic(fmt.Errorf("error converting arg --log.file-max-size to int - %s", err.Error())) } logfileMaxBackups, err := strconv.Atoi(*logFileMaxBackups) if err != nil { - panic(fmt.Errorf("error converting type of logFileMaxBackups to integer - %s", err.Error())) + panic(fmt.Errorf("error converting arg --log.file-max-backups to int - %s", err.Error())) } logfileMaxAge, err := strconv.Atoi(*logFileMaxAge) if err != nil { - panic(fmt.Errorf("error converting type of logFileMaxAge to integer - %s", err.Error())) + panic(fmt.Errorf("error converting arg --log.file-max-age to int - %s", err.Error())) } // init logger config