Redhat安装icinga2

SOP_Redhat安装icinga2

 

所需rpm包下载网址:http://packages.icinga.org/epel/

http://mirrors.hypo.cn/icinga/fedora/21/release/noarch  icingaweb2包)

 

php-intlphp-pecl-imagick需要单独下

 

 

需要的包:libboost_system1libboost_thread1libboost_regex1libeditboost-licenseicinga2icinga2-binicinga2-commonicingaweb2icingaweb2-commonicingaweb2-vendor-*6个)、php-icingaicingaclinagios-plugins

 

安装httpd

# yuminstall httpd

# yuminstall php php-gd (注意php版本和icinga2等匹配,如果不匹配就得手动下重装了)

 

php相关包有:phpphp-cliphp-commonphp-gdphp-intlphp-mysqlphp-pdophp-xml

 

# rpm �Cilibboost* boost-license (需先下载好)

 

# rpm �Ciicinga2*  php-icinga    (需先下载好)

# rpm �Cinagios-plugins-1.4.16-1.el6.rf.x86_64.rpm --nodeps

如果提示下面相关报错,做下链接即可

# ln -s/usr/lib64/libicui18n.so.42 /usr/lib64/libicui18n.so.36

# ln -s/usr/lib64/libicuuc.so.42 /usr/lib64/libicuuc.so.36

# ln -s/usr/lib64/libicudata.so.42 /usr/lib64/libicudata.so.36

# ln -s/usr/lib64/libMagickWand.so.2 /usr/lib64/libMagickWand.so.5

 

Log路径:/var/log/icinga2/icinga2.log

 

安装mysql

# yuminstall mysql-server

 

# mysql�Cu root  

  • use mysql;

  • update user set password=password(’xxxx’) where user=’root’;

  • flush privileges;

  • quit

 

# mysql �Curoot �Cp’xxxx’

  • create database icinga2;

  • grant all on icinga2.* to icinga2@localhost identified by ‘xxxxxx’;

  • flush privileges;

  • quit

 

# mysql �Curoot �Cp’xxxx’  icinga2 </usr/share/icinga2-ido-mysql/schema/mysql.sql

 

 

# rpm �Ciicingaweb2-*

 

#service icinga2 restart

#service httpd restart

 

页面访问:http://ip/icingaweb2

 

暂时还不能登录,点击账号上面的web-basedsetup-wizard

 

然后照着提示在命令行里操作:

 

#icingacli setup config directory --group icingaweb2

#icingacli setup token create

# su -c"mkdir -m 2770 /etc/icingaweb2;chgrp icingaweb2 /etc/icingaweb2;head -c 12/dev/urandom | base64 | tee /etc/icingaweb2/setup.token;chmod 0660/etc/icingaweb2/setup.token;"

 

然后将乱码贴到页面上

 

模块部分全勾,然后会提示the phpconfig 'date.timezone' is not defined

 

# vi/etc/php5/apache2/php.ini

 

date.timezone= Asia/Shanghai   (默认是注释掉的)

 

:wq

#service apache2 restart

 

再点击refresh即可(其它***提示可忽略)――Database――将数据库、用户名等补上,勾上Skip Validation――设置管理账号及密码

 

如果提示没有icingaweb_user表,就手动创建下吧,命令如下:

  • use icinga2;

  • create table icingaweb_user (name varchar(64) not null,activetinyint(1) not null,password_hash varbinary(255) not null,ctime timestamp,mtimetimestamp);

 

如果页面显示“icinga is currently notup and running,一是看/etc/icinga2/features-enabled/下是否有ido-mysql.conf,如果没有从/etc/icinga2/features-available/处链接过来即可;二是看/var/log/icinga2/icinga2.log提示

 

 

 

添加主机:

 

# cd/etc/icinga2/conf.d/

# vi shhudson.conf

 

object Host"hudson15" {

  import "generic-host"

