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 ...
随机推荐
- OPENCV图像特征点检测与FAST检测算法
前面描述角点检测的时候说到,角点其实也是一种图像特征点,对于一张图像来说,特征点分为三种形式包括边缘,焦点和斑点,在OPENCV中,加上角点检测,总共提供了以下的图像特征点检测方法 FAST SURF ...
- AngularJs ng-class 使用
今天在做项目的时候要对表格内的部分的最大最小值高亮 解决方案 1. 引用 ng-class 2. 引用原型求最大最小值 实例 AngularJs HTML 代码 <table class=&qu ...
- bzoj3110: [Zjoi2013]K大数查询 【cdq分治&树套树】
模板题,折腾了许久. cqd分治整体二分,感觉像是把询问分到答案上. #include <bits/stdc++.h> #define rep(i, a, b) for (int i = ...
- iOS开发—— UIImagePickerController获取相册和拍照
一.简单的拍照显示,或是从相册中直接选取照片 #import "ViewController.h" @interface ViewController ()<UIImageP ...
- 利用OpenSSL创建证书链并应用于IIS7
一.系统环境说明 Linux & OpenSSL Linux localhost -.el5 # SMP Tue Mar :: EDT x86_64 x86_64 x86_64 GNU/Lin ...
- 【转】程序员必须知道的几个Git代码托管平台
一.VS2013中克隆远程Git仓库和SSH的配置 1.VS2013中克隆远程项目 首先感谢园友的评论和补充,今日又仔细看了一下,VS2013中是可以克隆项目的,只是我一直用的GitHub来克隆的 ...
- java学习(三) java 中 mongodb的各种操作
一. 常用查询: 1. 查询一条数据:(多用于保存时判断db中是否已有当前数据,这里 is 精确匹配,模糊匹配 使用 regex...) public PageUrl getByUrl(String ...
- 获取linq生成的sql语句
命名空间:using System.Data.Objects; var query = db.TxtRes.Join(db.LangRes, a => new { id1 = a.ResID, ...
- LDA 线性判别分析
LDA, Linear Discriminant Analysis,线性判别分析.注意与LDA(Latent Dirichlet Allocation,主题生成模型)的区别. 1.引入 上文介绍的PC ...
- JAXB2序列化XML
Jaxb2 实现JavaBean与xml互转 http://zhuchengzzcc.iteye.com/blog/1838702 JAXBContext类,是应用的入口,用于管理XML/Java绑定 ...