Solaris process debugging: Difference between revisions
From Lolly's Wiki
Jump to navigationJump to search
No edit summary |
m (Text replacement - "[[Kategorie:" to "[[Category:") |
||
(4 intermediate revisions by the same user not shown) | |||
Line 1: | Line 1: | ||
[[ | [[Category:Solaris|Debugging]] | ||
==Swap usage per process== | |||
<syntaxhighlight lang=awk> | |||
# pgrep . | xargs -n 1 pmap -S 2>/dev/null | nawk ' | |||
function kb2h(value){ | |||
unit=1; | |||
while(value>=1024){ | |||
unit++; | |||
value/=1024; | |||
}; | |||
split("KB,MB,GB,TB,PB", unit_string, /,/); | |||
return sprintf("%7.2f %s",value,unit_string[unit]); | |||
} | |||
/[0-9]+:/ { | |||
pid=$1; | |||
prog=$2; | |||
} | |||
/^total/{ | |||
swap_total+=$3; | |||
printf ("%s\t%s\t%s\n",pid,kb2h($3),prog); | |||
} | |||
END{ | |||
printf "Total:\t%s\n",kb2h(swap_total); | |||
}' | |||
</syntaxhighlight> | |||
==Set the core file size limit on a process== | ==Set the core file size limit on a process== | ||
For example for the sshd (and all resulting childs from now): | For example for the sshd (and all resulting childs from now): | ||
< | <syntaxhighlight lang=bash> | ||
ssh-server# prctl -n process.max-core-size -v 2g -t privileged -r -e deny $(pgrep -u root -o sshd) | ssh-server# prctl -n process.max-core-size -v 2g -t privileged -r -e deny $(pgrep -u root -o sshd) | ||
</ | </syntaxhighlight> | ||
Check: | Check: | ||
< | <syntaxhighlight lang=bash> | ||
ssh-server# prctl -n process.max-core-size $(pgrep -u root -o sshd) | ssh-server# prctl -n process.max-core-size $(pgrep -u root -o sshd) | ||
process: 1491: /usr/lib/ssh/sshd | process: 1491: /usr/lib/ssh/sshd | ||
Line 14: | Line 40: | ||
privileged 2.00GB - deny - | privileged 2.00GB - deny - | ||
system 8.00EB max deny - | system 8.00EB max deny - | ||
</ | </syntaxhighlight> | ||
Now all processes (for example new logged in users) will have a core file size limit of 2GB... really? No! | Now all processes (for example new logged in users) will have a core file size limit of 2GB... really? No! | ||
< | <syntaxhighlight lang=bash> | ||
ssh-client# ssh ssh-server | ssh-client# ssh ssh-server | ||
ssh-server# ulimit -Ha | grep core | ssh-server# ulimit -Ha | grep core | ||
core file size (blocks, -c) 2097152 | core file size (blocks, -c) 2097152 | ||
</ | </syntaxhighlight> | ||
See what it says: blocks <-- !!! | See what it says: blocks <-- !!! | ||
From man page: -c Maximum core file size (in 512-byte blocks) | From man page: -c Maximum core file size (in 512-byte blocks) |
Latest revision as of 23:53, 25 November 2021
Swap usage per process
# pgrep . | xargs -n 1 pmap -S 2>/dev/null | nawk '
function kb2h(value){
unit=1;
while(value>=1024){
unit++;
value/=1024;
};
split("KB,MB,GB,TB,PB", unit_string, /,/);
return sprintf("%7.2f %s",value,unit_string[unit]);
}
/[0-9]+:/ {
pid=$1;
prog=$2;
}
/^total/{
swap_total+=$3;
printf ("%s\t%s\t%s\n",pid,kb2h($3),prog);
}
END{
printf "Total:\t%s\n",kb2h(swap_total);
}'
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)