k8s pod 내 socket 사용 확인

유진세·2022년 10월 31일
0

k8s 파드가 계속 죽어나는데 이유를 못찾아서 netstat 쳐보고 싶은데
pod 내부엔 있지도 않고...ㅠ ㅠ....
그렇다고 netstat 을 깔자니.... 그것도 좀 아닌 것 같고

이것 저것 찾아보니 netstat 없어도 비슷하게 보는 법이 있었음
난 맨날 까먹으니 또 써놔야함
아래 명령어 치면 from - to 로 예쁘게 나옴

awk 'function hextodec(str,ret,n,i,k,c){
    ret = 0
    n = length(str)
    for (i = 1; i <= n; i++) {
        c = tolower(substr(str, i, 1))
        k = index("123456789abcdef", c)
        ret = ret * 16 + k
    }
    return ret
}
function getIP(str,ret){
    ret=hextodec(substr(str,index(str,":")-2,2)); 
    for (i=5; i>0; i-=2) {
        ret = ret"."hextodec(substr(str,i,2))
    }
    ret = ret":"hextodec(substr(str,index(str,":")+1,4))
    return ret
} 
NR > 1 {{if(NR==2)print "Local - Remote";local=getIP($2);remote=getIP($3)}{print local" - "remote}}' /proc/net/tcp 

0개의 댓글