11#! /bin/bash
22#
3- # Copyright (c) 2020, 2021 ,2022 IBM Corporation, RedHat and others.
3+ # Copyright (c) 2022 ,2022 IBM Corporation, RedHat and others.
44#
55# Licensed under the Apache License, Version 2.0 (the "License");
66# you may not use this file except in compliance with the License.
@@ -27,6 +27,7 @@ function err_exit()
2727 exit 1
2828 fi
2929}
30+
3031function get_cpu()
3132{
3233 URL=$1
@@ -41,10 +42,10 @@ function get_cpu()
4142 # Processing curl output "timestamp value" using jq tool.
4243# echo "curl --silent -G -kH Authorization: Bearer ${TOKEN} --data-urlencode 'query=sum(node_namespace_pod_container:container_cpu_usage_seconds_total:sum_rate) by (pod)' ${URL} "
4344 curl --silent --data-urlencode ' query=sum(rate(container_cpu_usage_seconds_total[5m])) by (pod,namespace)' http://localhost:9090/api/v1/query | jq ' [ .data.result[] | [.metric.pod, .value[0], .value[1]|tostring]| join(";") ]' | grep " ${APP_NAME} " | cut -d " ;" -f2,3 >> ${RESULTS_DIR} /cpu-${ITER} .json
44- # err_exit "Error: could not get cpu details of the pod" >>setup.log
4545sleep 15
4646 done
4747}
48+
4849# # Collect MEM_RSS
4950function get_mem_rss()
5051{
@@ -59,10 +60,11 @@ function get_mem_rss()
5960 do
6061 # Processing curl output "timestamp value" using jq tool.
6162 curl --silent -G -kH " Authorization: Bearer ${TOKEN} " --data-urlencode ' query=sum(container_memory_rss) by (pod)' http://localhost:9090/api/v1/query | jq ' [ .data.result[] | [ .metric.pod,.value[0], .value[1]|tostring]| join(";") ]' | grep " ${APP_NAME} " | cut -d " ;" -f2,3 >> ${RESULTS_DIR} /mem-${ITER} .json
62- # err_exit "Error: could not get memory details of the pod" >>setup.log
63+
6364 sleep 15
6465 done
6566}
67+
6668function get_mem_usage()
6769{
6870 URL=$1
@@ -76,10 +78,11 @@ function get_mem_usage()
7678 do
7779 # Processing curl output "timestamp value" using jq tool.
7880 curl --silent -G -kH " Authorization: Bearer ${TOKEN} " --data-urlencode ' query=sum(container_memory_working_set_bytes) by (pod) ' http://localhost:9090/api/v1/query | jq ' [ .data.result[] | [ .metric.pod,.value[0], .value[1]|tostring] | join(";") ]' | grep " ${APP_NAME} " | cut -d " ;" -f2,3 >> ${RESULTS_DIR} /memusage-${ITER} .json
79- # err_exit "Error: could not get memory details of the pod" >>setup.log
81+
8082 sleep 15
8183 done
8284}
85+
8386# # Collect network bytes received
8487function get_container_network_receive_bytes_total()
8588{
@@ -92,10 +95,10 @@ function get_container_network_receive_bytes_total()
9295 do
9396 # Processing curl output "timestamp value" using jq tool.
9497 curl --silent -G -kH " Authorization: Bearer ${TOKEN} " --data-urlencode ' query=sum(rate(container_network_receive_bytes_total[60s]))' http://localhost:9090/api/v1/query | jq ' [ .data.result[] | [ .value[0], .value[1]|tostring] | join(";") ]' | grep -E " [0-9]" >> ${RESULTS_DIR} /netreceivebytes-${ITER} .json
95- # err_exit "Error: could not get network received details of the pod" >>setup.log
9698 sleep 15
9799 done
98100}
101+
99102function get_container_network_transmit_bytes_total()
100103{
101104 URL=$1
@@ -107,10 +110,10 @@ function get_container_network_transmit_bytes_total()
107110 do
108111 # Processing curl output "timestamp value" using jq tool.
109112 curl --silent -G -kH " Authorization: Bearer ${TOKEN} " --data-urlencode ' query=sum(rate(container_network_transmit_bytes_total[60s]))' http://localhost:9090/api/v1/query | jq ' [ .data.result[] | [ .value[0], .value[1]|tostring] | join(";") ]' | grep -E " [0-9]" >> ${RESULTS_DIR} /nettransmitbytes-${ITER} .json
110- # err_exit "Error: could not get container network transmit bytes details of the pod" >>setup.log
111113 sleep 15
112114 done
113115}
116+
114117function get_container_network_receive_packets_total()
115118{
116119 URL=$1
@@ -122,10 +125,10 @@ function get_container_network_receive_packets_total()
122125 do
123126 # Processing curl output "timestamp value" using jq tool.
124127 curl --silent -G -kH " Authorization: Bearer ${TOKEN} " --data-urlencode ' query=sum(rate(container_network_receive_packets_total[60s]))' http://localhost:9090/api/v1/query | jq ' [ .data.result[] | [ .value[0], .value[1]|tostring] | join(";") ]' | grep -E " [0-9]" >> ${RESULTS_DIR} /cnetreceivebytes-${ITER} .json
125- # err_exit "Error: could not get container network receive packet details of the pod" >>setup.log
126128 sleep 15
127129 done
128130}
131+
129132function get_container_network_transmit_packets_total()
130133{
131134 URL=$1
@@ -137,10 +140,10 @@ function get_container_network_transmit_packets_total()
137140 do
138141 # Processing curl output "timestamp value" using jq tool.
139142 curl --silent -G -kH " Authorization: Bearer ${TOKEN} " --data-urlencode ' query=sum(rate(container_network_transmit_packets_total[60s]))' http://localhost:9090/api/v1/query | jq ' [ .data.result[] | [ .value[0], .value[1]|tostring] | join(";") ]' | grep -E " [0-9]" >> ${RESULTS_DIR} /cnettransmitbytes-${ITER} .json
140- # err_exit "Error: could not get container network tranmit packet details of the pod" >>setup.log
141143 sleep 15
142144 done
143145}
146+
144147function get_disk_details_total()
145148{
146149 URL=$1
@@ -152,10 +155,10 @@ function get_disk_details_total()
152155 do
153156 # Processing curl output "timestamp value" using jq tool.
154157 curl --silent -G -kH " Authorization: Bearer ${TOKEN} " --data-urlencode ' query=sum(rate(container_fs_usage_bytes[60s]))' http://localhost:9090/api/v1/query | jq ' [ .data.result[] | [ .value[0], .value[1]|tostring] | join(";") ]' | grep -E " [0-9]" >> ${RESULTS_DIR} /diskdetails-${ITER} .json
155- # err_exit "Error: could not get disk details of the pod" >>setup.log
156158 sleep 15
157159 done
158160}
161+
159162function get_container_fs_io_time_seconds_total()
160163{
161164 URL=$1
@@ -167,10 +170,10 @@ function get_container_fs_io_time_seconds_total()
167170 do
168171 # Processing curl output "timestamp value" using jq tool.
169172 curl --silent -G -kH " Authorization: Bearer ${TOKEN} " --data-urlencode ' query=sum(rate(container_fs_io_time_seconds_total[60s]))' http://localhost:9090/api/v1/query | jq ' [ .data.result[] | [ .value[0], .value[1]|tostring] | join(";") ]' | grep -E " [0-9]" >> ${RESULTS_DIR} /fsiototal-${ITER} .json
170- # err_exit "Error: could not get I/O time details of the pod" >>setup.log
171173 sleep 15
172174 done
173175}
176+
174177function get_container_fs_read_seconds_total()
175178{
176179 URL=$1
@@ -182,10 +185,10 @@ function get_container_fs_read_seconds_total()
182185 do
183186 # Processing curl output "timestamp value" using jq tool.
184187 curl --silent -G -kH " Authorization: Bearer ${TOKEN} " --data-urlencode ' query=sum(rate(container_fs_read_seconds_total[60s]))' http://localhost:9090/api/v1/query | jq ' [ .data.result[] | [ .value[0], .value[1]|tostring] | join(";") ]' | grep -E " [0-9]" >> ${RESULTS_DIR} /fsreadtotal-${ITER} .json
185- # err_exit "Error: could not get required details of the pod" >>setup.log
186188 sleep 15
187189 done
188190}
191+
189192function get_container_fs_write_seconds_total()
190193{
191194 URL=$1
@@ -197,10 +200,10 @@ function get_container_fs_write_seconds_total()
197200 do
198201 # Processing curl output "timestamp value" using jq tool.
199202 curl --silent -G -kH " Authorization: Bearer ${TOKEN} " --data-urlencode ' query=sum(rate(container_fs_write_seconds_total[60s]))' http://localhost:9090/api/v1/query | jq ' [ .data.result[] | [ .value[0], .value[1]|tostring] | join(";") ]' | grep -E " [0-9]" >> ${RESULTS_DIR} /fswritetotal-${ITER} .json
200- # err_exit "Error: could not get required details of the pod" >>setup.log
201203 sleep 15
202204 done
203205}
206+
204207# this is not required for renaissance as of now,will be updated later
205208function get_request_duration_seconds_sum_total()
206209{
@@ -240,7 +243,6 @@ APP_NAME=$5
240243CLUSTER_TYPE=$6
241244
242245mkdir -p ${RESULTS_DIR}
243- # QUERY_APP=prometheus-k8s-openshift-monitoring.apps
244246if [[ ${CLUSTER_TYPE} == " openshift" ]]; then
245247 QUERY_APP=thanos-querier-openshift-monitoring.apps
246248 URL=https://${QUERY_APP} .${BENCHMARK_SERVER} /api/v1/query
@@ -266,6 +268,4 @@ timeout ${TIMEOUT} bash -c "get_disk_details_total ${URL} ${TOKEN} ${RESULTS_DI
266268timeout ${TIMEOUT} bash -c " get_container_fs_io_time_seconds_total ${URL} ${TOKEN} ${RESULTS_DIR} ${ITER} ${APP_NAME} " &
267269timeout ${TIMEOUT} bash -c " get_container_fs_read_seconds_total ${URL} ${TOKEN} ${RESULTS_DIR} ${ITER} ${APP_NAME} " &
268270timeout ${TIMEOUT} bash -c " get_container_fs_write_seconds_total ${URL} ${TOKEN} ${RESULTS_DIR} ${ITER} ${APP_NAME} " &
269- # timeout ${TIMEOUT} bash -c "get_request_duration_seconds_sum_total ${URL} ${TOKEN} ${RESULTS_DIR} ${ITER} ${APP_NAME}" &
270- # timeout ${TIMEOUT} bash -c "get_request_duration_seconds_count_total ${URL} ${TOKEN} ${RESULTS_DIR} ${ITER} ${APP_NAME}" &
271271sleep ${TIMEOUT}
0 commit comments