Skip to content

Commit d95183e

Browse files
committed
Merge remote-tracking branch 'origin/master' into grafana-dashboard-ts
2 parents 738a81e + f10f445 commit d95183e

File tree

1 file changed

+0
-84
lines changed

1 file changed

+0
-84
lines changed

holmes/plugins/toolsets/kubernetes.yaml

Lines changed: 0 additions & 84 deletions
Original file line numberDiff line numberDiff line change
@@ -86,90 +86,6 @@ toolsets:
8686
description: "Retrieve the events for a specific Kubernetes resource. `resource_type` can be any kubernetes resource type: 'pod', 'service', 'deployment', 'job', 'node', etc."
8787
command: "kubectl events --for {{resource_type}}/{{ resource_name }}{% if namespace %} -n {{ namespace }}{% endif %}"
8888

89-
- name: "kubectl_memory_requests_all_namespaces"
90-
description: "Fetch and display memory requests for all pods across all namespaces in MiB, summing requests across multiple containers where applicable and handling binary, decimal, and millibyte units correctly."
91-
command: |
92-
kubectl get pods --all-namespaces -o custom-columns="NAMESPACE:.metadata.namespace,NAME:.metadata.name,MEMORY_REQUEST:.spec.containers[*].resources.requests.memory" --no-headers | \
93-
awk '
94-
function convert_to_mib(value) {
95-
if (value ~ /^[0-9]+e[0-9]+$/) return (value + 0) / (1024 * 1024); # Scientific notation
96-
if (value ~ /m$/) return (value + 0) / (1024^2 * 1000); # Millibytes (m)
97-
if (value ~ /Ei$/) return (value + 0) * 1024^6 / (1024^2); # Binary units
98-
if (value ~ /Pi$/) return (value + 0) * 1024^5 / (1024^2);
99-
if (value ~ /Ti$/) return (value + 0) * 1024^4 / (1024^2);
100-
if (value ~ /Gi$/) return (value + 0) * 1024^3 / (1024^2);
101-
if (value ~ /Mi$/) return (value + 0);
102-
if (value ~ /Ki$/) return (value + 0) / 1024;
103-
if (value ~ /E$/) return (value + 0) * 1000^6 / (1024^2); # Decimal units
104-
if (value ~ /P$/) return (value + 0) * 1000^5 / (1024^2);
105-
if (value ~ /T$/) return (value + 0) * 1000^4 / (1024^2);
106-
if (value ~ /G$/) return (value + 0) * 1000^3 / (1024^2);
107-
if (value ~ /M$/) return (value + 0) * 1000^2 / (1024^2);
108-
if (value ~ /k$/) return (value + 0) * 1000 / (1024^2);
109-
return (value + 0) / (1024 * 1024); # Default: bytes
110-
}
111-
function sum_memory(requests) {
112-
gsub(/^[ \t]+|[ \t]+$/, "", requests);
113-
if (requests == "" || requests == "<none>") return 0;
114-
split(requests, arr, ",");
115-
total = 0;
116-
for (i in arr) {
117-
if (arr[i] != "<none>") total += convert_to_mib(arr[i]);
118-
}
119-
return total;
120-
}
121-
{
122-
namespace = $1;
123-
name = $2;
124-
requests = $3;
125-
for (i=4; i<=NF; i++) {
126-
requests = requests " " $i;
127-
}
128-
print namespace, name, sum_memory(requests) " Mi";
129-
}' | sort -k3 -nr
130-
131-
- name: "kubectl_memory_requests_namespace"
132-
description: "Fetch and display memory requests for all pods in a specified namespace in MiB, summing requests across multiple containers where applicable and handling binary, decimal, and millibyte units correctly."
133-
command: |
134-
kubectl get pods -n {{ namespace }} -o custom-columns="NAMESPACE:.metadata.namespace,NAME:.metadata.name,MEMORY_REQUEST:.spec.containers[*].resources.requests.memory" --no-headers | \
135-
awk '
136-
function convert_to_mib(value) {
137-
if (value ~ /^[0-9]+e[0-9]+$/) return (value + 0) / (1024 * 1024); # Scientific notation
138-
if (value ~ /m$/) return (value + 0) / (1024^2 * 1000); # Millibytes (m)
139-
if (value ~ /Ei$/) return (value + 0) * 1024^6 / (1024^2); # Binary units
140-
if (value ~ /Pi$/) return (value + 0) * 1024^5 / (1024^2);
141-
if (value ~ /Ti$/) return (value + 0) * 1024^4 / (1024^2);
142-
if (value ~ /Gi$/) return (value + 0) * 1024^3 / (1024^2);
143-
if (value ~ /Mi$/) return (value + 0);
144-
if (value ~ /Ki$/) return (value + 0) / 1024;
145-
if (value ~ /E$/) return (value + 0) * 1000^6 / (1024^2); # Decimal units
146-
if (value ~ /P$/) return (value + 0) * 1000^5 / (1024^2);
147-
if (value ~ /T$/) return (value + 0) * 1000^4 / (1024^2);
148-
if (value ~ /G$/) return (value + 0) * 1000^3 / (1024^2);
149-
if (value ~ /M$/) return (value + 0) * 1000^2 / (1024^2);
150-
if (value ~ /k$/) return (value + 0) * 1000 / (1024^2);
151-
return (value + 0) / (1024 * 1024); # Default: bytes
152-
}
153-
function sum_memory(requests) {
154-
gsub(/^[ \t]+|[ \t]+$/, "", requests);
155-
if (requests == "" || requests == "<none>") return 0;
156-
split(requests, arr, ",");
157-
total = 0;
158-
for (i in arr) {
159-
if (arr[i] != "<none>") total += convert_to_mib(arr[i]);
160-
}
161-
return total;
162-
}
163-
{
164-
namespace = $1;
165-
name = $2;
166-
requests = $3;
167-
for (i=4; i<=NF; i++) {
168-
requests = requests " " $i;
169-
}
170-
print namespace, name, sum_memory(requests) " Mi";
171-
}' | sort -k3 -nr
172-
17389
- name: "kubernetes_jq_query"
17490
user_description: "Query Kubernetes Resources: kubectl get {{kind}} --all-namespaces -o json | jq -r {{jq_expr}}"
17591
description: >

0 commit comments

Comments
 (0)