mirror of
https://github.com/ntop/ntopng.git
synced 2026-05-08 14:50:54 +00:00
Uses a union to handle k8s and docker info
This commit is contained in:
parent
af420ac215
commit
319c64eb4e
6 changed files with 86 additions and 50 deletions
|
|
@ -40,10 +40,13 @@ InterfaceStatsHash::~InterfaceStatsHash() {
|
|||
|
||||
if(buckets[i]->container_info_set) {
|
||||
if(buckets[i]->container_info.id) free(buckets[i]->container_info.id);
|
||||
if(buckets[i]->container_info.k8s.name) free(buckets[i]->container_info.k8s.name);
|
||||
if(buckets[i]->container_info.k8s.pod) free(buckets[i]->container_info.k8s.pod);
|
||||
if(buckets[i]->container_info.k8s.ns) free(buckets[i]->container_info.k8s.ns);
|
||||
if(buckets[i]->container_info.docker.name) free(buckets[i]->container_info.docker.name);
|
||||
if(buckets[i]->container_info.data_type == container_info_data_type_k8s) {
|
||||
if(buckets[i]->container_info.data.k8s.name) free(buckets[i]->container_info.data.k8s.name);
|
||||
if(buckets[i]->container_info.data.k8s.pod) free(buckets[i]->container_info.data.k8s.pod);
|
||||
if(buckets[i]->container_info.data.k8s.ns) free(buckets[i]->container_info.data.k8s.ns);
|
||||
} else if(buckets[i]->container_info.data_type == container_info_data_type_docker) {
|
||||
if(buckets[i]->container_info.data.docker.name) free(buckets[i]->container_info.data.docker.name);
|
||||
}
|
||||
}
|
||||
|
||||
free(buckets[i]);
|
||||
|
|
@ -107,10 +110,13 @@ bool InterfaceStatsHash::set(const sFlowInterfaceStats * const stats) {
|
|||
|
||||
if(buckets[hash]->container_info_set) {
|
||||
if(buckets[hash]->container_info.id) buckets[hash]->container_info.id = strdup(buckets[hash]->container_info.id);
|
||||
if(buckets[hash]->container_info.k8s.name) buckets[hash]->container_info.k8s.name = strdup(buckets[hash]->container_info.k8s.name);
|
||||
if(buckets[hash]->container_info.k8s.pod) buckets[hash]->container_info.k8s.pod = strdup(buckets[hash]->container_info.k8s.pod);
|
||||
if(buckets[hash]->container_info.k8s.ns) buckets[hash]->container_info.k8s.ns = strdup(buckets[hash]->container_info.k8s.ns);
|
||||
if(buckets[hash]->container_info.docker.name) buckets[hash]->container_info.docker.name = strdup(buckets[hash]->container_info.docker.name);
|
||||
if(buckets[hash]->container_info.data_type == container_info_data_type_k8s) {
|
||||
if(buckets[hash]->container_info.data.k8s.name) buckets[hash]->container_info.data.k8s.name = strdup(buckets[hash]->container_info.data.k8s.name);
|
||||
if(buckets[hash]->container_info.data.k8s.pod) buckets[hash]->container_info.data.k8s.pod = strdup(buckets[hash]->container_info.data.k8s.pod);
|
||||
if(buckets[hash]->container_info.data.k8s.ns) buckets[hash]->container_info.data.k8s.ns = strdup(buckets[hash]->container_info.data.k8s.ns);
|
||||
} else if(buckets[hash]->container_info.data_type == container_info_data_type_docker) {
|
||||
if(buckets[hash]->container_info.data.docker.name) buckets[hash]->container_info.data.docker.name = strdup(buckets[hash]->container_info.data.docker.name);
|
||||
}
|
||||
}
|
||||
|
||||
} else
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue