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 ...
随机推荐
- Spring自学教程-注解的使用(三)
一.java中的注解 定义注解 下面是一个定义注解的实例. @Target(ElementType.TYPE)@Retention(RetentionPolicy.RUNTIME)@Documente ...
- STM8的GPIO驱动
芯片的外设一般按照这么几个流程来进行,GPIO,外部中断,定时器,串口,ADC,IIC,SPI,下面我就按照各个模式来写 首先是GPIO,STM8的GPIO拥有复用功能,这句话告诉我们必然需要配置IO ...
- Mac iTerm2使用rz、sz从远程上传下载文件
使用 brew install lrzsz .如果安装遇到错误的话,使用以下方法: 在mac终端下运行: brew install lrzsz (安装教程:http://brew.sh/index_z ...
- UVa 727 - Equation
题目大意:给一个中缀表达式,转换成后缀表达式. 这类题一直不太会,让我想就是建一棵表达式树,然后后续遍历算了,可是建树的过程实在太麻烦了.今天才看到有中缀表达式转换成后缀表达式的算法,可以用栈进行实现 ...
- 安卓弹出对话框——Alertdialog(一)
首先看各种样式的对话框: 我们看到,Dialog有很多的子类实现,所以我们要定义一个对话框,使用其子类来实例化一个即可,而不要直接使用Dialog这个父类来构造. 二.AlertDialog 今天我们 ...
- CentOS搭建jdk
一.检查是否安装JDK 一般安装好的CentOS会自带jdk, java -version rpm -qa | grep java 显示如下信息: java-1.4.2-gcj-compat-1.4. ...
- 阿里CEO张勇:阿里蚂蚁20亿元扶持开发者
https://bbs.taobao.com/catalog/thread/508895-318032179.htm?spm=a21bo.7724922.8439-0.2.tkjSOl 阿里CEO张勇 ...
- Voilin 与 乐谱
小提琴属于高音乐器,所以它使用的是高音谱号: 用音的时候,线不够用,那就得上加线,或下加线. 小提琴的弦对应的五线谱的位置为: 第四弦,对应五线谱的下加两条线的下面 第三弦,对应五线谱的第一线的下面 ...
- 避免Node.js中回调地狱
为了解决这个阻塞问题,JavaScript严重依赖于回调,这是在长时间运行的进程(IO,定时器等)完成后运行的函数,因此允许代码执行经过长时间运行的任务. downloadFile('example. ...
- GoLang(第一篇 安装)
golang官网:https://golang.org 中文文档:docscn.studygolang.com/doc/ 一:环境变量设置 导入环境变量GOROOT:export GOROOT=/us ...