@@ -94,6 +94,66 @@ func NICJobList() []Job {
9494 ch <- jobResult
9595 },
9696 },
97+ {
98+ Name : "exec-agent-conf" ,
99+ Timeout : time .Second * 10 ,
100+ Execute : func (dc * data_collector.DataCollector , ctx context.Context , ch chan JobResult ) {
101+ jobResult := JobResult {Files : make (map [string ][]byte ), Error : nil }
102+ command := []string {"cat" , "/etc/nginx-agent/nginx-agent.conf" }
103+ for _ , namespace := range dc .Namespaces {
104+ pods , err := dc .K8sCoreClientSet .CoreV1 ().Pods (namespace ).List (ctx , metav1.ListOptions {})
105+ if err != nil {
106+ dc .Logger .Printf ("\t Could not retrieve pod list for namespace %s: %v\n " , namespace , err )
107+ } else {
108+ for _ , pod := range pods .Items {
109+ if strings .Contains (pod .Name , "ingress" ) {
110+ for _ , container := range pod .Spec .Containers {
111+ res , err := dc .PodExecutor (namespace , pod .Name , container .Name , command , ctx )
112+ if err != nil {
113+ jobResult .Error = err
114+ dc .Logger .Printf ("\t Command execution %s failed for pod %s in namespace %s: %v\n " , command , pod .Name , namespace , err )
115+ } else {
116+ fileName := fmt .Sprintf ("%s__%s__nginx-agent.conf" , pod .Name , container .Name )
117+ jobResult .Files [filepath .Join (dc .BaseDir , "exec" , namespace , fileName )] = res
118+ }
119+ }
120+ }
121+ }
122+ }
123+ }
124+ ch <- jobResult
125+ },
126+ },
127+ {
128+ Name : "exec-agent-version" ,
129+ Timeout : time .Second * 10 ,
130+ Execute : func (dc * data_collector.DataCollector , ctx context.Context , ch chan JobResult ) {
131+ jobResult := JobResult {Files : make (map [string ][]byte ), Error : nil }
132+ command := []string {"/usr/bin/nginx-agent" , "--version" }
133+ for _ , namespace := range dc .Namespaces {
134+ pods , err := dc .K8sCoreClientSet .CoreV1 ().Pods (namespace ).List (ctx , metav1.ListOptions {})
135+ if err != nil {
136+ dc .Logger .Printf ("\t Could not retrieve pod list for namespace %s: %v\n " , namespace , err )
137+ } else {
138+ for _ , pod := range pods .Items {
139+ if strings .Contains (pod .Name , "ingress" ) {
140+ for _ , container := range pod .Spec .Containers {
141+ res , err := dc .PodExecutor (namespace , pod .Name , container .Name , command , ctx )
142+ if err != nil {
143+ jobResult .Error = err
144+ dc .Logger .Printf ("\t Command execution %s failed for pod %s in namespace %s: %v\n " , command , pod .Name , namespace , err )
145+ } else {
146+ fileName := fmt .Sprintf ("%s__%s__nginx-agent-version.txt" , pod .Name , container .Name )
147+ jobResult .Files [filepath .Join (dc .BaseDir , "exec" , namespace , fileName )] = res
148+ }
149+ }
150+ }
151+ }
152+ }
153+ }
154+ ch <- jobResult
155+ },
156+ },
97157 {
98158 Name : "crd-objects" ,
99159 Timeout : time .Second * 10 ,
0 commit comments