  address = "10.0.0.2"

  vars.os = "Linux Servers"

  vars.sla = "24x7"

}

:wq

# chown icinga:icingashhudson.conf

# service icinga2restart 

 

此时页面上就会显示“hudson15”主机

 

添加主机组:

 

# cd/etc/icinga2/conf.d/

# vi groups.conf

 

object HostGroup"shhudson" {

  display_name = "shhudson"

  assign where host.vars.os =="shhudson"

}

:wq

# service icinga2restart

 

此时页面上就会显示“shhudson”主机组

 

 

 

安装nrpe(管理多台主机)

 

http://nchc.dl.sourceforge.net/project/nagios/nrpe-2.x/nrpe-2.12/nrpe-2.12.tar.gz

 

# yuminstall gcc

# tarzxfv nrpe-2.12.tar.gz

# cd nrpe-2.12

#./configure

# makeall

# makeinstall-plugin

 

此时会生成/usr/local/nagios/libexec/check_nrpe

 

# /usr/local/nagios/libexec/check_nrpe-H 10.0.1.57   (显示NRPE v2.12即为正常,前提是客户端已安装nrpe插件)

 

 

配置nrpe

 

# vi /etc/icinga2/conf.d/templates.conf

templateCheckCommand "nrpe-common" {

  import "plugin-check-command"

  command = [ PluginDir +"/check_nrpe" ]

  arguments = {

  "-H" = "$nrpe_address$"

  "-p" = "$nrpe_port$"

  "-c" = "$nrpe_command$"

  "-a" = {

       value = "$nrpe_args$"

       repeat_key = false

       order = 1

}

}

  vars.nrpe_address = "$address$"

  vars.nrpe_port = 5666

}

 

objectCheckCommand "nrpe-disk" {

   import "nrpe-common"

   vars.nrpe_command = "check_disk"

}

 

objectCheckCommand "nrpe-load" {

   import "nrpe-common"

   vars.nrpe_command = "check_load"

}

 

objectCheckCommand "nrpe-users" {

   import "nrpe-common"

   vars.nrpe_command = "check_users"

}

:wq

 

# vi/etc/icinga2/conf.d/services.conf

 

applyService "nrpe-disk" {

  import "generic-service"

  check_command = "nrpe-disk"

  assign where host.address

}

 

apply Service"nrpe_load" {

  import "generic-service"

  check_command = "nrpe-load"

  assign where host.address

}

 

applyService "nrpe_users" {

  import "generic-service"

  check_command = "nrpe-users"

  assign where host.address

}

:wq

 

# vi /etc/icinga2/conf.d/shhudson.conf

object Host"hudson15" {

  import "generic-host"

  address = "10.0.0.2"

  vars.os = "Linux Servers"

  vars.sla = "24x7"

vars.is_nrpe = true

vars.nrpe-disks["disk/space"] = {

    disk_partitions = "/space"

  }

}

 

:wq

# service icinga2restart

 

 

 

 

客户端安装nrpe插件:

 

Ubuntu

 

# useradd -s /sbin/nologin -M nagios
# apt-get install nagios-nrpe-server nagios-plugins
编辑nrpe配置文件
# vi /etc/nagios/nrpe.cfg

allowed_hosts=127.0.0.1,10.0.0.232   (默认为allowed_hosts=127.0.0.1)

dont_blame_nrpe=1
:wq

启动nrpe
# service nagios-nrpe-server start

 

 

Redhat:

 

# rpm �Cinagios-nrpe-2.14-1.el6.rf.x86_64.rpm  (需要下载)

# vi /etc/nagios/nrpe.cfg

allowed_hosts=127.0.0.1,10.0.0.232   (默认为allowed_hosts=127.0.0.1)

dont_blame_nrpe=1
:wq

启动nrpe
# service nrpe start

 

 

 

 

 


你可能感兴趣的:(icinga2,icingaweb2)