app.go 2.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980
  1. package containers
  2. import (
  3. "bytes"
  4. )
  5. func guessApplicationType(cmdline []byte) string {
  6. parts := bytes.Split([]byte(cmdline), []byte{0})
  7. cmd := bytes.TrimSuffix(bytes.Fields(parts[0])[0], []byte{':'})
  8. switch {
  9. case bytes.HasSuffix(cmd, []byte("memcached")):
  10. return "memcached"
  11. case bytes.HasSuffix(cmd, []byte("envoy")):
  12. return "envoy"
  13. case bytes.Contains(cmdline, []byte("org.elasticsearch.bootstrap")):
  14. return "elasticsearch"
  15. case bytes.Contains(cmdline, []byte("kafka.Kafka")) || bytes.Contains(cmdline, []byte("io.confluent.support.metrics.SupportedKafka")):
  16. return "kafka"
  17. case bytes.HasSuffix(cmd, []byte("mongod")):
  18. return "mongodb"
  19. case bytes.HasSuffix(cmd, []byte("mysqld")):
  20. return "mysql"
  21. case bytes.Contains(cmdline, []byte("org.apache.zookeeper.server.quorum.QuorumPeerMain")):
  22. return "zookeeper"
  23. case bytes.HasSuffix(cmd, []byte("redis-server")):
  24. return "redis"
  25. case bytes.HasSuffix(cmd, []byte("redis-sentinel")):
  26. return "redis-sentinel"
  27. case bytes.HasSuffix(cmd, []byte("beam.smp")) && bytes.Contains(cmdline, []byte("rabbit")):
  28. return "rabbitmq"
  29. case bytes.HasSuffix(cmd, []byte("beam.smp")) && bytes.Contains(cmdline, []byte("couch")):
  30. return "couchbase"
  31. case bytes.HasSuffix(cmd, []byte("pgbouncer")):
  32. return "pgbouncer"
  33. case bytes.HasSuffix(cmd, []byte("postgres")):
  34. return "postgres"
  35. case bytes.HasSuffix(cmd, []byte("haproxy")):
  36. return "haproxy"
  37. case bytes.HasSuffix(cmd, []byte("nginx")):
  38. return "nginx"
  39. case bytes.HasSuffix(cmd, []byte("kubelet")):
  40. return "kubelet"
  41. case bytes.HasSuffix(cmd, []byte("kube-apiserver")):
  42. return "kube-apiserver"
  43. case bytes.HasSuffix(cmd, []byte("kube-controller-manager")):
  44. return "kube-controller-manager"
  45. case bytes.HasSuffix(cmd, []byte("kube-scheduler")):
  46. return "kube-scheduler"
  47. case bytes.HasSuffix(cmd, []byte("etcd")):
  48. return "etcd"
  49. case bytes.HasSuffix(cmd, []byte("dockerd")):
  50. return "dockerd"
  51. case bytes.HasSuffix(cmd, []byte("consul")):
  52. return "consul"
  53. case bytes.Contains(cmdline, []byte("org.apache.cassandra.service.CassandraDaemon")):
  54. return "cassandra"
  55. case bytes.HasSuffix(cmd, []byte("clickhouse-server")):
  56. return "clickhouse"
  57. case bytes.HasSuffix(cmd, []byte("traefik")):
  58. return "traefik"
  59. case bytes.HasSuffix(cmd, []byte("asd")):
  60. return "aerospike"
  61. case bytes.HasSuffix(cmd, []byte("httpd")):
  62. return "httpd"
  63. case bytes.HasSuffix(cmd, []byte("influxd")):
  64. return "influxdb"
  65. case bytes.Contains(cmdline, []byte("org.apache.catalina.startup.Bootstrap")):
  66. return "tomcat"
  67. case bytes.HasSuffix(cmd, []byte("vault")):
  68. return "vault"
  69. case bytes.HasSuffix(cmd, []byte("proxysql")):
  70. return "proxysql"
  71. case bytes.HasSuffix(cmd, []byte("cockroach")):
  72. return "cockroach"
  73. case bytes.HasSuffix(cmd, []byte("prometheus")):
  74. return "prometheus"
  75. }
  76. //todo: ceph services, php-fpm, python, nodejs, java
  77. return ""
  78. }