Solaris process debugging

From Lolly's Wiki
Revision as of 11:28, 16 September 2016 by Lollypop (talk | contribs)
Jump to navigationJump to search

Debugging

Swap usage per process

# pgrep . |\
   xargs -n 1 pmap -S 2>/dev/null |\
   nawk '
     $1 ~ /[0-9]+:/{
       pid=$1;
       proc=$2;
     }
     /^total/ {
       swap_kb=$4;
       printf("%6s %6d Kb Swap %s\n",pid,swap_kb,proc);
     }' |\
   sort -k2n,2n


Set the core file size limit on a process

For example for the sshd (and all resulting childs from now):

ssh-server# prctl -n process.max-core-size -v 2g -t privileged -r -e deny  $(pgrep -u root -o sshd)

Check:

ssh-server# prctl -n process.max-core-size  $(pgrep -u root -o sshd)
process: 1491: /usr/lib/ssh/sshd
NAME    PRIVILEGE       VALUE    FLAG   ACTION                       RECIPIENT
process.max-core-size
        privileged      2.00GB      -   deny                                 -
        system          8.00EB    max   deny                                 -

Now all processes (for example new logged in users) will have a core file size limit of 2GB... really? No!

ssh-client# ssh ssh-server
ssh-server# ulimit -Ha | grep core
core file size          (blocks, -c) 2097152

See what it says: blocks <-- !!! From man page: -c Maximum core file size (in 512-byte blocks)