From d462602d45974b978644b662f43b7921d69f726e Mon Sep 17 00:00:00 2001 From: oliveromahony Date: Fri, 9 Jun 2023 14:24:49 +0100 Subject: [PATCH] fixed deps and linting --- src/core/nginx.go | 4 ++-- .../github.com/nginx/agent/v2/src/core/nginx.go | 14 ++++++++++---- 2 files changed, 12 insertions(+), 6 deletions(-) diff --git a/src/core/nginx.go b/src/core/nginx.go index a2def230ef..dac9c70c8a 100644 --- a/src/core/nginx.go +++ b/src/core/nginx.go @@ -810,7 +810,7 @@ func runtimeFromConfigure(configure []string) []string { // AccessLogs returns a list of access logs in the config func AccessLogs(p *proto.NginxConfig) map[string]string { var found = make(map[string]string) - var name := "" + name := "" for _, accessLog := range p.GetAccessLogs().GetAccessLog() { name = strings.Split(accessLog.GetName(), " ")[0] @@ -830,7 +830,7 @@ func AccessLogs(p *proto.NginxConfig) map[string]string { // ErrorLogs returns a list of error logs in the config func ErrorLogs(p *proto.NginxConfig) map[string]string { var found = make(map[string]string) - var name := "" + name := "" for _, errorLog := range p.GetErrorLogs().GetErrorLog() { name = strings.Split(errorLog.GetName(), " ")[0] diff --git a/test/performance/vendor/github.com/nginx/agent/v2/src/core/nginx.go b/test/performance/vendor/github.com/nginx/agent/v2/src/core/nginx.go index 41a879b842..dac9c70c8a 100644 --- a/test/performance/vendor/github.com/nginx/agent/v2/src/core/nginx.go +++ b/test/performance/vendor/github.com/nginx/agent/v2/src/core/nginx.go @@ -810,13 +810,16 @@ func runtimeFromConfigure(configure []string) []string { // AccessLogs returns a list of access logs in the config func AccessLogs(p *proto.NginxConfig) map[string]string { var found = make(map[string]string) + name := "" + for _, accessLog := range p.GetAccessLogs().GetAccessLog() { + name = strings.Split(accessLog.GetName(), " ")[0] + // check if the access log is readable or not if accessLog.GetReadable() && accessLog.GetName() != "off" { - name := strings.Split(accessLog.GetName(), " ")[0] format := accessLog.GetFormat() found[name] = format - } else { + } else if(!strings.Contains(name, "syslog:")){ log.Warnf("NGINX Access log %s is not readable or is disabled. Please make it readable and enabled in order for NGINX metrics to be collected.", accessLog.GetName()) } } @@ -827,13 +830,16 @@ func AccessLogs(p *proto.NginxConfig) map[string]string { // ErrorLogs returns a list of error logs in the config func ErrorLogs(p *proto.NginxConfig) map[string]string { var found = make(map[string]string) + name := "" + for _, errorLog := range p.GetErrorLogs().GetErrorLog() { + name = strings.Split(errorLog.GetName(), " ")[0] + // check if the error log is readable or not if errorLog.GetReadable() { - name := strings.Split(errorLog.GetName(), " ")[0] // In the future, different error log formats will be supported found[name] = "" - } else { + } else if(!strings.Contains(name, "syslog:")){ log.Warnf("NGINX Error log %s is not readable or is disabled. Please make it readable and enabled in order for NGINX metrics to be collected.", errorLog.GetName()) } }