Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

I know that we can use nagios plugin notify-by-email to send emails for any kind of critical alerts. Now I want one email to be sent as a report for the critical alerts of last one day daily. Can someone please help me to solve this.

share|improve this question
add comment

3 Answers

up vote 5 down vote accepted

Now I want one email to be sent as a report for the critical alerts of last one day daily.

Edit the nagios.cfg to change the rotation method to daily:

# LOG ROTATION METHOD
# This is the log rotation method that Nagios should use to rotate
# the main log file. Values are as follows..
#   n   = None - don't rotate the log
#   h   = Hourly rotation (top of the hour)
#   d   = Daily rotation (midnight every day)
#   w   = Weekly rotation (midnight on Saturday evening)
#   m   = Monthly rotation (midnight last day of month)

log_rotation_method=d

then parse the nagios.log for the CRITICAL alerts, something like this:

awk '/SERVICE ALERT: .*;CRITICAL;HARD/ { print $0 }' nagios.log | \
    perl -pe 's/(\d+)/localtime($1)/e' | \
        mail -s "Nagios daily report $(date +%F)" <your_email>@domain.com

Run the above command at the end of day as a daily cron job if you want.

share|improve this answer
add comment

in order to call the cgis on the shell, you should consider reading those hints as well (they are targetting Icinga 1.x so some cgi params might not work with Nagios).

http://docs.icinga.org/latest/en/cgiparams.html

http://docs.icinga.org/latest/en/cgicmd.html

share|improve this answer
add comment

You could look into http://<nagios-server>/cgi-bin/icinga/summary.cgi and select a report you want to see every day. After fiddling with the parameters, grab the URL of the generated report.

Now via cron do something like the following:

  • grab the report from said URL
  • if you want, preprocess and rearrange the html you just pulled down
  • send it via email
share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.