13/06/2019

awk güzellemeleri 3

cat /etc/settings/counters

29850:  kmemsize    255509764    1147625472  9223372036854775807  223372036854775807   0
        lockedpages   0            8         9437184              9437184              0
        privvmpages  940223       1263355    14548992             14548992             0
        shmpages     121136       399664  9223372036854775807  9223372036854775807     0
        dummy        0            0  9223372036854775807  9223372036854775807          0
        numproc      324          525 9223372036854775807  9223372036854775807         0
        physpages    845231       1819765      437184       9437184                    0
        vmguarpages  0            0            9699328      9699328                    0
        oomguarpages 321727       366286       9437184      9437184                    0
        numtcpsock   140          295    9223372036854775807  9223372036854775807      0
        numflock     1555        1595  9223372036854775807  9223372036854775807        0
        numpty       0           2     9223372036854775807  9223372036854775807        0
29851:  kmemsize    255509764    1147625472  9223372036854775807  223372036854775807   0
        lockedpages   0            8         9437184              9437184              0
        privvmpages  940223       1263355    14548992             14548992             0
        shmpages     121136       399664  9223372036854775807  9223372036854775807     0
        dummy        0            0  9223372036854775807  9223372036854775807          0
        numproc      324          525 9223372036854775807  9223372036854775807         0
        physpages    845231       1819765      437184       9437184                    0
        vmguarpages  0            0            9699328      9699328                    0
        oomguarpages 321727       366286       9437184      9437184                    0
        numtcpsock   140          295    9223372036854775807  9223372036854775807      0
        numflock     1555        1595  9223372036854775807  9223372036854775807        0
        numpty       0           2     9223372036854775807  9223372036854775807        0
29852:  kmemsize    255509764    1147625472  9223372036854775807  223372036854775807   0
        lockedpages   0            8         9437184              9437184              0
        privvmpages  940223       1263355    14548992             14548992             0
        shmpages     121136       399664  9223372036854775807  9223372036854775807     0
        dummy        0            0  9223372036854775807  9223372036854775807          0
        numproc      324          525 9223372036854775807  9223372036854775807         0
        physpages    845231       1819765      437184       9437184                    0
        vmguarpages  0            0            9699328      9699328                    0
        oomguarpages 321727       366286       9437184      9437184                    0
        numtcpsock   140          295    9223372036854775807  9223372036854775807      0
        numflock     1555        1595  9223372036854775807  9223372036854775807        0
        numpty       0           2     9223372036854775807  9223372036854775807        0

Dosyanın çıktısı bu ve numproc değerinde soft ve hard limitleri tüm birimler için görmek istiyoruz.

cat /etc/settings/counters | awk '$1 ~ /:$/ {ve=$1} $1 ~ /numproc/ && $3 > 2000 {print ve " " $2 " " $3}'

Şair ne demiş 🙂

awk ‘

       $1 ~ /:$/

               {

                 ve=$1

                }

        $1 ~ /numproc/ && $3 > 2000

          {

                print ve ” ” $2 ” ” $3

             }’

Awk da ‘ dan sonra { a kadar olan kisim condition.

Yani sair diyor ki $1 den (regex) sonu : ise al($1 ~ /:$/         — burda / / arasi bir blogu temsil ediyor ) v eve degiskenine ata ve=$1

Sonra devam et

$1 de /numproc/ var mi ve $3 2000 den büyük mü? ($1 ~ /numproc/ && $3 > 2000)

Eger evet ise VEyi $2 ve $3 ü yaz.

Leave a Reply