Ver Fonte

Merge pull request #57 from coroot/improve_app_type_detection

enhance application type detection
Nikolay Sivko há 2 anos atrás
pai
commit
7ac7ff14d2
2 ficheiros alterados com 16 adições e 1 exclusões
  1. 15 1
      containers/app.go
  2. 1 0
      containers/container.go

+ 15 - 1
containers/app.go

@@ -2,6 +2,13 @@ package containers
 
 import (
 	"bytes"
+	"regexp"
+)
+
+var (
+	phpCmd    = regexp.MustCompile(`.*php\d*\.?\d*$`)
+	pythonCmd = regexp.MustCompile(`.*python\d*\.?\d*$`)
+	nodejsCmd = regexp.MustCompile(`.*node(js)?\d*\.?\d*$`)
 )
 
 func guessApplicationType(cmdline []byte) string {
@@ -89,7 +96,14 @@ func guessApplicationType(cmdline []byte) string {
 		return "rook"
 	case bytes.HasSuffix(cmd, []byte("nats-server")):
 		return "nats"
+	case bytes.HasSuffix(cmd, []byte("java")):
+		return "java"
+	case phpCmd.Match(cmd):
+		return "php"
+	case pythonCmd.Match(cmd):
+		return "python"
+	case nodejsCmd.Match(cmd):
+		return "nodejs"
 	}
-	//todo: php-fpm, python, nodejs, java
 	return ""
 }

+ 1 - 0
containers/container.go

@@ -333,6 +333,7 @@ func (c *Container) Collect(ch chan<- prometheus.Metric) {
 				}
 			}
 		case process.dotNetMonitor != nil:
+			appTypes["dotnet"] = struct{}{}
 			process.dotNetMonitor.Collect(ch)
 		}
 	}