From 45b76331a227444fe9e7a6a9348c05b64518d01f Mon Sep 17 00:00:00 2001 From: yinbinbin Date: Tue, 11 Jul 2023 18:27:18 +0800 Subject: [PATCH] pod_allocpage: support 10250 port Signed-off-by: yinbinbin --- source/tools/monitor/unity/collector/pod_allocpage.lua | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/source/tools/monitor/unity/collector/pod_allocpage.lua b/source/tools/monitor/unity/collector/pod_allocpage.lua index f4043968..9a541234 100644 --- a/source/tools/monitor/unity/collector/pod_allocpage.lua +++ b/source/tools/monitor/unity/collector/pod_allocpage.lua @@ -30,7 +30,7 @@ function CPodAlloc:_init_(proto, pffi, mnt, pFile) self.cgroup_pod = {} self.allpods = {} self.blacklist = {["arms-prom"] = 1, ["kube-system"] = 1, ["kube-public"] = 1, ["kube-node-lease"] = 1} - -- self.blacklist= {} + --self.blacklist= {} self.total = 0 self.count = 0 self.cgroup_count = 0 @@ -209,6 +209,13 @@ function CPodAlloc:get_allpods() local cli = ChttpCli.new() local content = cli:get(url) local obj = cli:jdecode(content.body) + if not obj then + local cmd = ' curl -s -k -XGET https://127.0.0.1:10250/pods --cacert /var/run/secrets/kubernetes.io/serviceaccount/ca.crt --header "Authorization: Bearer $(cat /var/run/secrets/kubernetes.io/serviceaccount/token) "' + local f = io.popen(cmd,"r") + local podsinfo = f:read("*a") + f:close() + obj = json.decode(podsinfo) + end for _,v in pairs(obj['items']) do if not self.blacklist[v['metadata']['namespace']] then self.allpods[v['metadata']['name']] = v['metadata']['namespace'] end end -- Gitee