设为首页 收藏本站
查看: 1687|回复: 0

Nagios监控HP、Dell服务器的硬件状态

[复制链接]

尚未签到

发表于 2019-1-14 11:57:54 | 显示全部楼层 |阅读模式
  一、监控服务器安装
1.关闭SELINUX
# vi /etc/selinux/config
SELINUX=disabled
2. 使用yum 安装依赖包
# yum install -y gcc glibc glibc-common gd gd-devel xinetd openssl-devel
# yum install -y libxml2-devel
3.创建nagios用户和用户组
# useradd -s /sbin/nologin nagios
# mkdir /usr/local/nagios
# chown -R nagios.nagios /usr/local/nagios
4. 编译安装Nagios
# wget http://sourceforge.net/projects/nagios/files/nagios-3.x/nagios-3.5.1/nagios-3.5.1.tar.gz
# tar zxvf nagios-3.5.1.tar.gz
# cd nagios
# ./configure --prefix=/usr/local/nagios
# make all
# make install
# make install-init
# make install-commandmode
# make install-config
# chkconfig --add nagios
# chkconfig --level 35 nagios on
# chkconfig --list nagios
5. 安装Nagios 插件
# wget http://prdownloads.sourceforge.net/sourceforge/nagiosplug/nagios-plugins-1.4.16.tar.gz
# tar zxvf nagios-plugins-1.4.16.tar.gz
# cd nagios-plugins-1.4.16
# ./configure --prefix=/usr/local/nagios
# make && make install
6. 安装与配置Apache和Php
Apache 和Php 不是安装nagios 所必须的,但是nagios提供了web监控界面,通过web监控界面可以清晰的看到被监控主机、资源的运行状态,因此,安装一个web服务是很必要的。
需要注意的是,nagios在nagios3.1.x版本以后,配置web监控界面时需要php的支持。这里我们下载的nagios版本为nagios-3.5.1,因此在编译安装完成apache后,还需要编译php模块,这里选取的php版本为php5.5.3。
a. 安装Apache
# wget http://archive.apache.org/dist/httpd/httpd-2.2.25.tar.gz
# tar zxvf httpd-2.2.25.tar.gz
# cd httpd-2.2.25
# ./configure --prefix=/usr/local/apache2
# make && make install
b. 安装Php
# wget http://cn2.php.net/distributions/php-5.5.3.tar.gz
# tar zxvf php-5.5.3.tar.gz
# cd php-5.5.3
# ./configure --prefix=/usr/local/php --with-apxs2=/usr/local/apache2/bin/apxs
# make && make install
c. 配置apache
找到apache 的配置文件/usr/local/apache2/conf/httpd.conf
# vim /usr/local/apache2/conf/httpd.conf
找到:
User daemon
Group daemon
修改为
User nagios
Group nagios
然后找到

  DirectoryIndex index.html

修改为

  DirectoryIndex index.html index.php

接着增加如下内容:
AddType application/x-httpd-php .php
为了安全起见,一般情况下要让nagios 的web 监控页面必须经过授权才能访问,这需要增加验证配置,即在httpd.conf 文件最后添加如下信息
#setting for nagios
ScriptAlias /nagios/cgi-bin "/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

Alias /nagios "/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

