您的位置:首页 > 移动开发 > IOS开发

liunx服务使用( 源码包 Nagios 监控软件)

2013-09-13 19:48 399 查看
一个台服务器的状态如何保证?各项信息如何保证? 用Nagios 监控软件可以实现服务器信息的监控。
本人声明; 所有的博文都是本人自己之前学习记录的,没有任何的抄袭情况

Nagios 监控软件

开始安装
安装nagios-3.2.1.tar.gz到/usr/local/src

先解压
tar -zxvf nagios-3.2.1.tar.gz -C /usr/local/src/
tar -zxvf nagios-plugins-1.4.14.tar.gz -C /usr/local/src/

文档所在位置
/usr/local/src/nagios-3.2.1/html/docs
firefox index.html

------------------------------------

useradd nagios 添加这个用户
passwd nagios
/usr/sbin/groupadd nagcmd 创建组
/usr/sbin/usermod -a -G nagcmd nagios 该拥有者 添加到组里
/usr/sbin/usermod -a -G nagcmd apache 该拥有者
建立nagios用户 并设置密码 建立nagcmd组 并且将该组设置为nagios apache用的附加组

到nagios-3.2.1解压目录进行安装
./configure --with-command-group=nagcmd

make all 编译软件`
make install 安装软件
make install-init 生成启动文件
make install-config 生成配置文件
make install-commandmode 设置组的执行权限
make install-webconf

htpasswd -c /usr/local/nagios/etc/htpasswd.users nagiosadmin 用户必须是这个

service httpd restart

-------------------------------------------------------------

插件的安装
nagios-plugins-1.4.14.tar 解压缩 /usr/local/src下

./configure --with-nagios-user=nagios --with-nagios-group=nagios
make
make install

chkconfig --add nagios 添加服务启动

chkconfig nagios on 打开服务

service nagios restart

访问http://192.168.1.113/nagios

-----------------------------------------

配置检测对象
vim /usr/local/nagios/etc/objects/ localhost.cfg
cp localhost.cfg 192.168.1.196.cfg

vim 192.168.1.196.cfg 自定自己要图形里要监控的东西

3 define host{
4 use linux-server
5 host_name testserver
6 alias host196
7 address 192.168.1.196
}

让配置文件监控自己定义的文件
vim /usr/local/nagios/etcetc/nagios.cfg
36 复制
37 添加
36 cfg_file=/usr/local/nagios/etc/objects/localhost.cfg
37 cfg_file=/usr/local/nagios/etc/objects/192.168.1.102.cfg

/usr/local/nagios/bin/nagios -v /usr/local/nagios/etc/nagios.cfg
检测nagios的配置文件是否正常后 启动nagios

重启服务
service nagios restart

测试
访问http://192.168.1.113/nagios

-----------------------------------

nagios.cfg 主配置文件

localhost.cfg 主机文件

templates.cfg 模板

timeperiods.cfg周期

commands 命令
/usr/local/nagios/ libexec 插件

-------------------
在图形里添加新的功能
192.168.1.102.cfg 主机文件

91 define service{
92 use local-service
93 host_name peng
94 service_description NFS --图形上显示的名字
95 check_command check_nfs --对应 命令名字
96 notifications_enabled 0
97 }

commands 命令

241 define command{
242 command_name check_nfs --这个名字对应下面的模块
243 command_line $USER1$/check_http -H 192.168.1.102 -p 2049
244 }

/usr/local/nagios/ libexec 插件

-----------------------------------
-----------------------------------
远程私有信息

安装openssl包
yum install openssl openssl-devel

server端
安装nrpe

tar -zxvf nrpe-2.12.tar.gz -C /usr/local/src
./configure && make all && make install
make install-plugin 设置插件权限

定义nrpe
cd /usr/local/nagios/etc/objects
vim commands.cfg 在该文件最末行后定义check_nrpe插件的调用参数

define command{
command_name check_nrpe
com m an d_line $USER1$/check_nrpe -H $HOSTADDRESS$ -c $ARG1$
}

定义监控主机台主机
cd /usr/local/nagios/etc/objects/
vim 192.168.1.100.cfg

define service{
use local-service
host_name ZHB-linux
service_description boot Partition
check_command check_nrpe!check_boot
}

定义调用命令及参数check_root 该参数会在客户端定义相对应的命令以达到通过该参数检测客户端硬盘使用率的信息

命令作用同上,server端同上

---------------------------------
client端

安装nagios-plugins包
useradd nagios 添加用户以及组
groupadd nagcmd
usermod -G nagcmd nagios
编译并且安装
/usr/local/src/nagios-plugins-1.4.14/
./configure && make && make install

安装nrpe
tar zxvf nrpe-2.12.tar.gz -C /usr/local/src
./configure && make all && make install
make install-plugin 安装进程
make install-daemon 安装守护进程
make install-daemon-config 安装守护进程的配置文件
make install-xinetd 产生xinetd的配置文件nrpe

安装xinetd
yum install xinetd
设置nrpe及启动
在源文件/etc/xinet.d/nrpe文件里
only_from =127.0.0.1 192.168.1.102 后添加 192.168.1.113(自己的127.0.0.1和对方IP)

添加nrpe对应的端口(必须做)
vi /etc/services (该文件记录系统中所有服务的端口)
nrpe 5666/tcp # NRPE

定义nrpe命令(check_root)
cd /usr/local/nagios/etc
vi nrpe.cfg 该文件用与定义客户端的命令调用
command[check_users]=/usr/local/nagios/libexec/check_users -w 5 -c 10 (默认已写好)
command[check_load]=/usr/local/nagios/libexec/check_load -w 15,10,5 -c 30,25,20
command[check_zombie_procs]=/usr/local/nagios/libexec/check_procs -w 5 -c 10 -s Z
command[check_total_procs]=/usr/local/nagios/libexec/check_procs -w 150 -c 200

command[check_boot]=/usr/local/nagios/libexec/check_disk -w 20% -c 10% -p /boot (新加对应文件)

启动nrpe
service xinetd restart

netstat -anplt | grep 5666 查看端口是否打开
tcp 0 0 0.0.0.0:5666 0.0.0.0:* LISTEN 21403/xinetd

测试nrpe
./check_nrpe -H 127.0.0.1
得到结果NRPE v2.12

服务端
/usr/local/nagios/bin/nagios -v /usr/local/nagios/etc/nagios.cfg 检测文件时候正确
service nagios restart
访问http://192.168.1.160/nagios/

本文出自 “history_xcy” 博客,请务必保留此出处http://historys.blog.51cto.com/7903899/1296690
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: