Nagios邮件报警

p.MsoNormal,li.MsoNormal,div.MsoNormal { margin: 0cm; margin-bottom: .0001pt; line-height: 150%; font-size: 13.5pt; font-family: "Calibri", "sans-serif" }
h1 { margin-top: 17.0pt; margin-right: 0cm; margin-bottom: 16.5pt; margin-left: 0cm; text-indent: 56.2pt; line-height: 240%; page-break-after: avoid; font-size: 22.0pt; font-family: "Calibri", "sans-serif" }
h2 { margin-top: 13.0pt; margin-right: 0cm; margin-bottom: 13.0pt; margin-left: 0cm; line-height: 172%; page-break-after: avoid; font-size: 18.0pt; font-family: "Calibri Light", "sans-serif" }
h3 { margin-top: 13.0pt; margin-right: 0cm; margin-bottom: 13.0pt; margin-left: 0cm; line-height: 172%; page-break-after: avoid; font-size: 16.0pt; font-family: "Calibri", "sans-serif" }
p.MsoHeader,li.MsoHeader,div.MsoHeader { margin: 0cm; margin-bottom: .0001pt; text-align: center; line-height: 150%; border: none; padding: 0cm; font-size: 9.0pt; font-family: "Calibri", "sans-serif" }
p.MsoFooter,li.MsoFooter,div.MsoFooter { margin: 0cm; margin-bottom: .0001pt; line-height: 150%; font-size: 9.0pt; font-family: "Calibri", "sans-serif" }
a:link,span.MsoHyperlink { color: #0563C1; text-decoration: underline }
a:visited,span.MsoHyperlinkFollowed { color: #954F72; text-decoration: underline }
span.MsoIntenseEmphasis { color: #5B9BD5; font-weight: bold; font-style: italic }
span.1Char
{ font-weight: bold }
span.2Char
{ font-family: "Calibri Light", "sans-serif"; font-weight: bold }
span.3Char
{ font-weight: bold }
span.Char { }
span.Char0 { }
.MsoChpDefault { font-size: 10.0pt; font-family: "Calibri", "sans-serif" }
.MsoPapDefault { line-height: 150% }
div.WordSection1 { }

Nagios邮件报警

准备

yum - y
install ntp        ntpdate
time.windows.com   同步时间,否则无法发送邮件

yum - y remove
postfix                                  由于系统默认安装了postfix
所以先卸载掉

安装sendmail

yum -y
install sendmail mail          安装sendmail 和mail

service
sendmail start                       启动sendmail

echo
"Hello World" | /bin/mail -s test darker_darker@163.com  发送测试邮件

编辑sendmail权限

sendmail 默认一般只让root使用,非root用户无法访问
/var/spool/mqueue

chmod 2755 /usr/sbin/sendmail.sendmail

chmod a+rwx /var/spool/mqueue

service
sendmail restart                                 重启sendmail

nagios配置文件

vim /usr/local/nagios/etc/objects/contacts.cfg

emaildarker_darker@163.com  darker_darker@139.com

修改email为自己的邮箱  可以空格后添加多个邮箱

/usr/local/nagios/bin/nagios
-v /usr/local/nagios/etc/nagios.cfg

service
nagios restart

然后测试nagios配置文件是否正常,重启nagios

Nagios邮件报警

service httpd stop                停止被监控端Web服务

邮箱报警

Nagios邮件报警

163和139同时收到了Mysql服务down掉

Nagios邮件报警

Mysql恢复后会发送邮件通知

其他参数

vim /usr/local/nagios/etc/objects/templates.cfg                 编辑模版

normal_check_interval

此选项是用来设置服务检查时间间隔,也就是说,nagios这一次检查和下一次检查之间所隔的时间,这里是10分钟。  一般设置为5分钟。         一般设置10分钟

报警延迟是由于host or service状态不稳定,nagios称之为flapping state

在nagios的主配置文件nagios.cfg中,有如下内容:

enable_flap_detection=0#虽然文档里说默认是0,但实际为1.改为0之后就解决了flapping state,并且解决了临时suppress notifications的问题

上一篇:使用TinkPHP实现品字形布局


下一篇:ListView排序并隔色显示