0

I have got the requirement to find the core file in multiple box/machine and trigger email about core file generation.

Do we have any utility which help us to find core in single machine or multiple machine. I believe we should have any utility to find the core file beacuse it is very generic scenario.

After the below input, I am able to write a perl script which find the core file and trigger mail if any core file exist

This script work fine into local machine but I need to add all Production server. Does anyone also provide me any idea to connect linux terminal through Perl script.

As of now, we are concentrating on dev machine So this script can login into all dev machine and find the core file.

3 Answers3

0

Implement that into your email script:

find / -name core

Or just cronjob it to output all paths to a log. Of course you can also change "/" in the find command with a specific path

Adam
  • 21
  • 2
0

Shell script will better option for your question. I am not used to with shell script but i tried to formulate it.

#list of server to be monitored for core file
serverList="root@server1 root@server2 root@server50"

for server in $serverList
do
    #core file
    log="/tmp/coreFiles.log"

    ssh $server find / -type f -name core >$log

    if [ -s $log] then
       echo "core files for server $server" | mail -s "Core files found" xyz@abc.com < $log
    fi      

done
Sach
  • 659
  • 8
  • 20
0

The old-fashioned way is to periodically search the whole filesystem for core files:

find / -type f -name core

or

find / -type f -name 'core.*'

This, naturally, does have the risk of matching user files with the (rather unfortunate) name core.

Fortunately, modern Linux systems are somewhat more configurable. You can use the /proc/sys/kernel/core_pattern file to set up a specific directory where core files will be placed, as well as a format for the name of the file. You can have core filenames that contain the name of the program, the UID and GID under which it was launched and so on - have a look at this manual page.

This way you can keep all your core files in a single directory, which has several advantages:

  • You do not risk having core files sprinkled all over the filesystem.

  • You can easily remove all core files without the computational expense of searching all over the filesystem and without the risk of removing user files.

  • Since all core files are in a single place, it is far more reasonable to poll for new files as needed.

  • If you want immediate action, you can avoid polling by using inotifywait or other tools based on inotify to monitor the core file directory.

thkala
  • 84,049
  • 23
  • 157
  • 201
  • Thanks a lot for reply me. So I have created Perl script which search the core file and send mail to me if any core file exist. –  Jul 05 '12 at 12:43