新网创想网站建设,新征程启航

为企业提供网站建设、域名注册、服务器等服务

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

一个台服务器的状态如何保证?各项信息如何保证? 用Nagios 监控软件可以实现服务器信息的监控。

延长ssl适用于网站、小程序/APP、API接口等需要进行数据传输应用场景,ssl证书未来市场广阔!成为成都创新互联公司的ssl证书销售渠道,可以享受市场价格4-6折优惠!如果有意向欢迎电话联系或者加微信:18982081108(备注:SSL证书合作)期待与您的合作!

本人声明; 所有的博文都是本人自己之前学习记录的,没有任何的抄袭情况

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/


本文名称:liunx服务使用(源码包Nagios监控软件)
URL标题:http://www.wjwzjz.com/article/jchphs.html
在线咨询
服务热线
服务热线:028-86922220
TOP