nagios是一款开源的企业级主机、服务应用程序和网络监控程序,它可以有效的监控Windows、Unix / Linux / BSD,网络和网络设备,快速灵活、可靠稳定!小编这里给大家带来最新nagios客户端,附安装配置教程,欢迎下载!
nagios功能特色
1、监控网络服务(SMTP、POP3、HTTP、NNTP、PING等);
2、监控主机资源(处理器负荷、磁盘利用率等);
3、简单地插件设计使得用户可以方便地扩展自己服务的检测方法;
4、并行服务检查机制;
5、具备定义网络分层结构的能力,用"parent"主机定义来表达网络主机间的关系,这种关系可被用来发现和明晰主机宕机或不可达状态;
6、当服务或主机问题产生与解决时将告警发送给联系人(通过EMail、短信、用户定义方式);
7、可以定义一些处理程序,使之能够在服务或者主机发生故障时起到预防作用;
8、自动的日志滚动功能;
9、可以支持并实现对主机的冗余监控;
10、可选的WEB界面用于查看当前的网络状态、通知和故障历史、日志文件等;
11、可以通过手机查看系统监控信息;
12、可指定自定义的事件处理控制器;
nagios客户端安装配置教程
(一)安装Nagios (Nagios服务器为:192.168.6.6 Nagios客户端为: 192.168.2.33)
1.基础支持套件:gcc glibc glibc-common gd gd-devel xinetd openssl-devel httpd php 注:php和httpd均用源码包安装,安装配置方法此处不在详述
# yum install -y gcc glibc glibc-common gd gd-devel xinetd openssl-devel
2.创建Nagios账户和组
#useradd -m nagios
#groupadd nagcmd
#usermod -a -G nagcmd nagios
#usermod -a -G nagcmd apache
3.编译安装
#tar xvf nagios-4.1.1.tar.gz
#cd nagios-4.1.1
#./configure prefix=/usr/local/nagios --with-command-group=nagcmd --with-nagios-user=nagios --with-nagios-group=nagios
#make all
#make install
#make install-init (生成init启动脚本)
#make install-config (生成一些模板配置文件)
#make install-commandmode (设置相应的权限)
#make install-webconf (生成Apache配置文件nagios.conf)
4.为Nagios设置Web验证的密码
#/usr/local/apache/bin/htpasswd -c /usr/local/nagios/etc/htpasswd.user nagiosadmin
5.设置Nagios的开机启动
chkconfig --add nagios
chkconfig nagios on
6.安装Nagios的插件nagios-plugin
#tar zxvf nagios-plugins-1.4.16.tar.gz
#cd nagios-plugins-1.4.16
#./configure --prefix=/usr/local/nagios --with-nagios-user=nagios --with-nagios-group=nagios
--with-apt-get-command --with-ping6-command --with-ping-command --with-mysql
--with-gnutls --enable-extra-opts
#make
#make install
7.此时完成初步安装,可以监控查看本机的一些服务,检测配置文件并启动nagios
#/usr/local/nagios/bin/nagios -v /usr/local/nagios/etc/nagios.cfg
Nagios Core 4.1.1
Copyright (c) 2009-2011 Nagios Core Development Team and Community Contributors
Copyright (c) 1999-2009 Ethan Galstad
Last Modified: 08-30-2013
License: GPL
. 配置apache并加载nagios登录页面
找到apache 的配置文件/usr/local/apache/conf/httpd.conf
找到:
User daemon
Group daemon 修改为
User nagios
Group nagios
为了安全起见,一般情况下要让nagios 的web 监控页面必须经过授权才能访问,这需要增加验证配置,即在httpd.conf 文件最后添加如下信息:
下面信息在编译nagios(make install-webconf )时就已经生成,配置信息在:/etc/httpd/confd.d/nagios.conf 文件中
#######################################################################
#setting for nagios
ScriptAlias /nagios/cgi-bin "/usr/local/nagios/sbin"
<Directory "/usr/local/nagios/sbin">
AuthType Basic
Options ExecCGI
AllowOverride None
Order allow,deny
Allow from all
AuthName "Nagios Access"
AuthUserFile /usr/local/nagios/etc/htpasswd.user
Require valid-user
</Directory>
Alias /nagios "/usr/local/nagios/share"
<Directory "/usr/local/nagios/share">
AuthType Basic
Options None
AllowOverride None
Order allow,deny
Allow from all
AuthName "nagios Access"
AuthUserFile /usr/local/nagios/etc/htpasswd.user
Require valid-user
</Directory>
9.重启nagios、apache并访问nagios
#service nagios restart
#/usr/local/apache/bin/apachectl restart
http://192.168.6.6/nagions
提示输入用户名密码,访问成功
但是登陆进去后,nagios页面右侧全部乱码
解决方法:
主要是apache没有开启cgi脚本的缘故
进入apache的主配置文件httpd.conf
#vim /usr/local/apache/conf/httpd.conf
#LoadModule cgid_module modules/mod_cgid.so
#LoadModule actions_module modules/mod_actions.so
将上面2行的#去掉,重启apache就OK
再次访问 ,乱码消失OK!
(二)配置Nagios
1.nagios配置目录信息
# cd /usr/local/nagios/etc/
# ls
cgi.cfg htpasswd.user nagios.cfg objects resource.cfg
[root@localhost etc]# ll
total 68
-rw-rw-r-- 1 nagios nagios 11669 Nov 29 14:18 cgi.cfg (CGI配置文件)
-rw-r--r-- 1 root root 50 Nov 29 14:20 htpasswd.user (Apache的验证密码文件)
-rw-rw-r-- 1 nagios nagios 44710 Nov 29 14:18 nagios.cfg (主配置文件)
drwxrwxr-x 2 nagios nagios 4096 Nov 29 14:18 objects (对象定义文件目录)
-rw-rw---- 1 nagios nagios 1340 Nov 29 14:18 resource.cfg (资源配置文件)
2.修改nagios.cfg主配置文件
#vim nagios.cfg
注释掉:cfg_file=/usr/local/nagios/etc/objects/localhost.cfg ———— #cfg_file=/usr/local/nagios/etc/objects/localhost.cfg
将 #cfg_dir=/usr/local/nagios/etc/servers 的 #(注释)去掉 ----- cfg_dir=/usr/local/nagios/etc/servers
在/usr/local/nagios/etc/目录中新建 servers子目录,在里面可以直接添加主机配置文件
#mkdir servers
3.配置object目录中的配置文件
#cd objects/
#ll
total 48
-rw-rw-r-- 1 nagios nagios 7716 Nov 29 14:18 commands.cfg (命令定义文件)
-rw-rw-r-- 1 nagios nagios 2166 Nov 29 14:18 contacts.cfg (联系人信息定义文件)
-rw-rw-r-- 1 nagios nagios 5403 Nov 29 14:18 localhost.cfg
-rw-rw-r-- 1 nagios nagios 3124 Nov 29 14:18 printer.cfg
-rw-rw-r-- 1 nagios nagios 3293 Nov 29 14:18 switch.cfg
-rw-rw-r-- 1 nagios nagios 10812 Nov 29 14:18 templates.cfg
-rw-rw-r-- 1 nagios nagios 3208 Nov 29 14:18 timeperiods.cfg (时间周期定义文件)
-rw-rw-r-- 1 nagios nagios 4019 Nov 29 14:18 windows.cfg
配置联系人信息(邮件接收者邮箱地址)
联系人定义:
#vim contacts.cfg
将 email 字段后边的 nagios@localhost 改成自己的邮箱,将报警信息发送的此邮箱,比如 15566058@139.com
如果是设置提醒多个邮箱可以在后跟其它邮箱地址,以逗号隔开,比如: 15566058@139.com,abc@163.com保存,退出。
nagios配置sendmail邮件告警
1、检查commands.cfg
# 'notify-host-by-email' command definition
define command{
command_name notify-host-by-email
command_line /usr/bin/printf "%b" "***** Nagios *****\n\nNotification
Type: $NOTIFICATIONTYPE$\nHost: $HOSTNAME$\nState: $HOSTSTATE$\nAddress: $HOSTA
DDRESS$\nInfo: $HOSTOUTPUT$\n\nDate/Time: $LONGDATETIME$\n" | /bin/mail -s "** $
NOTIFICATIONTYPE$ Host Alert: $HOSTNAME$ is $HOSTSTATE$ **" $CONTACTEMAIL$
}
# 'notify-service-by-email' command definition
define command{
command_name notify-service-by-email
command_line /usr/bin/printf "%b" "***** Nagios *****\n\nNotification
Type: $NOTIFICATIONTYPE$\n\nService: $SERVICEDESC$\nHost: $HOSTALIAS$\nAddress:
$HOSTADDRESS$\nState: $SERVICESTATE$\n\nDate/Time: $LONGDATETIME$\n\nAdditional
Info:\n\n$SERVICEOUTPUT$" | /bin/mail -s "** $NOTIFICATIONTYPE$ Service Alert:
$HOSTALIAS$/$SERVICEDESC$ is $SERVICESTATE$ **" $CONTACTEMAIL$
}
这是正确的命令配置,其中最重要的就是/bin/mail后边的命令配置
2、mqueue
[root@localhost mqueue]# pwd
/var/spool/mqueue
[root@localhost mqueue]# ll
total 8
-rw------- 1 root smmsp 8 Nov 18 20:54 dfmAICsFQj009878
-rw------- 1 root smmsp 901 Nov 18 21:56 qfmAICsFQj009878
[root@localhost mqueue]#
这个目录存储的是邮件发送队列,如果这个里边满了不但会影响程序的运行,而且sendmail容易死掉,所以必要的时候要删除。
3、修改access
[root@localhost mail]# pwd
/etc/mail
[root@localhost mail]# vi access
# Check the /usr/share/doc/sendmail/README.cf file for a description
# of the format of this file. (search for access_db in that file)
# The /usr/share/doc/sendmail/README.cf is part of the sendmail-doc
# package.
#
# by default we allow relaying from localhost...
Connect:localhost.localdomain RELAY
Connect:localhost RELAY
Connect:127.0.0.1 RELAY
Connect:192.168.0 RELAY
Connect:http://www.163.com RELAY
Connect:1.1.1 RELAY
Connect:nagios@localhost.localdomain RELAY
Connect:root@localhost RELAY
然后执行makemap hash access < access
或者是makemap -v hash /etc/mail/access.db < /etc/mail/access
4、[root@localhost spool]# pwd
/var/spool
chmod 777 mqueue
我的邮箱是163.com。
5、. 检查所传送的电子邮件是否送出,或滞留在邮件服务器中
语法:/usr/lib/sendmail -bp
若屏幕显示为“Mail queue is empty” 的信息,表示mail 已送出。
6检查邮件发送过程
在Sendmail邮件服务器上执行下面的命令.
# echo testing | /usr/sbin/sendmail -v someone@somedomain.com
7、sendmail日志
[root@localhost log]# pwd
/var/log
vi maillog就可以看了,出现任何错误都可以看到。
- PC官方版
- 安卓官方手机版
- IOS官方手机版