Monthly Archives: August 2005

coreadm and %d

Coreadm(1m) has a really nice feature that can be used to restrict coredumps that are collected to just the one from the system. Typically I’m not interested in a global core file from and application that someone is developing so I would like to limit the cores to just those created by programs that are delivered as part of solaris.

So if you use %d as part of the pattern it will expand to the name of the directory where the binary lives. If the directory does not exist then no core file.

So in this example if /usr/bin/ls were to dump core (not that it does) using this setup:

 # coreadm
global core file pattern: /var/cores/%d/%f.%p.%u
global core file content: default
init core file pattern: core
init core file content: default
global core dumps: enabled
per-process core dumps: enabled
global setid core dumps: disabled
per-process setid core dumps: disabled
global core dump logging: enabled

The global core only gets dumped if /var/cores/usr/bin exists.

The down side of this is that not all the executables you may be interested in are in /usr/bin or other obvious locations so they could fail to dump core as the directory does not yet exist.

So I knocked together this little script to create all the directories that I will ever need:

nawk ‘$2 == “f” { printf(“file %sn”, $1) }’  /var/sadm/install/contents |
ksh -p |
nawk ‘function dirname(path) {
len= length(path);
for (n = 1 ; index(substr(path, len – (1+ n), n), “/”) == 0; n++) ;

return(substr(path, 1, len – (2+ n)));
/ELF.*executable/ {
for (y in x ) {
printf(“test -d /var/cores%s || mkdir -p /var/cores%sn”,
y, y)
}’ | ksh -x

My suspicion is that there is probably a better way. So let me know.

Tags: topic:[solaris] topic:[coreadm]

WP Like Button Plugin by Free WordPress Templates