centos安装nagios
编译安装nagios
yum install -y gcc glibc glibc-common gd gd-devel httpd php php-gd mysql* sendmailunzip nagios.zipuseradd nagios
groupadd nagcmd
usermod -a -G nagcmd nagios
usermod -a -G nagcmd apacheecho 'export LC_ALL=C'>>/etc/profile
source /etc/profiletar zxvf nagios-3.5.1.tar.gz
cd nagios
./configure --with-command-group=nagcmd
make all
make install
make install-init
make install-commandmode
make install-config
make install-webconf
创建htpasswd.users,并添加nagios网页登录的用户密码
htpasswd -cb /usr/local/nagios/etc/htpasswd.users nagios 123456
打开浏览器,输入本机ip地址/nagios进行访问
#在34行修改email地址
vim /usr/local/nagios/etc/objects/contacts.cfg
编译安装nagios-plugins插件
tar zxvf nagios-plugins-1.4.16.tar.gz
cd nagios-plugins-1.4.16
./configure --with-nagios-user=nagios --with-nagios-group=nagios --enable-perl-modules
make
make install#检查nagios语法
/usr/local/nagios/bin/nagios -v /usr/local/nagios/etc/nagios.cfg
/etc/init.d/nagios checkconfig#启动nagios
/etc/init.d/nagios start
编译安装nrpe
tar zxvf nrpe-2.12.tar.gz
cd nrpe-2.12
./configure
make all
make install-plugin
make install-daemon
make install-daemon-config
创建hosts,services.cfg,services
cd /usr/local/nagios/etc/objectshead -51 localhost.cfg > hosts.cfg
#hosts.cfg实例配置
cat hosts.cfg
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 192.168.1.171alias 192.168.1.171address 192.168.1.171}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 192.168.1.172alias 192.168.1.172address 192.168.1.172}define hostgroup{hostgroup_name linux-servers ; The name of the hostgroupalias Linux Servers ; Long name of the groupmembers 192.168.1.171,192.168.1.172 ; Comma separated list of hosts that belong to this group}
touch services.cfgmkdir services#添加客户端配置文件,实例
vim services/192.168.1.171.cfg
define service{
use generic-service
host_name 192.168.1.171
service_description Disk Partition
check_command check_nrpe!check_disk
}
define service{
use generic-service
host_name 192.168.1.171
service_description mem
check_command check_nrpe!check_mem
}
define service{
use generic-service
host_name 192.168.1.171
service_description load
check_command check_nrpe!check_load
}
define service{
use generic-service
host_name 192.168.1.171
service_description swap
check_command check_nrpe!check_swap
}
define service{
use generic-service
host_name 192.168.1.171
service_description iostat
check_command check_nrpe!check_iostat
}
define service{
use generic-service
host_name 192.168.1.171
service_description http
check_command check_http!192.168.1.171
}
define service{
use generic-service
host_name 192.168.1.171
service_description phpmyadmin
check_command check_http!192.168.1.171 -u /phpmyadmin/
}
define service{
use generic-service
host_name 192.168.1.171
service_description ping
check_command check_ping!100.0,20%!500.0,60%
}
define service{
use generic-service
host_name 192.168.1.171
service_description port_80
check_command check_tcp!80
}
define service{
use generic-service
host_name 192.168.1.171
service_description mysql
check_command check_mysql!192.168.1.171
}
vim services/192.168.1.172.cfg
define service{
use generic-service
host_name 192.168.1.172
service_description Disk Partition
check_command check_nrpe!check_disk
}
define service{
use generic-service
host_name 192.168.1.172
service_description mem
check_command check_nrpe!check_mem
}
define service{
use generic-service
host_name 192.168.1.172
service_description load
check_command check_nrpe!check_load
}
define service{
use generic-service
host_name 192.168.1.172
service_description swap
check_command check_nrpe!check_swap
}
define service{
use generic-service
host_name 192.168.1.172
service_description iostat
check_command check_nrpe!check_iostat
}
define service{
use generic-service
host_name 192.168.1.172
service_description mysql
check_command check_mysql!192.168.1.172
}
chown -R nagios.nagios *
#添加命令,commands.cfg配置实例
vim commands.cfg
#将227到238替换为以下内容
# 'process-host-perfdata' command definition
define command{command_name process-host-perfdatacommand_line /usr/local/nagios/libexec/process_perfdata.pl}# 'process-service-perfdata' command definition
define command{command_name process-service-perfdatacommand_line /usr/local/nagios/libexec/process_perfdata.pl}在结尾添加
# 'check_nrpe' command definition
define command{command_name check_nrpecommand_line $USER1$/check_nrpe -H $HOSTADDRESS$ -c $ARG1$}# 'check_mysql' command definition
define command{command_name check_mysqlcommand_line $USER1$/check_mysql -H $HOSTADDRESS$ -u root -p 123456}
修改用户权限
vim /usr/local/nagios/etc/cgi.cfg
#将nagiosadmin用户替换为nagios,nagios为登录的用户,替换后才能出图
g/nagiosadmin/s//nagios/g
安装出图插件
yum install -y cairo pango zlib zlib-devel freetype freetype-devel gd gd-develtar zxvf libart_lgpl-2.3.17.tar.gz
cd libart_lgpl-2.3.17
./configure
make
make install
cp -r /usr/local/include/libart-2.0 /usr/include/
cd ..
tar zxvf rrdtool-1.2.14.tar.gz
cd rrdtool-1.2.14
./configure --prefix=/usr/local/rrdtool --disable-python --disable-tcl
make
make install
cd ..
tar zxvf pnp-0.4.14.tar.gz
cd pnp-0.4.14
./configure --with-rrdtool=/usr/local/rrdtool/bin/rrdtool --with-perfdata-dir=/usr/local/nagios/share/perfdata/
make all
make install
make install-config
make install -init
cd ..
vim nagios.cfg
#在35行添加
cfg_file=/usr/local/nagios/etc/objects/hosts.cfg
cfg_dir=/usr/local/nagios/etc/objects/services
#注释40行左右的下面这一行
#cfg_file=/usr/local/nagios/etc/objects/localhost.cfg
#修改835行,将0改为1
process_performance_data=1
#取消847、848行的注释
host_perfdata_command=process-host-perfdata
service_perfdata_command=process-service-perfdata
vim templates.cfg
#在linux-server中添加下列配置,大概在83行
process_perf_data 1
action_url /nagios/pnp/index.php?host=$HOSTNAME$
#在generic-service中添加下列配置,大概在179行
action_url /nagios/pnp/index.php?host=$HOSTNAME$&srv=$SERVICEDESC$
客户端插件安装
useradd nagios -M -s /sbin/nologin
echo 'export LC_ALL=C'>>/etc/profile
source /etc/profile
unzip nagios.zip
tar zxvf nagios-plugins-1.4.16.tar.gz
cd nagios-plugins-1.4.16
./configure --with-nagios-user=nagios --with-nagios-group=nagios --enable-perl-modules
make
make install
cd ..
tar zxvf nrpe-2.12.tar.gz
cd nrpe-2.12
./configure
make all
make install-plugin
make install-daemon
make install-daemon-config
cd ..
tar zxvf Params-Validate-0.91.tar.gz
cd Params-Validate-0.91
perl Makefile.PL
make
make install
cd ..
tar zxvf Class-Accessor-0.31.tar.gz
cd Class-Accessor-0.31
perl Makefile.PL
make
make install
cd ..
tar zxvf Config-Tiny-2.12.tar.gz
cd Config-Tiny-2.12
perl Makefile.PL
make
make install
cd ..
tar zxvf Math-Calc-Units-1.07.tar.gz
cd Math-Calc-Units-1.07
perl Makefile.PL
make
make install
cd ..
tar zxvf Regexp-Common-2010010201.tar.gz
cd Regexp-Common-2010010201
perl Makefile.PL
make
make install
cd ..
tar zxvf Nagios-Plugin-0.34.tar.gz
cd Nagios-Plugin-0.34
perl Makefile.PL
make
make install
cd ..
yum install -y sysstat dos2unix
cp check_iostat /usr/local/nagios/libexec/
cp check_memory.pl /usr/local/nagios/libexec/
cd /usr/local/nagios/libexec/
chmod 755 check_iostat
chmod 755 check_memory.pl
dos2unix check_iostat
dos2unix check_memory.pl
配置nrpe
vim /usr/local/nagios/etc/nrpe.cfg
在第79行填写监控服务器地址
allowed_hosts=192.168.1.178
将199到203行替换为以下内容
command[check_load]=/usr/local/nagios/libexec/check_load -w 15,10,5 -c 30,25,20
command[check_mem]=/usr/local/nagios/libexec/check_memory.pl -w 10% -c 3%
command[check_disk]=/usr/local/nagios/libexec/check_disk -w 15% -c 7% -p /
command[check_swap]=/usr/local/nagios/libexec/check_swap -w 20% -c 10%
command[check_iostat]=/usr/local/nagios/libexec/check_iostat -w 6 -c 10
启动nrpe
/usr/local/nagios/bin/nrpe -c /usr/local/nagios/etc/nrpe.cfg -d
centos安装nagios相关推荐
- CentOS安装Nagios网络监视工具
Nagios是一款开源的免费网络监视工具,能有效监控Windows.Linux和Unix的主机状态,交换机路由器等网络设置,打印机等.在系统或服务状态异常时发出邮件或短信报警第一时间通知网站运维人员, ...
- CentOS 6.5安装nagios
linux下nagios安装 系统环境:CentOS 6.5 安装包:httpd-2.2.12.tar.bz2 , pcre-8.30.tar.bz2 , php-5.4.6.tar.bz2 ...
- centos 5.4 x64 安装nagios 3.2.3
Nagios 安装 一 ,准备工作,最小化安装系统 系统版本 centos 5.4 http://www.verycd.com/topics/2776496/ nagios-3.2.3.tar htt ...
- CentOS 6 nagios安装与监控
部署安装LAMP 1.制作本地yum源 2.关闭防火墙和SELinux 3.安装LAMP的服务包 4.编写Apache的PHP测试页 5.开启Apache服务,查看测试页成功 部署安装nagios服务 ...
- centos 7 安装nagios
一.Nagios简介 Nagios是一款开源的电脑系统和网络监视工具,能有效监控Windows.Linux和Unix的主机状态,交换机路由器等网络设置,打印机等.在系统或服务状态异常时发出邮件或短信报 ...
- CentOS7安装Nagios并配置出图详解
目录 开始之前 系统环境 监控内容 所需软件包 CentOS7重要变化 配置开发环境 同步时间 关闭Selinux 使用CRT上传软件包 安装邮件服务 监控主机安装 常用到的命令 安装nagios所需 ...
- 通过yum安装Nagios
主监控机设置: 1.安装epel # cat /etc/issue CentOS release 6.0 (Final) Kernel \r on an \m # rpm -ivh http://dl ...
- CentOS 安装docker.ce报错提示containerd.io >= 1.2.2-3问题
centos安装docker.ce遇到报错,提示如下 # yum install -y docker-ce Last metadata expiration check: 0:01:49 ago on ...
- CentOS安装crontab
CentOS安装crontab: yum install crontabs 说明: service crond start //启动服务 service crond stop //关闭服务 servi ...
最新文章
- 拆分命令_在MongoDB分片集群中拆分数据块chunks
- Linux定时备份数据到百度云盘
- 2022年全球及中国固态电解质(SSE)行业应用现状与十四五投资潜力分析报告
- java中ThreadLocalRandom的使用
- python3的float数精度_python浮点数精度问题
- ABP入门系列(6)——定义导航菜单
- realme x2 深度测试打不开_realme 的产品到底是不是贴牌的?
- mysql 热切换_热璞HotDB学习篇—如何基于MySQL进行数据高可用
- 使用变量替换批量部署GoldenGate
- 《大数据技术原理与应用》(第三章 HDFS 课后答案)
- Base16,Base32,Base64编码的介绍
- 微星主板 B450 迫击炮 无线网卡 无法上网解决办法
- 1.爬虫基础——了解html什么是爬虫
- 【架构设计】简单设计原则(Kent Beck)
- 逻辑思维训练——假设法
- 黑马linux系统编程
- Eric靶机渗透测试
- 使用sklearn进行对数据标准化、归一化以及将数据还原
- hdoj4466题解
- 不染计算机音乐谱大全,不染钢琴谱-毛不易-完美版
热门文章
- unity 一万个具有相同动画的物体渲染
- 四位全加器的设计与仿真
- Lichee_RV学习系列---移植dhrystone
- 【BAT-表姐御用01dir命令】批量获取文件夹中的文件名
- Linux内核编译很简单,6步编译一个自己的内核
- java并发编程实战wwj----------------------第二阶段--------------04-05--06--07-8-9-10-11
- Swin Transformer猫狗分类
- 计算机基础知识——计算机概述(CSP-J组初赛知识点)
- 仿真软件proteus构建LCD1602显示字符串实验
- python少儿编程课程体系_Python