监控服务器-----nagios

一,监控服务器的作用

  监控内存,硬盘,cpu使用率等硬件条件 c/s模式

  使用自带的监控插件 对指定的监控对象做监控,当监控对象超过指定的阀时 就会触发警报 。web页面显示警告。 

  监控本地服务器

  监控网关服务器(公有资源/端口扫描信息等snmp,私有资源/ 硬盘 内存,进程数等)   

二,nagios安装

 

 yum -y install php gcc glibc glibc-common gd gd-devellibpng libjpeg zlib  (压缩) 

 yum -y install php-* 装上所有php包 装完php后重启web服务器

yum -y install libjpeg-turbo-* 装上图片包

安装httpd后启动报错httpd: Could not reliably determine the server's fully qualified domain name, using localhost.localdomain for ServerName

vim /etc/httpd/conf/httpd.conf  添加 servername localhost:80

 

解压nagios.tar.gz

安装nagios前添加用户 useradd -s /sbin/nologin  nagios

groupadd nagcmd

usermod -G nagcmd nagios

usermod -G nagcmd apache

进入文件

./configure --with-command-group=nagcmd

make all

make install-init

make install-config

make install-commandmode

make install-webconf

主配置文件

 

 监控模板

 

监控时间

nagios主要文件

$USER1$的定义位置 

 

 

启动时加载主配置文件 /usr/local/nagios/etc/nagios.cfg

libexec 插件目录

share网页文件

 var nagios运行时产生的临时文件

./etc/objects/ 各种监控配置

 

nagios-plug的安装

./configure --with-nagios-user=najgios --with-nagios-group=nagcmd

make && make install

 define command{

    command_name   定义监控命令名称

    command_line  监控命令功能(监控什么的)

        }

 

监控主机模板定义

define host{

use linux-server           

host_name localhost

alias localhost

address 127.0.0.1
}

监控对象模板

define service {

use local-service ; 对当前对象监控时指定的模板

host_name localhost   服务器主机名 (与host定义的主机名同步)

service_description PING 监控描述信息

check_command check_ping!100.0,20%!500.0,60%  调用的监控命令

}

 

配置网页文件

存在改文件的用户都有效 

根据上面文件提示 创建用户名密码

 

 

nagios无法获取被监控机的私有资源需要安装nrpe插件获取

客户端nrpe服务提交给服务端

安装前添加nagios用户和nagcmd组

之和和服务器端一样安装nagios-plugins-2.2.1插件

 

安装nrpe插件nrpe-3.2.1(安装前检查openssl-devel是否安装)

前面和普通编译安装一致

./configure make make install

make install-plugins

all builds nrpe and check_nrpe
nrpe builds nrpe only
check_nrpe builds check_nrpe only
install-groups-users add the users and groups if they do not exist
install install nrpe and check_nrpe
install-plugin install the check_nrpe plugin
install-daemon install the nrpe daemon
install-config install the nrpe configuration file
install-inetd install the startup files for inetd, launchd, etc.
install-init install the startup files for init, systemd, etc.

 修改该文件

 

 

 修改nrpe主配置文件

/usr/local/nagios/etc/nrpe.cfg

 

posted @ 2017-10-02 20:18  jack-toy  阅读(205)  评论(0编辑  收藏  举报