d. 创建apache目录验证文件
在上面的配置中,指定了目录验证文件htpasswd,下面要创建这个文件:
# /usr/local/apache2/bin/htpasswd -c /usr/local/nagios/etc/htpasswd admin
设置admin的密码
这样就在/usr/local/nagios/etc 目录下创建了一个htpasswd 验证文件,当通过http://192.168.1.108/nagios/ 访问时就需要输入用户名和密码了。
e. 查看认证文件的内容
# cat /usr/local/nagios/etc/htpasswd
启动服务
/usr/local/apache2/bin/apachectl start
检查
/usr/local/nagios/bin/nagios -v /usr/local/nagios/etc/nagios.cfg
/usr/local/nagios/bin/nagios -d /usr/local/nagios/etc/nagios.cfg
h.
如果出现
It appears as though you do not have permission to view information for any of the hosts you requested...
编辑cgi.cfg文件
此文件用来控制相关cgi脚本,如果想在nagios的web监控界面执行cgi脚本,例如重启nagios进程、关闭nagios通知、停止nagios主机检测等,这时就需要配置cgi.cfg文件了。
由于nagios的web监控界面验证用户为admin所以只需在cgi.cfg文件中添加此用户的执行权限就可以了,需要修改的配置信息如下:
default_user_name=admin
authorized_for_system_information=nagiosadmin,admin
authorized_for_configuration_information=nagiosadmin,admin
authorized_for_system_commands=admin
authorized_for_all_services=nagiosadmin,admin
authorized_for_all_hosts=nagiosadmin,admin
authorized_for_all_service_commands=nagiosadmin,admin  
authorized_for_all_host_commands=nagiosadmin,admin
7.安装HP的check_hpasm
#wget http://labs.consol.de/download/shinken-nagios-plugins/check_hpasm-4.6.3.2.tar.gz
#tar zxvf check_hpasm-4.6.3.tar.gz
#cd check_hpasm-4.6.3
#./configure --prefix=/usr/local/nagios
#make&&make install
8.安装dell的check_openmanage
# wget http://folk.uio.no/trondham/software/check_openmanage.html#download
# tar zxvf check_openmanage-3.7.11.tar.gz
# cd check_openmanage-3.7.11
# cp check_openmanage /usr/local/nagios/libexec/
9.安装snmp
yum --nogpgcheck install http://download.fedoraproject.org/pub/epel/6/i386/epel-release-6-5.noarch.rpm
yum install perl-Net-SNMP

  

  

  

  

  二、HP服务器的客户端安装
  1.下载软件包http://downloads.linux.hp.com/SDR/downloads/
hp-health-8.7.0.22-17.rhel6.x86_64.rpm

hpacucli-8.70-8.0.noarch.rpmhp-snmp-agents-8.7.0.23-17.rhel6.x86_64.rpm2.安装hp检测hp服务器硬件健康状态包和检测hp服务器磁盘阵列状态包# rpm -ivh hp-health-8.7.0.22-17.rhel6.x86_64.rpm# rpm -ivh hpacucli-8.70-8.0.noarch.rpm  提示安装依赖包
# yum installlibc.so.6 libgcc_s.so.1libstdc++.so.6


安装成功,启动服务
/etc/init.d/hp-health start
/etc/init.d/hp-asrd start
3.安装pciutils
# yum installpciutils*
4.安装SNMP
# yum install net-snmp


# vim /etc/snmp/snmpd.conf
增加一行
dlmod cmaX /usr/lib64/libcmaX64.so
修改



view  all included   .1
view  systemview  included       .1.3.6.1.2.1.1
view  systemview  included      .1.3.6.1.2.1.25.1.1


access notConfigGroup ""any noauth exact all all none



# service snmpd start
# chkconfig snmpd on
# rpm -ivh hp-snmp-agents-8.7.0.23-17.rhel6.x86_64.rpm/etc/init.d/hp-snmp-agents start
  然后在监控服务器测试
  /usr/local/nagios/libexec/check_hpasm -H 172.16.8.15 -C public



.安装dell服务器
1.下载dell osma
# wget -q-O - http://linux.dell.com/repo/hardware/latest/bootstrap.cgi | bash
# yum install srvadmin-all –y
启动服务
/opt/dell/srvadmin/sbin/srvadmin-services.sh start
2. 安装snmp
# yum -y install net-snmp
# vim /etc/snmp/snmpd.conf

修改

view  all included   .1
view  systemview  included       .1.3.6.1.2.1.1
view  systemview  included      .1.3.6.1.2.1.25.1.1
access notConfigGroup ""any noauth exact all all none

启动服务器
/etc/init.d/snmpd restart
然后在监控服务器测试
/usr/local/nagios/libexec/check_openmanage -H 172.16.8.18 -C public

  windows的就不介绍了
  dell的去官网下载OM-SrvAdmin-Dell-Web
  hp的在smartstart盘安装psp软件包
  启动snmp服务器即可
  安装已完成
  

  配置
  定义主机
  vim /usr/local/nagios/etc/objects/linux.cfg

