Skip to content

Commit

Permalink
metrics: allow passing explicit port-num
Browse files Browse the repository at this point in the history
Allow running exporter with explicit port-number. If input port-number
is non positive, use default port-number.

Signed-off-by: Shachar Sharon <[email protected]>
  • Loading branch information
synarete committed Jul 7, 2024
1 parent c7b9c39 commit 2c9b0ad
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 3 deletions.
2 changes: 1 addition & 1 deletion cmd/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ func main() {
}
log.Info("Located smbstatus", "path", loc, "version", ver)

err = metrics.RunSmbMetricsExporter(log)
err = metrics.RunSmbMetricsExporter(log, metrics.DefaultMetricsPort)
if err != nil {
os.Exit(1)
}
Expand Down
7 changes: 5 additions & 2 deletions internal/metrics/exporter.go
Original file line number Diff line number Diff line change
Expand Up @@ -63,8 +63,11 @@ func (sme *smbMetricsExporter) serve() error {

// RunSmbMetricsExporter executes an HTTP server and exports SMB metrics to
// Prometheus.
func RunSmbMetricsExporter(log logr.Logger) error {
sme := newSmbMetricsExporter(log, DefaultMetricsPort)
func RunSmbMetricsExporter(log logr.Logger, port int) error {
if port <= 0 {
port = DefaultMetricsPort
}
sme := newSmbMetricsExporter(log, port)
err := sme.init()
if err != nil {
return err
Expand Down

0 comments on commit 2c9b0ad

Please sign in to comment.