第4步.nagios配置邮件服务器设置预警和其他补充问题

第4步.nagios配置邮件服务器设置预警和其他补充问题

本文分三篇文章来讲
1.nagios的安装
2.nagios配置监控本地localhost
3.nagios配置监控远程
4.nagios配置邮件服务设置预警和其他补充问题

一、配置邮件报警验证:

1,确认至少有一个服务为crital状态

2,安装postfix

yum install postfix -y
service postfix  restart
chkconfig postfix on

3,保证nagios服务器能上公网,还有确认有mail命令了


4,修改邮件接收人

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

 email                           xxxxxxx@126.com –改成你的一个公网测试邮箱

5,重启服务

/etc/init.d/nagios restart

如果你想做成免费手机短信通知,可以使用类似139邮箱这种(有邮件到达就短信通知的功能)的邮箱

现在有智能手机就方便多了,直接报警邮件发给外部一个邮箱,然后在你的手机上下载对应邮箱的app软件就ok了
现在nagios官方直接都有手机客户端管理软件

=======================================================================


二、nagiosgraph 让nagios能够图形监控服务动态的状态信息

nagiosgraph-1.4.4.tar.gz
tar xf nagiosgraph-1.4.4.tar.gz -C /usr/src
cd /usr/src/nagiosgraph-1.4.4
 ./install.pl --check-prereq
checking required PERL modules
  Carp...1.11
  CGI...3.51
  Data::Dumper...2.124
  File::Basename...2.77
  File::Find...1.14
  MIME::Base64...3.08
  POSIX...1.17
  RRDs... ***FAIL***   --没有rrd,就算你在rhel6上yum install *rrd*  再来测试也是fail
  Time::HiRes...1.9721
checking optional PERL modules
  GD...fail --没有gd,yum install *gd* 也不能搞定
checking nagios installation
  found nagios at /usr/local/nagios/bin/nagios
checking web server installation
  found apache at /usr/sbin/httpd

安装gd

tar xf libgd-2.1.0.tar.gz -C /usr/src/
cd /usr/src/libgd-2.1.0/
./configure ;make ;make install
echo /usr/local/lib >> /etc/ld.so.conf
ldconfig
tar xf GD-2.56.tar.gz -C /usr/src/
cd /usr/src/GD-2.56/
perl Build.PL
./Build
./Build install
ldconfig


安装rrdtool

# tar xf rrdtool-1.4.8.tar.gz -C /usr/src/
# cd /usr/src/rrdtool-1.4.8/
# ./configure ;make ;make install
# echo /opt/rrdtool-1.4.8/lib > /etc/ld.so.conf.d/rrdtools.conf
# ldconfig
# cd /usr/src/rrdtool-1.4.8/bindings/perl-shared
# make clean
# perl Makefile.PL && make && make install
# cd /usr/src/nagiosgraph-1.4.4/

–再次用下面的命令检测就都OK了

[root@li nagiosgraph-1.4.4]# ./install.pl --check-prereq
checking required PERL modules
  Carp...1.11
  CGI...3.51
  Data::Dumper...2.124
  File::Basename...2.77
  File::Find...1.14
  MIME::Base64...3.08
  POSIX...1.17
  RRDs...1.4008
  Time::HiRes...1.9721
checking optional PERL modules
  GD...2.56
checking nagios installation
  found nagios at /usr/local/nagios/bin/nagios
checking web server installation
  found apache at /usr/sbin/httpd


————


参考下面这份文档
http://www.linuxfunda.com/2013/04/02/steps-to-configure-nagiosgraph-with-nagios-core/

开始安装

[root@qianyun nagiosgraph-1.4.4]# ./install.pl --install
checking required PERL modules
  Carp...1.11
  CGI...3.51
  Data::Dumper...2.124
  File::Basename...2.77
  File::Find...1.14
  MIME::Base64...3.08
  POSIX...1.17
  RRDs...1.4008
  Time::HiRes...1.9721
checking optional PERL modules
  GD...2.53
checking nagios installation
  found nagios at /usr/local/nagios/bin/nagios
checking web server installation
  found apache at /usr/sbin/httpd
