完整安装nagios+邮件报警

2026/1/25 4:57:32

完整安装nagios+cacti+短信和邮件报警

一:安装nagios中用到的其他软件和库文件

yum -y install httpd gcc glibc glibc-common gd gd-devel php php-mysql mysql mysql-server mysql-devel openssl-devel

二:安装和配置nagios3.4.1监控主程序 2.1建立用户和组 groupadd nagcmd useradd –m nagios

usermod -a -G nagcmd nagios usermod -a -G nagcmd apache 2.2下载最新版nagios3.4.1 mkdir downloads

wgethttp://prdownloads.sourceforge.net/sourceforge/nagios/nagios-3.4.1.tar.gz 2.3 编译安装 cd downloads

tar –zxvf nagios-3.4.1.tar.gz cd nagios

默认安装至/usr/local/nagios/

./configure --with-command-group=nagcmd --enable-event-broker

make all && make install && make install-init && make install-config && make install-commandmode && make install-webconf

WEB界面的用户名和密码

htpasswd -c /usr/local/nagios/etc/htpasswd.users nagiosadmin 输入密码并确认 service httpd restart chkconfig httpd on

三:编译安装nagios-plugins-1.4.16 3.1下载最新版本nagios-plugins-1.4.16 cd downloads

wget http://prdownloads.sourceforge.net/sourceforge/nagiosplug/nagios-plugins-1.4.16.tar.gz cd nagios-plugins-1.4.16

./configure --with-nagios-user=nagios --with-nagios-group=nagcmd --with-mysql make && make install chkconfig --add nagios chkconfig nagios on

vim /etc/profile

加入PATH=$PATH:/usr/local/nagios/bin

检查nagios语法是否正确

nagios -v /usr/local/nagios/etc/nagios.cfg

service nagios start

3.2 关闭selinux 及修改iptables或关闭iptables 关闭selinux的方法 vi /etc/sysconfig/selinux添加 SELINUX=disabled

iptables建议开启,然后允许需要开启的端口,一般nagios需要的端口是80和5666(nrpe) vi /etc/sysconfig/iptables

service httpd restart 此时已经能从浏览器访问http://****/nagios默认用户名nagiosadmin 密码是之前输入过的。

四:监控nagios本机

创建fund123目录,用于存放所有相关配置文件 cd /usr/local/nagios/etc/ mkdir fund123

cd /usr/local/nagios/etc/objects cp -v -R * /usr/local/nagios/etc/fund123/ 文件和目录修改下权限

chown -R nagios:nagios fund123

修改主配置文件nagios.cfg,修改之前最好先备份下 vi /usr/local/nagios/etc/nagios.cfg 修改成

cfg_file=/usr/local/nagios/etc/fund123/commands.cfg cfg_file=/usr/local/nagios/etc/fund123/contacts.cfg cfg_file=/usr/local/nagios/etc/fund123/timeperiods.cfg cfg_file=/usr/local/nagios/etc/fund123/templates.cfg cfg_file=/usr/local/nagios/etc/fund123/contactgroups.cfg cfg_file=/usr/local/nagios/etc/fund123/hostgroups.cfg cfg_file=/usr/local/nagios/etc/fund123/servicegroups.cfg cfg_dir=/usr/local/nagios/etc/fund123/servers/ cfg_dir=/usr/local/nagios/etc/fund123/services/

注释掉#cfg_file=/usr/local/nagios/etc/objects/localhost.cfg

cp objects/localhost.cfg fund123/servers/local-nagios.cfg vi local-nagios.cfg

# Define a host for the local machine define host{

use linux-server ; Name of host template to use

; This host definition will inherit all variables that are defined

; in (or inherited by) the linux-server host template definition.

host_name local-nagios alias nagios+cacti address 127.0.0.1 }

注释掉组的定义,后续会在hostgroups里定义 #define hostgroup{

# hostgroup_name linux-servers ; The name of the hostgroup # alias Linux Servers ; Long name of the group

# members localhost ; Comma separated list of hosts that belong to this group # }

通过PING检测主机是否存活 define service{

use local-service ; Name of service template to use host_name local-nagios service_description PING

check_command check_ping!100.0,20%!500.0,60% }

# Define a service to check the disk space of the root partition # on the local machine. Warning if < 20% free, critical if

# < 10% free space on partition.

define service{

use local-service ; Name of service template to use host_name local-nagios service_description Root Partition

check_command check_local_disk!20%!10%!/ }

# Define a service to check the number of currently logged in # users on the local machine. Warning if > 20 users, critical # if > 50 users.

define service{

use local-service ; Name of service template to use host_name local-nagios service_description Current Users

check_command check_local_users!20!50 }

# Define a service to check the number of currently running procs # on the local machine. Warning if > 250 processes, critical if # > 400 users.

define service{

use local-service ; Name of service template to use host_name local-nagios service_description Total Processes

check_command check_local_procs!250!400!RSZDT }

# Define a service to check the load on the local machine.

define service{

use local-service ; Name of service template to use host_name local-nagios service_description Current Load

check_command check_local_load!5.0,4.0,3.0!10.0,6.0,4.0 }


完整安装nagios+邮件报警.doc 将本文的Word文档下载到电脑
搜索更多关于: 完整安装nagios+邮件报警 的文档
相关推荐
相关阅读
× 游客快捷下载通道(下载后可以自由复制和排版)

下载本文档需要支付 10

支付方式:

开通VIP包月会员 特价:29元/月

注:下载文档有可能“只有目录或者内容不全”等情况,请下载之前注意辨别,如果您已付费且无法下载或内容有问题,请联系我们协助你处理。
微信:xuecool-com QQ:370150219