第一范文网 - 专业文章范例文档资料分享平台

完整安装nagios+邮件报警

来源:用户分享 时间:2025/8/21 9:20:23 本文由loading 分享 下载这篇文档手机版
说明:文章内容仅供预览,部分内容可能不全,需要完整文档或者需要复制内容,请下载word后使用。下载word有问题请添加微信号:xxxxxxx或QQ:xxxxxx 处理(尽可能给您提供完整文档),感谢您的支持与谅解。

完整安装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+邮件报警 的文档
完整安装nagios+邮件报警.doc 将本文的Word文档下载到电脑,方便复制、编辑、收藏和打印
本文链接:https://www.diyifanwen.net/c77pa89rlya37lyc0yejd_1.html(转载请注明文章来源)
热门推荐
Copyright © 2012-2023 第一范文网 版权所有 免责声明 | 联系我们
声明 :本网站尊重并保护知识产权,根据《信息网络传播权保护条例》,如果我们转载的作品侵犯了您的权利,请在一个月内通知我们,我们会及时删除。
客服QQ:xxxxxx 邮箱:xxxxxx@qq.com
渝ICP备2023013149号
Top