nagios安装使用
来源:互联网 发布:上海电信网络套餐介绍 编辑:程序博客网 时间:2024/05/18 06:21
nagios
nagios自身在ubuntu上的安装可参照http://nagios.sourceforge.net/docs/3_0/quickstart-ubuntu.html
NRPE安装参照http://blog.c1gstudio.com/archives/559 , 另在此之前安装libssl-dev
percona monitoring plugin 可参见http://www.percona.com/software/percona-monitoring-plugins/ , can integrate with nagios
其实我就是一个网络搬运工
安装
in nagios server (ubuntu 12.04):
机器A, ip 172.16.21.119
apt-get install libssl-dev openssl
dpkg -L libssl-dev #see libssl.so real path
ln -s /usr/lib/x86_64-linux-gnu/libssl.so /usr/lib/libssl.so
apt-get install apache2 libapache2-mod-php5 build-essential libgd2-xpm-dev
useradd -m -s /bin/bash nagios
passwd nagios
groupadd nagcmd
usermod -a -G nagcmd nagios
usermod -a -G nagcmd www-data
mkdir ~/downloads && cd ~/downloads
wget http://prdownloads.sourceforge.net/sourceforge/nagios/nagios-3.2.3.tar.gz
wget https://www.nagios-plugins.org/download/nagios-plugins-1.5.tar.gz
tar xvf nagios-3.2.3.tar.gz
cd nagios-3.2.3
./configure –with-command-group=nagcmd
make all
make install
make install-init
make install-config
make install-commandmode
vim /usr/local/nagios/etc/objects/contacts.cfg #and change email address associated with nagiosadmin
make install-webconf
htpasswd -c /usr/local/nagios/etc/htpasswd.users nagiosadmin #and remember the password
/etc/init.d/apache2 reload
cd ..
tar xvf nagios-plugins-1.5.tar.gz
cd nagios-plugins-1.5
./configure –with-nagios-user=nagios –with-nagios-group=nagios
make
make install
ln -s /etc/init.d/nagios /etc/rcS.d/S99nagios
/usr/local/nagios/bin/nagios -v /usr/local/nagios/etc/nagios.cfg
/etc/init.d/nagios start
cd ..
wget http://sourceforge.net/projects/nagios/files/nrpe-2.x/nrpe-2.15/nrpe-2.15.tar.gz
tar xvf nrpe-2.12.tar.gz
cd nrpe-2.12
./configure –prefix=/usr/local/nagios
make all
make install-plugin
/usr/local/nagios/libexec/check_nrpe -H xxx.xxx.xxx.xxx #after nagios client run nrpe deamon, use this to check, xxx.xxx.xxx.xxx is client ip
vim /usr/local/nagios/etc/objects/commands.cfg , add:
vim /usr/local/nagios/etc/objects/hostA.cfg , add:
echo “cfg_file=/usr/local/nagios/etc/objects/hostA.cfg” >> /usr/local/nagios/etc/nagios.cfg
service nagios reload
see nagios web interface at http://localhost/nagios/
in nagios client(ubuntu 12.04):
机器B, ip 172.16.21.59
apt-get install libssl-dev openssl
dpkg -L libssl-dev #see libssl.so real path
ln -s /usr/lib/x86_64-linux-gnu/libssl.so /usr/lib/libssl.so
groupadd nagios
useradd -g nagios -d /usr/local/nagios -s /sbin/nologin nagios
wget https://www.nagios-plugins.org/download/nagios-plugins-1.5.tar.gz
tar xvf nagios-plugins-1.5.tar.gz
cd nagios-plugins-1.5
./configure –with-nagios-user=nagios –with-nagios-group=nagios –prefix=/usr/local/nagios –with-ping-command=”/bin/ping”
make
make install
ls /usr/local/nagios/libexec #check
cd ..
wget http://sourceforge.net/projects/nagios/files/nrpe-2.x/nrpe-2.15/nrpe-2.15.tar.gz
tar xvf nrpe-2.12.tar.gz
cd nrpe-2.12
./configure –prefix=/usr/local/nagios
make all
make install-plugin
make install-daemon
make install-daemon-config
chown -R nagios:nagios /usr/local/nagios
vi /usr/local/nagios/etc/nrpe.cfg
allowed_hosts=127.0.0.1,172.16.21.119echo ‘nrpe:192.172.16.21.119’ >> /etc/hosts.allow
/usr/local/nagios/bin/nrpe -c /usr/local/nagios/etc/nrpe.cfg -d
/usr/local/nagios/libexec/check_nrpe -H 127.0.0.1 #check
netstat -an | grep 5666 #check
echo “/usr/local/nagios/bin/nrpe -c /usr/local/nagios/etc/nrpe.cfg -d” >> /etc/rc.local #开机启动
some additions
添加更多监控项
以添加check_procs举例
B:
vim /usr/local/nagios/etc/nrpe.cfg ,add
ps aux | grep nagios
kill -9 xxxx #xxxx is nagios pid
/usr/local/nagios/bin/nrpe -c /usr/local/nagios/etc/nrpe.cfg -d #重启
A:
vim /usr/local/nagios/etc/objects/hostA.cfg ,add
service nagios reload
自定义监控
功能强大的Nagios网络监控平台让你可以为其功能增添一系列可用插件。如果你找不到可以满足自身要求的一款插件,也很容易自行编写.
Nagios插件可以用任何一门编程语言来编写,只要该编程语言在运行Nagios的平台上得到支持。Bash是用来编写Nagios插件的一门流行语言,因为它功能强大、使用简单。
借助插件进行的每一次有效的Nagios检查(Nagios check)都会生成一个数字表示的退出状态。可能的状态有:
- 0–各方面都正常,检查成功完成。
- 1–资源处于警告状态。某个地方不太妙。
- 2–资源处于临界状态。原因可能是主机宕机或服务未运行。
- 3–未知状态,这未必表明就有问题,而是表明检查没有给出一个清楚明确的状态。
插件还能输出文本消息。默认情况下,该消息显示在Nagios web界面和Nagios邮件警报信息中。尽管消息并不是硬性要求,你通常还是可以在可用插件中找到它们,因为消息告诉用户出了什么岔子,而不会迫使用户查阅说明文档。
an simple example write by shell to check nginx
vim /usr/local/nagios/libexec/check_nginx
脚本需要可执行权限, 然后和上面添加权限一样添加入nagios即可
邮件报警
http://my.oschina.net/u/615185/blog/69699
nagios发邮件默认是使用本机的smtp服务,需要安装sendmail,但也可以更改commands.cfg中发邮件的命令,使用第三方邮件服务器,这样就不用自己搭建邮件服务器了,但也要注意第三方服务和网络的稳定性。
这里我使用163做邮件服务器,用sendEmail_ 作为客户端来发送邮件
163邮件服务器: smtp.163.com 用户 xxx@163.com 密码 xxx
wget http://caspian.dotconf.net/menu/Software/SendEmail/sendEmail-v1.56.tar.gz
tar xvf sendEmail-v1.56.tar.gz
cd sendEmail-v1.56
./sendEmail -v -f xxx@163.com -t yyy@gmail.com -u “from nagios” -s smtp.163.com -xu xxx@163.com -xp xxx -m “test sendEmail” #test
如果发邮件成功则 cp sendEmail /usr/local/bin
chmod +x /usr/local/bin/sendEmail
现在开始配置nagios中邮件报警
cd /usr/local/nagios/
vim etc/objects/contacts.cfg
在email那里加上自己的邮箱,如果有多个可以用逗号隔开
修改etc/objects/commands.cfg中notify_host_by_email和notify_service_by_email:
service nagios reload
关闭某些服务或重启nagios client机器测试下报警功能
- nagios安装使用
- nagios应用3- 插件的安装使用
- Nagios 安装、配置和使用 操作
- nagios 中安装和使用nrpe
- Nagios 安装、配置和使用 操作
- 使用 Ansible 编译和安装 nagios
- 安装Nagios
- nagios 安装
- nagios 安装
- nagios安装
- nagios安装
- 安装nagios
- nagios 安装
- nagios安装
- Nagios安装
- 安装NAGIOS
- nagios 安装
- nagios安装
- Android Cursor 泄漏检测
- mfc button 重绘
- A collection of iOS7 animation controllers and interaction controllers, providing flip, fold and all
- Qt中Signal与Slot参数问题<一>
- 软件测试面试 (一) 如何测试一个杯子
- nagios安装使用
- ubuntu 12.04 14.04,14.10 打开windows下txt乱码解决方法!
- 输出星号
- Keytool的使用总结
- Cocos2d-x 动作之创建自定义动作
- mini2440 usb host device controller驱动分析(二) -----数据(urb)的收发流程
- 矩阵连乘问题
- 软件测试面试 (二) 如何测试网页的登录页面
- 第七周项目3-求三数最大