# hp server
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               KVM152
alias                   KVM152
address                 172.16.8.152
}
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               KVM153
alias                   KVM153
address                 172.16.8.153
}
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               KVM154
alias                   KVM154
address                 172.16.8.154
}
# dell server
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               KVM155
alias                   KVM155
address                 172.16.8.155
}
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               KVM156
alias                   KVM156
address                 172.16.8.156
}
  定义命令

vim /usr/local/nagios/etc/objects/commands.cfg
#DELL OMSA
define command {
command_name    check_hardware
command_line    $USER1$/check_openmanage -H $HOSTADDRESS$ -C public -b $ARG1$
}
define command {
command_name    check_hardware_alertlog
command_line    $USER1$/check_openmanage -H $HOSTADDRESS$ -C public --only=alertlog
}
define command{
command_name omsa_status
command_line $USER1$/check_openmanage -H $HOSTADDRESS$ -C public
}
define command{
command_name omsa_cpu
command_line $USER1$/check_openmanage -H $HOSTADDRESS$ -C public --only cpu -p
}
define command{
command_name omsa_temp
command_line $USER1$/check_openmanage -H $HOSTADDRESS$ -C public --only temp -w $ARG1$ -c $ARG2$ -p
}
define command{
command_name omsa_storage
command_line $USER1$/check_openmanage -H $HOSTADDRESS$ -C public --only storage -p
}
define command{
command_name omsa_intrusion
command_line $USER1$/check_openmanage -H $HOSTADDRESS$ -C public --only intrusion -p
}
define command{
command_name    omsa_fans
command_line    $USER1$/check_openmanage -H $HOSTADDRESS$ -C public --only fans -p
}
define command{
command_name    omsa_memory
command_line    $USER1$/check_openmanage -H $HOSTADDRESS$ -C public --only memory -p
}
# HP
define command{
command_name    hpasm
command_line    $USER1$/check_hpasm -H $HOSTADDRESS$ -v -C public
}  

  定义服务
vim /usr/local/nagios/etc/objects/services.cfg
# HP
define service {
use generic-service
host_name       KVM152,KVM153,KVM154,KVM155,KVM156,KVM157,KVM158,KVM160,KVM166,KVM167,KVM169
service_description hp
check_command  hpasm
}
# DELL
define service {
use generic-service
host_name           KVM168,KVM158,KVM160,KVM166,KVM167,KVM169
service_description omsa_status
check_command omsa_status
}
define service {
use                 generic-service
host_name           KVM168,KVM158,KVM160,KVM166,KVM167,KVM169
service_description  omsa_cpu
check_command       omsa_cpu
}
define service {
use                 generic-service
host_name           KVM168,KVM158,KVM160,KVM166,KVM167,KVM169
service_description  omsa_temp
check_command       omsa_temp
}
define service {
use                 generic-service
host_name          KVM168,KVM158,KVM160,KVM166,KVM167,KVM169
service_description  omsa_storage
check_command       omsa_storage
}
define service {
use                 generic-service
host_name          KVM168,KVM158,KVM160,KVM166,KVM167,KVM169
service_description  omsa_intrusion
check_command       omsa_intrusion
}
define service {
use                 generic-service
host_name           KVM168,KVM158,KVM160,KVM166,KVM167,KVM169
service_description  omsa_fans
check_command       omsa_fans
}
define service {
use                 generic-service
host_name          KVM168,KVM158,KVM160,KVM166,KVM167,KVM169
service_description  omsa_memory
check_command       omsa_memory
}
service_description omsa_status
check_command omsa_status
}
define service {
use                 generic-service
host_name           KVM168,KVM158,KVM160,KVM166,KVM167,KVM169
service_description  omsa_cpu
check_command       omsa_cpu
}
define service {
use                 generic-service
host_name          KVM168,KVM158,KVM160,KVM166,KVM167,KVM169
service_description  omsa_temp
check_command       omsa_temp
}
define service {
use                 generic-service
host_name          KVM168,KVM158,KVM160,KVM166,KVM167,KVM169
service_description  omsa_storage
check_command       omsa_storage
}
define service {
use                 generic-service
host_name          KVM168,KVM158,KVM160,KVM166,KVM167,KVM169
service_description  omsa_intrusion
check_command       omsa_intrusion
}
define service {
use                 generic-service
host_name          KVM168,KVM158,KVM160,KVM166,KVM167,KVM169
service_description  omsa_fans
check_command       omsa_fans
}
define service {
use                 generic-service
host_name           KVM168,KVM158,KVM160,KVM166,KVM167,KVM169
service_description  omsa_memory
check_command       omsa_memory
}  配置nagios.cfg

  vim /usr/local/nagios/etc/nagios.cfg
