nagios安装及监控Linux主机
服务端的操作:
##################################安装lamp环境及依赖包##########################
24 rpm -ivh gd-devel-2.0.35-11.el6.x86_64.rpm --nodeps # 加不加都可以
25 cd /media/Packages/
26 yum -y install httpd gcc glibc glibc-common gd gd-devel php php-mysql mysql mysql-devel mysql-server
################################添加用户,组,apache用户赋予nagios用户权限#####
27 groupadd nagios
28 useradd -g nagios nagios # 27和28部 可以写为 useradd nagios 默认用户的组为nagios
29 passwd nagios
30 usermod (-a) -G nagios apache
31 cd /root/Desktop/
32 ls
#############################安装nagios主程序####################################
33 tar -xzvf nagios-4.0.3.tar.gz
34 cd nagios-4.0.3
35 ls
36 ./configure --with-command-group=nagios --enable-event-broker
37 make all # 编译所有
38 make install //安装主程序,CGI和HTML文件
39 make install-init //在/etc/rc.d/init.d安装启动脚本
39 make install-commandmode //配置目录权限
40 make install-config //安装示例配置文件
41 make install-webconf //安装nagios的web接口,会在/etc/httpd/conf.d目录中创建 nagios.conf文件。
#####################################创建用户访问控制用户和密码##################
配置apache
找到apache 的配置文件,修改httpd.conf
找到:
User daemon
Group daemon
修改为?
User nagios
Group nagios
然后找到?
<IfModule dir_module>
DirectoryIndex index.html
</IfModule>
修改为?
<IfModule dir_module>
DirectoryIndex index.html index.php
</IfModule>
接着增加如下内容:?
AddType application/x-httpd-php .php
为了安全起见,一般情况下要让nagios 的web 监控页面必须经过授权才能访问,这需要增加验证配置,即在httpd.conf 文件最后添加如下信息:?
#setting for nagios
ScriptAlias /nagios/cgi-bin "/usr/local/nagios/sbin"
<Directory "/usr/local/nagios/sbin">
AuthType Basic
Options ExecCGI
AllowOverride None
Order allow,deny
Allow from all
AuthName "Nagios Access"
AuthUserFile /usr/local/nagios/etc/htpasswd //用于此目录访问身份验证的文件
Require valid-user
</Directory>
Alias /nagios "/usr/local/nagios/share"
<Directory "/usr/local/nagios/share">
AuthType Basic
Options None
AllowOverride None
Order allow,deny
Allow from all
AuthName "nagios Access"
AuthUserFile /usr/local/nagios/etc/htpasswd
Require valid-user
</Directory>
42 htpasswd -c /usr/local/nagios/etc/htpasswd nagiosadmin #nagiosadmin为用户名 htpasswd为用户设置密码
43 service httpd restart
44 ifup eth0
45 service iptables stop
46 setenforce 0
47 ifconfig
48 cd /root/Desktop
####################################安装nagios-Plugin插件#############################
49 tar -xzvf nagios-plugins-1.5.tar.gz
50 cd nagios-plugins-1.5
51 ls
52 ./configure --with-nagios-user=nagios --with-nagios-group=nagios
53 make &&make install
54 chkconfig --add nagios # 把nagios添加到开机系统中
55 chkconfig nagios on #把nagios设置为开机启动
56 /usr/local/nagios/bin/nagios -v /usr/local/nagios/etc/nagios.cfg 检查nagios的配置文件 出现两个 0 就正确
57 service nagios start
58 cd /root/Desktop
59 ls
监控windows 时 安装windows的插件
1: 进入nagios的配置文件下的nagios.cfg里面
vim /usr/local/nagios/etc/nagios.cfg
cfg-file把# 注释去掉
2:vim etc/objects/windows.cfg
改为虚拟机的IP address 172.18.9.122 ; IP address of the host
3:windows 下安装插件NSClient++ IP设为虚拟机的IP
监控linux安装nrep插件
###############################安装nrpe插件########################################
60 tar -xzvf nrpe-2.12.tar.gz
61 cd nrpe-2.12
62 ./configure --with-nrpe-user=nagios --with-nrpe-group=nagios --with-nagios-user=nagios --with-nagios-group=nagios --enable-command-args --enable-ssl
63 make all
64 make install-plugin
####################创建监控linux主机的配置文件linuxserver.cfg#######################
65 cd /usr/local/nagios/
66 ls
67 cd etc/objects/
68 ls
69 vim linuxserver.cfg
添加:
define host{
use linux-server
host_name linuxserver
alias my linux server
address 172.18.9.98 (客户端ip)
}
define service{
use local-service
host_name linuxserver
service_description Current Users
check_command check_nrpe!check_users
}
define service{
use local-service
host_name linuxserver
service_description Current Load
check_command check_nrpe!check_load
}
define service{
use local-service
host_name linuxserver
service_description Swap Usage
check_command check_local_swap!20!10
}
define service{
use local-service
host_name linuxserver
service_description http
check_command check_http
}
#######################在命令文件里添加命令调用linuxserver.cfg里面的服务############
70 vim commands.cfg
71 cd ..
72 ls
添加:
在commands.cfg中增加对check_nrpe的定义
define command{
command_name check_nrpe
command_line $USER1$/check_nrpe -H $HOSTADDRESS$ -c $ARG1$
}
###################在主配置文件里面添加调用linuxserver.cfg配置文件的命令############
73 vim nagios.cfg
去掉#号 进入vim /usr/local/nagios/etc/nagios.cfg
添加:
cfg_file=/usr/local/nagios/etc/objects/linuxserver.cfg
######################重启服务测试############################################
74 service nagios restart
客户端操作:
###################################安装依赖环境####################################
67 rpm -ivh gd-devel-2.0.35-11.el6.x86_64.rpm --nodeps
68 cd /media/Packages/
69 yum -y install httpd gcc glibc glibc-common gd gd-devel php php- mysql mysql mysql-devel mysql-server openssl*
######################################创建默认不能登录系统的nagios用户############
70 useradd -s /sbin/nologin nagios
71 cd /root/Desktop
72 ls
########################安装nagios-plugin插件######################################
73 tar -xzvf nagios-plugins-1.5.tar.gz
74 cd nagios-plugins-1.5
75 ls
76 ./configure --with-nagios-user=nagios --with-nagios-group=nagios
77 make all
78 make install
79 cd /root/Desktop
#########################安装nrpe插件##############################################
80 tar -xzvf nrpe-2.12.tar.gz
81 cd nrpe-2.12
82 ./configure --with-nrpe-user=nagios --with-nrpe-group=nagios --with-nagios-user=nagios --with-nagios-group=nagios --enable-command-args --enable-ssl
83 make all
84 make install-plugin && make install-daemon &&make install-daemon-config
#############################修改nrpe配置文件使其与服务器建立连接####################
85 vim /usr/local/nagios/etc/nrpe.cfg
修改参数:
allowed_hosts=172.16.100.1(服务器ip)
##########################启动nrpe插件#####################################
86 /usr/local/nagios/bin/nrpe -c /usr/local/nagios/etc/nrpe.cfg -d
87 ifup eth0
88 service iptables stop
89 setenforce 0
90 ifconfig
####################################开启http服务#################################
91 service httpd restart
nagios安装及监控Linux主机的更多相关文章
- 一步步实现Nagios监控linux主机及飞信报警
一步步实现Nagios监控linux主机及飞信报警 上篇文章介绍了在linux主机上架设nagios监控服务,并对windows主机进行服务状态变化的监控,这次我们继续上次内容. 首先实现n ...
- Zabbix监控Linux主机设置
说明: Zabbix监控服务端已经配置完成,现在要使用Zabbix对Linux主机进行监控. 具体操作: 以下操作在被监控的Linux主机进行,这里以CentOS 6.x系统为例. 一.配 ...
- nagios系列(八)之nagios通过nsclient监控windows主机
nagios通过nsclient监控windows主机 1.下载NSClient -0.3.8-Win32.rar安装在需要被监控的windows主机中 可以设置密码,此处密码留空 2.通过在nagi ...
- zabbix通过snmp监控linux主机
1.安装net-snmp [root@db01 ~]# yum install -y net-snmp 2.修改配置文件 [root@db01 ~]# vim /etc/snmp/snmpd.conf ...
- zabbix通过agent监控linux主机
前言: 前几篇博客分别介绍了通过snmp来进行监控linux主机与windows主机,本篇介绍通过agent客户端来进行系统监控. 环境: server:192.168.249.142 client: ...
- 使用cacti监控linux主机
介绍:使用cacti监控linux主机,需要在linux主机上面安装snmp服务,并修改snmpd.conf文件,指定cacti服务器的地址,然后在cacti的前台界面添加此主机即可,此处以监控cen ...
- Cacti监控Linux主机
1 要监视一台Linux主机,需要在被监控的主机上安装net-snmp相关软件包,CentOS安装可使用“yum -y install net-snmp”命令:# yum -y install net ...
- Nagios利用NSClient++监控Windows主机
在Nagios的libexec下有check_nt这个插件,它就是用来检查windows机器的服务的.其功能类似于check_nrpe.不过还需要搭配另外一个软件NSClient++,它则类似于NRP ...
- nagios监控linux主机监控内存脚本
说明 工作包括两部分监控端(一二三)和被监控端(四) 一.nrpe.cfg中添加脚本 nrpe.cfg中添加命令索引 command[check_used_mem]=/usr/local/nagios ...
随机推荐
- 在octave语言中K-means聚类算法求聚类中心的向量化计算
使用octave编程的时候,一定要注意使用向量化编程的思想,下面我就说说我今天做题遇到的一个K-means聚类问题,如何使用octave中的函数向量计算聚类中心centroids. octave几个函 ...
- Vue.js起步
Vue.js是一套构建用户界面的 渐进式框架,Vue 采用自底向上增量开发的设计,Vue 的核心库只关注视图层.Vue 完全有能力驱动采用单文件组件和 Vue 生态系统支持的库开发的复杂单页应用. V ...
- LPC1788的内部EEPROM使用
Lpc1788内置有eeprom 使用代码 #ifndef __E2PRONINCHIP_H_ #define __E2PROMINCHIP_H #include "common.h&quo ...
- UIResponder学习
http://blog.csdn.net/jimzhai/article/details/23283515 UIResponder 介绍 UIResponder 这个类定义了很多用来处理响应和时间处理 ...
- 《算法导论》习题2.3-6 改进的InsertSort
InsertSort中有关键的一步是把当前元素A[i]插入到已经排好序的A[1,i-1]的合适的位置上,在原始的InsertSort算法中, 采用的是从后往前一步一步查找的方法,习题2.3-6要求利用 ...
- MIPI-2
Mipi针对显示有一整套解决方案,首先,框图如下 可以看到,很像OSI七层参考模型,分为 应用层:像素处理以及像素包管理,处理一些比较高的协议, 协议层底层:用于对打包好的像素数据进行二次打包,包括对 ...
- STM32驱动AT24CXX系列芯片
AT24Cxx系列EEPROM是由美国Mcrochip公司出品,1-512K位的支持I2C总线数据传送协议的串行CMOS E2PROM,可用电擦除,可编程自定时写周期(包括自动擦除时间不超过10ms, ...
- IOS开发中AVFoundation中AVAudioPlayer的使用
IOS开发中如何调用音频播放组件 1.与音频相关的头文件等都在AVFoundation.h中,所以第一步是添加音频库文件: #import <AVFoundation/AVFoundation. ...
- sql2000/sql2005/sql2008数据库变为0字节修复/MDF文件0字节恢复
[数据恢复故障描述] 这个客户是生产型数据库,数据比较重要,产生量也比较大,客户要求必须尽快修复,保证生产尽快恢复运行.sql数据库文件,由于碎片链接过长,mdf文件突然变为0字节,开始客户尝试自行 ...
- React Native 之 HelloWorld
1. 切换目录 输入之前要切换到要保存的目录 2. 修改下载源 cd ~/ vim .npmrc 添加 registry = https://registry.npm.taobao.org 3. 在终 ...