Destination directory (prefix)? [/usr/local/nagiosgraph]
Location of configuration files (etc-dir)? [/usr/local/nagiosgraph/etc]
Location of executables? [/usr/local/nagiosgraph/bin]
Location of CGI scripts? [/usr/local/nagiosgraph/cgi]
Location of documentation (doc-dir)? [/usr/local/nagiosgraph/doc]
Location of examples? [/usr/local/nagiosgraph/examples]
Location of CSS and JavaScript files? [/usr/local/nagiosgraph/share]
Location of utilities? [/usr/local/nagiosgraph/util]
Location of state files (var-dir)? [/usr/local/nagiosgraph/var]
Location of RRD files? [/usr/local/nagiosgraph/var/rrd]
Location of log files (log-dir)? [/usr/local/nagiosgraph/var]
Path of log file? [/usr/local/nagiosgraph/var/nagiosgraph.log]
Path of CGI log file? [/usr/local/nagiosgraph/var/nagiosgraph-cgi.log]
URL of CGI scripts? [/nagiosgraph/cgi-bin]
URL of CSS file? [/nagiosgraph/nagiosgraph.css]
URL of JavaScript file? [/nagiosgraph/nagiosgraph.js]
Path of Nagios performance data file? [/tmp/perfdata.log]
URL of Nagios CGI scripts? [/nagios/cgi-bin]
username or userid of Nagios user? [nagios]
username or userid of web server user? [apache]
Modify the Nagios configuration? [n]
Modify the Apache configuration? [n]
configuration:
  ng_layout            standalone
  ng_prefix            /usr/local/nagiosgraph
  ng_etc_dir           /usr/local/nagiosgraph/etc
  ng_bin_dir           /usr/local/nagiosgraph/bin
  ng_cgi_dir           /usr/local/nagiosgraph/cgi
  ng_doc_dir           /usr/local/nagiosgraph/doc
  ng_examples_dir      /usr/local/nagiosgraph/examples
  ng_www_dir           /usr/local/nagiosgraph/share
  ng_util_dir          /usr/local/nagiosgraph/util
  ng_var_dir           /usr/local/nagiosgraph/var
  ng_rrd_dir           /usr/local/nagiosgraph/var/rrd
  ng_log_dir           /usr/local/nagiosgraph/var
  ng_log_file          /usr/local/nagiosgraph/var/nagiosgraph.log
  ng_cgilog_file       /usr/local/nagiosgraph/var/nagiosgraph-cgi.log
  ng_url               /nagiosgraph
  ng_cgi_url           /nagiosgraph/cgi-bin
  ng_css_url           /nagiosgraph/nagiosgraph.css
  ng_js_url            /nagiosgraph/nagiosgraph.js
  nagios_cgi_url       /nagios/cgi-bin
  nagios_perfdata_file /tmp/perfdata.log
  nagios_user          nagios
  www_user             apache
  modify_nagios_config n
  nagios_config_file
  nagios_commands_file
  modify_apache_config n
  apache_config_dir
  apache_config_file
Continue with this configuration? [y]
.............
2,
# vim /usr/local/nagios/etc/nagios.cfg --最后加上下面一段
process_performance_data=1
service_perfdata_file=/tmp/perfdata.log
service_perfdata_file_template=$LASTSERVICECHECK$||$HOSTNAME$||$SERVICEDESC$||$SERVICEOUTPUT$||$SERVICEPERFDATA$
service_perfdata_file_mode=a
service_perfdata_file_processing_interval=30
service_perfdata_file_processing_command=process-service-perfdata-for-nagiosgraph
3,
# vim /usr/local/nagios/etc/objects/commands.cfg  --加上这一段,定义此命令
define command {
command_name process-service-perfdata-for-nagiosgraph
command_line /usr/local/nagiosgraph/bin/insert.pl
}
4,
# vim /etc/httpd/conf/httpd.conf  --在你的apache里include这个文件
Include /usr/local/nagiosgraph/etc/nagiosgraph-apache.conf
# /etc/init.d/httpd  restart
# /etc/init.d/nagios  restart
5,
http://192.168.1.8/nagiosgraph/cgi-bin/showconfig.cgi --用此页面查看信息
# vim /usr/local/nagios/etc/objects/templates.cfg --加上下面的模版
define service {
name nagiosgraph
action_url /nagiosgraph/cgi-bin/show.cgi?host=$HOSTNAME$&service=$SERVICEDESC$
register 0
}
6,
# vim /usr/local/nagios/etc/objects/localhost.cfg   --在你所有的要加图形的监控主机里的服务的use后加上nagiosgraph模版,如下
define service{
        use                             local-service,nagiosgraph
        host_name                       localhost
        service_description             PING
        check_command                   check_ping!100.0,20%!500.0,60%
        }
7,
# /etc/init.d/nagios restart

最后到你的http://192.168.1.8/nagios/下去查看,会发现只要加了nagiosgraph模版的被监控服务会多了一个图标,按图标就会产生图形

暂无评论

发送评论 编辑评论


				
|´・ω・)ノ
ヾ(≧∇≦*)ゝ
(☆ω☆)
(╯‵□′)╯︵┴─┴
 ̄﹃ ̄
(/ω\)
∠( ᐛ 」∠)_
(๑•̀ㅁ•́ฅ)
→_→
୧(๑•̀⌄•́๑)૭
٩(ˊᗜˋ*)و
(ノ°ο°)ノ
(´இ皿இ`)
⌇●﹏●⌇
(ฅ´ω`ฅ)
(╯°A°)╯︵○○○
φ( ̄∇ ̄o)
ヾ(´・ ・`。)ノ"
( ง ᵒ̌皿ᵒ̌)ง⁼³₌₃
(ó﹏ò。)
Σ(っ °Д °;)っ
( ,,´・ω・)ノ"(´っω・`。)
╮(╯▽╰)╭
o(*////▽////*)q
>﹏<
( ๑´•ω•) "(ㆆᴗㆆ)
😂
😀
😅
😊
🙂
🙃
😌
😍
😘
😜
😝
😏
😒
🙄
😳
😡
😔
😫
😱
😭
💩
👻
🙌
🖕
👍
👫
👬
👭
🌚
🌝
🙈
💊
😶
🙏
🍦
🍉
😣
Source: github.com/k4yt3x/flowerhd
颜文字
Emoji
小恐龙
花!
上一篇
下一篇