cfg_file=/usr/local/nagios/etc/objects/commands.cfg
cfg_file=/usr/local/nagios/etc/objects/contacts.cfg
cfg_file=/usr/local/nagios/etc/objects/timeperiods.cfg
cfg_file=/usr/local/nagios/etc/objects/templates.cfg
cfg_file=/usr/local/nagios/etc/objects/services.cfg
# Definitions for monitoring the local (Linux) host
cfg_file=/usr/local/nagios/etc/objects/localhost.cfg
cfg_file=/usr/local/nagios/etc/objects/linux.cfg  

  重启服务service nagios stop

  测试有无报错
  /usr/local/nagios/bin/nagios -v /usr/local/nagios/etc/nagios.cfg
  无报错就可以启动服务

  service nagios start





运维网声明 1、欢迎大家加入本站运维交流群:群②:261659950 群⑤:202807635 群⑦870801961 群⑧679858003
2、本站所有主题由该帖子作者发表,该帖子作者与运维网享有帖子相关版权
3、所有作品的著作权均归原作者享有,请您和我们一样尊重他人的著作权等合法权益。如果您对作品感到满意,请购买正版
4、禁止制作、复制、发布和传播具有反动、淫秽、色情、暴力、凶杀等内容的信息,一经发现立即删除。若您因此触犯法律,一切后果自负,我们对此不承担任何责任
5、所有资源均系网友上传或者通过网络收集,我们仅提供一个展示、介绍、观摩学习的平台,我们不对其内容的准确性、可靠性、正当性、安全性、合法性等负责,亦不承担任何法律责任
6、所有作品仅供您个人学习、研究或欣赏,不得用于商业或者其他用途,否则,一切后果均由您自己承担,我们对此不承担任何法律责任
7、如涉及侵犯版权等问题,请您及时通知我们,我们将立即采取措施予以解决
8、联系人Email:admin@iyunv.com 网址:www.yunweiku.com

所有资源均系网友上传或者通过网络收集,我们仅提供一个展示、介绍、观摩学习的平台,我们不对其承担任何法律责任,如涉及侵犯版权等问题,请您及时通知我们,我们将立即处理,联系人Email:kefu@iyunv.com,QQ:1061981298 本贴地址:https://www.yunweiku.com/thread-663168-1-1.html 上篇帖子: Nagios网络监控(一) 下篇帖子: nagios与nconf整合与使用
您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

扫码加入运维网微信交流群X

扫码加入运维网微信交流群

扫描二维码加入运维网微信交流群,最新一手资源尽在官方微信交流群!快快加入我们吧...

扫描微信二维码查看详情

客服E-mail:kefu@iyunv.com 客服QQ:1061981298


QQ群⑦:运维网交流群⑦ QQ群⑧:运维网交流群⑧ k8s群:运维网kubernetes交流群


提醒:禁止发布任何违反国家法律、法规的言论与图片等内容;本站内容均来自个人观点与网络等信息,非本站认同之观点.


本站大部分资源是网友从网上搜集分享而来,其版权均归原作者及其网站所有,我们尊重他人的合法权益,如有内容侵犯您的合法权益,请及时与我们联系进行核实删除!



合作伙伴: 青云cloud

快速回复 返回顶部 返回列表