kostya / eye

Process monitoring tool. Inspired from Bluepill and God.
MIT License
1.19k stars 89 forks source link

Getting Parent ProcessName on email alerts #202

Closed innovia closed 6 years ago

innovia commented 6 years ago

Hi Konstantin,

I currently get child process pid that crash - having the parent process name in the email will be much help.

my message_body method is:

 def message_body
    log_name = "#{log_file.empty? ? msg_name.to_s : log_file}.log"

    if process_match =  /^(\w+)-/.match(msg_name.to_s)
      log_name = "#{process_match[1]}.log"
    end

    public_ip = `wget -q -O - http://169.254.169.254/latest/meta-data/public-ipv4`.chomp
    m = []
    m << "<body>"
    m << "from mail: #{from_mail}"
    m << "<br><h3>#{msg_name.to_s} Process Info: </h3><br>"
    m << "<b>StdOut Log Tail (#{logs_folder}/#{log_name}):</b><br> <pre>#{`tail -n 30 #{logs_folder}/#{log_name}`}</pre><br>"
    m << "</body>"
    debug "message body: #{m * "\n"}"
    "#{m * "\n"}"
  end

I end up getting an email like this:

child-7513 on Server - Bounded memory(<400Mb): [81Mb, 81Mb, *2290Mb, *7834Mb, *13211Mb] send to [:restart]

child-7513 Process Info:

StdOut Log Tail (/opt/redash/logs/child.log):

What I want is to get the parent process name for the child that was killed.

is there a built in way in Eye to do that? what do you think?

Ami

kostya commented 6 years ago

try to output msg_full_name

innovia commented 6 years ago

Thanks a lot