@@ -136,6 +136,8 @@ func (npp *NginxProcessParser) getInfo(ctx context.Context, proc *nginxprocess.P
136136 }
137137 }
138138
139+ confPath := getConfPathFromCommand (proc .Cmd )
140+
139141 var nginxInfo * Info
140142
141143 outputBuffer , err := npp .executer .RunCmd (ctx , exePath , "-V" )
@@ -148,6 +150,10 @@ func (npp *NginxProcessParser) getInfo(ctx context.Context, proc *nginxprocess.P
148150 nginxInfo .ExePath = exePath
149151 nginxInfo .ProcessID = proc .PID
150152
153+ if nginxInfo .ConfPath = getNginxConfPath (ctx , nginxInfo ); confPath != "" {
154+ nginxInfo .ConfPath = confPath
155+ }
156+
151157 loadableModules := getLoadableModules (nginxInfo )
152158 nginxInfo .LoadableModules = loadableModules
153159
@@ -268,7 +274,6 @@ func parseNginxVersionCommandOutput(ctx context.Context, output *bytes.Buffer) *
268274 }
269275
270276 nginxInfo .Prefix = getNginxPrefix (ctx , nginxInfo )
271- nginxInfo .ConfPath = getNginxConfPath (ctx , nginxInfo )
272277
273278 return nginxInfo
274279}
@@ -392,3 +397,17 @@ func convertToMap(processes []*nginxprocess.Process) map[int32]*nginxprocess.Pro
392397
393398 return processesByPID
394399}
400+
401+ func getConfPathFromCommand (command string ) string {
402+ commands := strings .Split (command , " " )
403+
404+ for i , command := range commands {
405+ if command == "-c" {
406+ if i < len (commands )- 1 {
407+ return commands [i + 1 ]
408+ }
409+ }
410+ }
411+
412+ return ""
413+ }
0 commit comments