-
Notifications
You must be signed in to change notification settings - Fork 50
/
app.go
109 lines (106 loc) · 3.62 KB
/
app.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
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 {
parts := bytes.Split(cmdline, []byte{0})
cmd := bytes.TrimSuffix(bytes.Fields(parts[0])[0], []byte{':'})
switch {
case bytes.HasSuffix(cmd, []byte("memcached")):
return "memcached"
case bytes.HasSuffix(cmd, []byte("envoy")):
return "envoy"
case bytes.Contains(cmdline, []byte("org.elasticsearch.bootstrap")):
return "elasticsearch"
case bytes.Contains(cmdline, []byte("kafka.Kafka")) || bytes.Contains(cmdline, []byte("io.confluent.support.metrics.SupportedKafka")):
return "kafka"
case bytes.HasSuffix(cmd, []byte("mongod")):
return "mongodb"
case bytes.HasSuffix(cmd, []byte("mongos")):
return "mongos"
case bytes.HasSuffix(cmd, []byte("mysqld")):
return "mysql"
case bytes.Contains(cmdline, []byte("org.apache.zookeeper.server.quorum.QuorumPeerMain")):
return "zookeeper"
case bytes.HasSuffix(cmd, []byte("redis-server")):
return "redis"
case bytes.HasSuffix(cmd, []byte("redis-sentinel")):
return "redis-sentinel"
case bytes.HasSuffix(cmd, []byte("keydb-server")):
return "keydb"
case bytes.HasSuffix(cmd, []byte("beam.smp")) && bytes.Contains(cmdline, []byte("rabbit")):
return "rabbitmq"
case bytes.HasSuffix(cmd, []byte("beam.smp")) && bytes.Contains(cmdline, []byte("couch")):
return "couchbase"
case bytes.HasSuffix(cmd, []byte("pgbouncer")):
return "pgbouncer"
case bytes.HasSuffix(cmd, []byte("postgres")):
return "postgres"
case bytes.HasSuffix(cmd, []byte("haproxy")):
return "haproxy"
case bytes.HasSuffix(cmd, []byte("nginx")):
return "nginx"
case bytes.HasSuffix(cmd, []byte("kubelet")):
return "kubelet"
case bytes.HasSuffix(cmd, []byte("kube-apiserver")):
return "kube-apiserver"
case bytes.HasSuffix(cmd, []byte("kube-controller-manager")):
return "kube-controller-manager"
case bytes.HasSuffix(cmd, []byte("kube-scheduler")):
return "kube-scheduler"
case bytes.HasSuffix(cmd, []byte("k3s")):
return "k3s"
case bytes.HasSuffix(cmd, []byte("etcd")):
return "etcd"
case bytes.HasSuffix(cmd, []byte("dockerd")):
return "dockerd"
case bytes.HasSuffix(cmd, []byte("consul")):
return "consul"
case bytes.Contains(cmdline, []byte("org.apache.cassandra.service.CassandraDaemon")):
return "cassandra"
case bytes.HasSuffix(cmd, []byte("clickhouse-server")):
return "clickhouse"
case bytes.HasSuffix(cmd, []byte("traefik")):
return "traefik"
case bytes.HasSuffix(cmd, []byte("asd")):
return "aerospike"
case bytes.HasSuffix(cmd, []byte("httpd")):
return "httpd"
case bytes.HasSuffix(cmd, []byte("influxd")):
return "influxdb"
case bytes.Contains(cmdline, []byte("org.apache.catalina.startup.Bootstrap")):
return "tomcat"
case bytes.HasSuffix(cmd, []byte("vault")):
return "vault"
case bytes.HasSuffix(cmd, []byte("proxysql")):
return "proxysql"
case bytes.HasSuffix(cmd, []byte("cockroach")):
return "cockroach"
case bytes.HasSuffix(cmd, []byte("prometheus")):
return "prometheus"
case bytes.HasSuffix(cmd, []byte("ceph-mon")) ||
bytes.HasSuffix(cmd, []byte("ceph-mgr")) ||
bytes.HasSuffix(cmd, []byte("ceph-osd")) ||
bytes.HasSuffix(cmd, []byte("cephcsi")):
return "ceph"
case bytes.HasSuffix(cmd, []byte("rook")):
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"
}
return ""
}