diff --git a/Makefile b/Makefile index 201028c05..dd9c5851c 100644 --- a/Makefile +++ b/Makefile @@ -92,7 +92,7 @@ local-deb-package: ## Create local deb package local-rpm-package: ## Create local rpm package GOWORK=off CGO_ENABLED=0 GOARCH=${LOCAL_ARCH} GOOS=linux go build -ldflags=${DEBUG_LDFLAGS} -o ./build/nginx-agent - VERSION=$(shell echo ${VERSION} | tr -d 'v') nfpm pkg --config ./scripts/.local-nfpm.yaml --packager rpm --target ./build/${PACKAGE_PREFIX}-$(shell echo ${VERSION} | tr -d 'v')-SNAPSHOT.rpm; + VERSION=$(shell echo ${VERSION} | tr -d 'v') nfpm pkg --config ./scripts/.local-nfpm.yaml --packager rpm --target ./build/${PACKAGE_PREFIX}-$(shell echo ${VERSION} | tr -d 'v')-SNAPSHOT-${COMMIT}.rpm; local-txz-package: ## Create local txz package GOWORK=off CGO_ENABLED=0 GOARCH=${LOCAL_ARCH} GOOS=freebsd go build -ldflags=${DEBUG_LDFLAGS} -o ./build/nginx-agent diff --git a/scripts/packages/packager/local-entrypoint.sh b/scripts/packages/packager/local-entrypoint.sh index d5c96299a..1eda52836 100644 --- a/scripts/packages/packager/local-entrypoint.sh +++ b/scripts/packages/packager/local-entrypoint.sh @@ -19,7 +19,7 @@ cp build/nginx-agent /staging/usr/local/bin chmod +x /staging/usr/local/etc/rc.d/nginx-agent -VERSION="$(git describe --match 'v[0-9]*' --abbrev=0 | tr -d 'v')-SNAPSHOT" envsubst < scripts/packages/manifest > /staging/+MANIFEST +VERSION="$(git describe --match 'v[0-9]*' --abbrev=0 | tr -d 'v')-SNAPSHOT-$(git rev-parse --short HEAD)" envsubst < scripts/packages/manifest > /staging/+MANIFEST pkg -o ABI="FreeBSD:13:amd64" create --format txz \ -m /staging \ @@ -31,7 +31,7 @@ pkg -o ABI="FreeBSD:13:amd64" create --format txz \ # but since version 1.17.0 pkg will now always create a file with the extesion pkg no matter what the format is. # See 1.17.0 release notes for more info: https://cgit.freebsd.org/ports/commit/?id=e497a16a286972bfcab908209b11ee6a13d99dc9 cd build/ -ln -s nginx-agent-"$(git describe --match 'v[0-9]*' --abbrev=0 | tr -d 'v')"-SNAPSHOT.pkg nginx-agent-"$(git describe --match 'v[0-9]*' --abbrev=0 | tr -d 'v')"-SNAPSHOT.txz +ln -s nginx-agent-"$(git describe --match 'v[0-9]*' --abbrev=0 | tr -d 'v')"-SNAPSHOT-"$(git rev-parse --short HEAD)".pkg nginx-agent-"$(git describe --match 'v[0-9]*' --abbrev=0 | tr -d 'v')"-SNAPSHOT-"$(git rev-parse --short HEAD)".txz cd .. rm -rf /staging diff --git a/src/core/metrics/sources/swap.go b/src/core/metrics/sources/swap.go index 8e6f0ea8c..fb6ac39d8 100644 --- a/src/core/metrics/sources/swap.go +++ b/src/core/metrics/sources/swap.go @@ -27,6 +27,15 @@ func NewSwapSource(namespace string, env core.Environment) *Swap { statFunc = cgroupSwapSource.SwapMemoryStat } + // Verify if swap metrics can be collected on startup + _, err := statFunc() + if err != nil { + if e, ok := err.(*os.PathError); ok { + log.Warnf("Unable to collect Swap metrics because the file %v was not found", e.Path) + } + log.Warnf("Unable to collect Swap metrics: %v", err) + } + return &Swap{&namedMetric{namespace, "swap"}, statFunc} } @@ -35,10 +44,10 @@ func (c *Swap) Collect(ctx context.Context, wg *sync.WaitGroup, m chan<- *proto. swapStats, err := c.statFunc() if err != nil { if e, ok := err.(*os.PathError); ok { - log.Warnf("Unable to collect Swap metrics because the file %v was not found", e.Path) + log.Debugf("Unable to collect Swap metrics because the file %v was not found", e.Path) return } - log.Errorf("Failed to collect Swap metrics: %v", err) + log.Debugf("Unable to collect Swap metrics: %v", err) return } diff --git a/test/performance/vendor/github.com/nginx/agent/v2/src/core/metrics/sources/swap.go b/test/performance/vendor/github.com/nginx/agent/v2/src/core/metrics/sources/swap.go index 8e6f0ea8c..fb6ac39d8 100644 --- a/test/performance/vendor/github.com/nginx/agent/v2/src/core/metrics/sources/swap.go +++ b/test/performance/vendor/github.com/nginx/agent/v2/src/core/metrics/sources/swap.go @@ -27,6 +27,15 @@ func NewSwapSource(namespace string, env core.Environment) *Swap { statFunc = cgroupSwapSource.SwapMemoryStat } + // Verify if swap metrics can be collected on startup + _, err := statFunc() + if err != nil { + if e, ok := err.(*os.PathError); ok { + log.Warnf("Unable to collect Swap metrics because the file %v was not found", e.Path) + } + log.Warnf("Unable to collect Swap metrics: %v", err) + } + return &Swap{&namedMetric{namespace, "swap"}, statFunc} } @@ -35,10 +44,10 @@ func (c *Swap) Collect(ctx context.Context, wg *sync.WaitGroup, m chan<- *proto. swapStats, err := c.statFunc() if err != nil { if e, ok := err.(*os.PathError); ok { - log.Warnf("Unable to collect Swap metrics because the file %v was not found", e.Path) + log.Debugf("Unable to collect Swap metrics because the file %v was not found", e.Path) return } - log.Errorf("Failed to collect Swap metrics: %v", err) + log.Debugf("Unable to collect Swap metrics: %v", err) return } diff --git a/test/performance/vendor/github.com/nginx/agent/v2/src/extensions/nginx-app-protect/monitoring/processor/nap.go b/test/performance/vendor/github.com/nginx/agent/v2/src/extensions/nginx-app-protect/monitoring/processor/nap.go index 6d824f1ba..ea34ce712 100644 --- a/test/performance/vendor/github.com/nginx/agent/v2/src/extensions/nginx-app-protect/monitoring/processor/nap.go +++ b/test/performance/vendor/github.com/nginx/agent/v2/src/extensions/nginx-app-protect/monitoring/processor/nap.go @@ -460,7 +460,7 @@ func setValue(napConfig *NAPConfig, key, value string, logger *logrus.Entry) err case requestStatus: napConfig.RequestStatus = value case severity: - napConfig.Severity = value + napConfig.Severity = strings.ToLower(value) case sigSetNames: napConfig.SigSetNames = replaceEncodedList(value, listSeperator) case threatCampaignNames: