(lnmp平台)

系统环境: rhel6 x86_64 iptables and selinux disabled

主机: 192.168.122.185 server85.example.com

192.168.122.117 server17.example.com (注:时间需同步)

相关网址: rpm.pbone.net http://www.cyberciti.biz/nixcraft/linux/docs/uniqlinuxfeatures/mrtg/ cacti.net nagios.org https://trac.assembla.com/npc(需FQ)

所需的包:cacti-0.8.7h.tar.gz
cacti-spine-0.8.7h.tar.gz cacti-plugin-0.8.7h-PA-v3.0.tar.gz
settings-v0.71-1.tgz monitor-v1.3-1.tgz nagios-cn-3.2.3.tar.bz2
nagios-plugins-1.4.16.tar.gz gd-devel-2.0.35-10.el6.x86_64.rpm
FCGI-0.74.tar.gz FCsettings-v0.71-1.tgzGI-ProcManager-0.24.tar.gz
ExtUtils-Constant-0.23.tar.gz Socket-2.001.tar.gz
fastcgi-wrapper.pl rrdtool-perl-1.3.8-6.el6.x86_64.rpm fetion
linuxso_20101113.tar.gz nrpe-2.14.tar.gz ganglia-3.4.0.tar.gz
ganglia-web-3.5.2.tar.gz libconfuse-2.6-3.el6.x86_64.rpm
libconfuse-devel-2.6-3.el6.x86_64.rpm
rrdtool-devel-1.3.8-6.el6.x86_64.rpm npc-2.0.4.tar.gz
ndoutils-1.4b9.tar.gz PDO_MYSQL-1.0.2.tgz

1.安装与配置cacti

[root@server17 kernel]# tar zxf cacti-0.8.7h.tar.gz -C /usr/local/lnmp/nginx/html/

[root@server17 kernel]# cd /usr/local/lnmp/nginx/html/

[root@server17 html]# mv cacti-0.8.7h/ cacti

[root@server17 cacti]# yum install rrdtool -y

[root@server17 cacti]# vim /usr/local/lnmp/nginx/conf/nginx.conf

location ~ \.php$ {

root html;

fastcgi_pass 127.0.0.1:9000;

fastcgi_index index.php;

# fastcgi_param SCRIPT_FILENAME /scripts$fastcgi_script_name;

include fastcgi.conf;

}

[root@server17 cacti]# nginx -s reload

[root@server17 cacti]# /etc/init.d/mysqld start

[root@server17 cacti]# /etc/init.d/php-fpm start

[root@server17 cacti]# mysql

mysql> create database cacti;

mysql> quit

[root@server17 cacti]# mysql cacti < cacti.sql

[root@server17 cacti]# mysql

mysql> grant all on cacti.* to cacti@localhost identified by 'cacti';

mysql> flush privileges;

mysql> quit

[root@server17 cacti]# cd /usr/local/lnmp/nginx/html/cacti/include/

[root@server17 include]# vim config.php

$database_type = "mysql";

$database_default = "cacti";

$database_hostname = "localhost";

$database_username = "cacti";

$database_password = "cacti";

$database_port = "3306";

$database_ssl = false;

[root@server17 include]# nginx -s reload

访问server17.example.com/cacti出现如下页面:

解决方法如下:

[root@server17 include]# yum list net-snmp*

[root@server17 include]# yum install net-snmp.x86_64 net-snmp-utils.x86_64 net-snmp-perl.x86_64 net-snmp-python.x86_64 -y

按下一步会出现白屏,解决方法如下:

[root@server17 include]# vim /usr/local/lnmp/nginx/html/cacti/lib/functions.php

function kill_session_var($var_name) {

/* register_global = off: reset local settings cache so the user sees the new settings */

unset($_session_unregister[$var_name]);

/* register_global =
on: reset local settings cache so the user sees the new settings */

unset($_SESSION[$var_name]);

}

[root@server17
include]# useradd cacti

[root@server17
include]# chown cacti /usr/local/lnmp/nginx/html/cacti/rra/ -R

[root@server17
include]# chown cacti /usr/local/lnmp/nginx/html/cacti/log/ -R

[root@server17
include]# su - cacti

[cacti@server17
~]$ crontab -e

*/5
* * * * /usr/local/lnmp/php/bin/php
/usr/local/lnmp/nginx/html/cacti/poller.php

[cacti@server17
etc]$ logout

[root@server17
include]# /etc/init.d/crond start

[root@server17
include]# vim /etc/snmp/snmpd.conf

(注:以下配置可在http://www.cyberciti.biz/nixcraft/linux/docs/uniqlinuxfeatures/mrtg/上查看)

#com2sec
notConfigUser default public

com2sec
local localhost public

com2sec
mynetwork 192.168.122.0/24
public

#group
notConfigGroup v1 notConfigUser

#group
notConfigGroup v2c notConfigUser

group
MyRWGroup v1 local

group
MyRWGroup v2c local

group
MyRWGroup usm local

group
MyROGroup v1 mynetwork

group
MyROGroup v2c mynetwork

group
MyROGroup usm mynetwork

view
systemview included .1.3.6.1.2.1

view
systemview included .1.3.6.1.2.1.25.1.1

view
all included .1 80

#access
notConfigGroup "" any noauth exact
systemview none none

access
MyROGroup "" any noauth exact all none
none

access
MyRWGroup "" any noauth exact all all
none

syslocation
rhel6.3
(edit /etc/snmp/snmpd.conf)

syscontact
Root <root@localhost> (configure /etc/snmp/snmp.local.conf)

[root@server17
include]# /etc/init.d/snmpd start

[root@server17
include]# snmpwalk -v 1 -c public localhost IP-MIB::ipAdEntIfIndex
(此命令可在http://www.cyberciti.biz/nixcraft/linux/docs/uniqlinuxfeatures/mrtg/上查看)

IP-MIB::ipAdEntIfIndex.127.0.0.1
= INTEGER: 1

IP-MIB::ipAdEntIfIndex.192.168.122.117
= INTEGER: 2

(出现类似上面的输出为正常)

访问server17.example.com/cacti出现如下页面:

注:第一次登录会强制要求更改密码(初始用户名:admin,密码:admin)

出现类似上面图形说明可以正常采集到数据.

#安装插件

[root@server17 kernel]# tar zxf cacti-plugin-0.8.7h-PA-v3.0.tar.gz

[root@server17 kernel]# cd cacti-plugin-arch/

[root@server17 cacti-plugin-arch]# mysql cacti < pa.sql

[root@server17 cacti-plugin-arch]# cp cacti-plugin-0.8.7h-PA-v3.0.diff /usr/local/lnmp/nginx/html/cacti/

[root@server17 cacti]# yum install patch -y

[root@server17 cacti]# patch -p1 -N < cacti-plugin-0.8.7h-PA-v3.0.diff

[root@server17 cacti]# cd include/

[root@server17 include]# vim config.php

$cacti_session_name = "Cacti";

$url_path = "/cacti/";

[root@server17 kernel]# tar zxf settings-v0.71-1.tgz -C /usr/local/lnmp/nginx/html/cacti/plugins

[root@server17 kernel]# tar zxf monitor-v1.3-1.tgz -C /usr/local/lnmp/nginx/html/cacti/plugins

选择User Management


将Plugin Management打上对勾,按save保存.

在Configuration中就会出现Plugin Management这个选项,启动插件.

注:在新版的cacti中已经集成了Plugin Management这个功能,只需将要安装的插件包加压到cacti目录下的plugins目录中,然后在Plugin Management中安装激活即可使用

#安装并配置spine

[root@server17 ~]# yum install net-snmp-devel mysql-devel openssl-devel dos2unix autoconf automake binutils libtool gcc cpp glibc-headers kernel-headers glibc-devel -y

[root@server17 kernel]# tar zxf cacti-spine-0.8.7h.tar.gz

[root@server17 kernel]# cd cacti-spine-0.8.7h

[root@server17 cacti-spine-0.8.7h]# ./bootstrap

[root@server17 cacti-spine-0.8.7h]# ./configure --with-snmp=/usr/ --with-mysql=/usr/local/lnmp/mysql/

[root@server17 cacti-spine-0.8.7h]# make && make install

[root@server17 cacti-spine-0.8.7h]# cd /usr/local/spine/etc/

[root@server17 etc]# cp spine.conf.dist /etc/spine.conf

[root@server17 etc]# vim /etc/spine.conf

DB_Host localhost

DB_Database cacti

DB_User cacti

DB_Pass cacti

DB_Port 3306

DB_PreG 1

(注:如果你用的是cacti087g,将DB_PreG配置为0,否则将 DB_PreG配置为1.)

[root@server17 etc]# /usr/local/spine/bin/spine

此时会出现以下错误:

/usr/local/spine/bin/spine: error while loading shared libraries: libmysqlclient.so.18: cannot open shared object file: No such file or directory

解决方法如下:

[root@server17 etc]# vim /etc/ld.so.conf

include ld.so.conf.d/*.conf

/usr/local/lnmp/mysql/lib

[root@server17 etc]# ldconfig

执行/usr/local/spine/bin/spine出现类似如下结果为正确:

SPINE: Using spine config file [/etc/spine.conf]

SPINE: Version 0.8.7h starting

SPINE: Time: 0.1010 s, Threads: 5, Hosts: 2

选择Settings选项.

选择Paths选项.

如图填写并保存,然后选择Poller选项.

如图选择并保存.

注:观察图像,如果没有出现中断说明spine配置成功.

#监控远程主机(server85.example.com)

以下步骤在server85上实施:

[root@server85 ~]# yum install net-snmp-5.5-41.el6.x86_64 -y

[root@server85 ~]# yum install net-snmp-utils-5.5-41.el6.x86_64 -y

[root@server85 ~]# vim /etc/snmp/snmpd.conf

(注:以下配置可在http://www.cyberciti.biz/nixcraft/linux/docs/uniqlinuxfeatures/mrtg/上查看)

#com2sec notConfigUser default public

com2sec local localhost public

com2sec mynetwork 192.168.122.0/24 public

#group notConfigGroup v1 notConfigUser

#group notConfigGroup v2c notConfigUser

group MyRWGroup v1 local

group MyRWGroup v2c local

group MyRWGroup usm local

group MyROGroup v1 mynetwork

group MyROGroup v2c mynetwork

group MyROGroup usm mynetwork

view systemview included .1.3.6.1.2.1

view systemview included .1.3.6.1.2.1.25.1.1

view all included .1 80

#access notConfigGroup "" any noauth exact systemview none none

access MyROGroup "" any noauth exact all none none

access MyRWGroup "" any noauth exact all all none

syslocation rhel6.3 (edit /etc/snmp/snmpd.conf)

syscontact Root <root@localhost> (configure /etc/snmp/snmp.local.conf)

[root@server85 ~]# /etc/init.d/snmpd start

[root@server85 ~]# snmpwalk -v 1 -c public localhost IP-MIB::ipAdEntIfIndex(此命令可在http://www.cyberciti.biz/nixcraft/linux/docs/uniqlinuxfeatures/mrtg/上查看)

IP-MIB::ipAdEntIfIndex.127.0.0.1 = INTEGER: 1

IP-MIB::ipAdEntIfIndex.192.168.122.185 = INTEGER: 2

注:出现类似上面输出,说明配置完成.

以下步骤在server17上实施:

[root@server17 ~]# yum install net-snmp-5.5-41.el6.x86_64 -y

[root@server17 ~]# yum install net-snmp-utils-5.5-41.el6.x86_64 -y

[root@server17 ~]# vim /etc/snmp/snmpd.conf

(注:以下配置可在http://www.cyberciti.biz/nixcraft/linux/docs/uniqlinuxfeatures/mrtg/上查看)

#com2sec notConfigUser default public

com2sec local localhost public

com2sec mynetwork 192.168.122.0/24 public

#group notConfigGroup v1 notConfigUser

#group notConfigGroup v2c notConfigUser

group MyRWGroup v1 local

group MyRWGroup v2c local

group MyRWGroup usm local

group MyROGroup v1 mynetwork

group MyROGroup v2c mynetwork

group MyROGroup usm mynetwork

view systemview included .1.3.6.1.2.1

view systemview included .1.3.6.1.2.1.25.1.1

view all included .1 80

#access notConfigGroup "" any noauth exact systemview none none

access MyROGroup "" any noauth exact all none none

access MyRWGroup "" any noauth exact all all none

syslocation rhel6.3 (edit /etc/snmp/snmpd.conf)

syscontact Root <root@localhost> (configure /etc/snmp/snmp.local.conf)

[root@server17 ~]# /etc/init.d/snmpd start

[root@server17 ~]# snmpwalk -v 1 -c public 192.168.122.185 IP-MIB::ipAdEntIfIndex(此命令可在http://www.cyberciti.biz/nixcraft/linux/docs/uniqlinuxfeatures/mrtg/上查看)

IP-MIB::ipAdEntIfIndex.127.0.0.1 = INTEGER: 1

IP-MIB::ipAdEntIfIndex.192.168.122.185 = INTEGER: 2

选择Devices选项,并选择add设备.

如上图填写并保存.

注:如果需要监控root分区的剩余空间,需要将/etc/snmp/snmpd.conf中的disk / 1000这一行的注释去掉,这样在创建图时才有相应的选项,否则无法监控。

选择所要创建的图.

将新添加的设备加入到树中.

至此cacti的安装及配置完毕!!!

2.安装与配置nagios

[root@server17 kernel]# useradd nagios

[root@server17 kernel]# usermod -G nagios nginx(注:通过web更改nagios设置时,需要考虑此权限问题,例如:启动服务通知时)

[root@server17 kernel]# yum localinstall gd-devel-2.0.35-10.el6.x86_64.rpm -y

[root@server17 kernel]# tar jxf nagios-cn-3.2.3.tar.bz2

[root@server17 kernel]# cd nagios-cn-3.2.3

[root@server17 nagios-cn-3.2.3]# ./configure –enable-embedded-perl

此时会出现如下提示:

Can't locate ExtUtils/Embed.pm in @INC (@INC contains: /usr/local/lib64/perl5 /usr/local/share/perl5 /usr/lib64/perl5/vendor_perl /usr/share/perl5/vendor_perl /usr/lib64/perl5 /usr/share/perl5 .).

BEGIN failed--compilation aborted.

Can't locate ExtUtils/Embed.pm in @INC (@INC contains: /usr/local/lib64/perl5 /usr/local/share/perl5 /usr/lib64/perl5/vendor_perl /usr/share/perl5/vendor_perl /usr/lib64/perl5 /usr/share/perl5 .).

BEGIN failed--compilation aborted.

creating base/perlxsi.c

Can't locate ExtUtils/Embed.pm in @INC (@INC contains: /usr/local/lib64/perl5 /usr/local/share/perl5 /usr/lib64/perl5/vendor_perl /usr/share/perl5/vendor_perl /usr/lib64/perl5 /usr/share/perl5 .).

解决方法如下:

[root@server17
nagios-cn-3.2.3]# yum install perl-ExtUtils-Embed -y

[root@server17
nagios-cn-3.2.3]# make all

[root@server17
nagios-cn-3.2.3]# make install

[root@server17
nagios-cn-3.2.3]# make install-init

[root@server17
nagios-cn-3.2.3]# make install-commandmode

[root@server17
nagios-cn-3.2.3]# make install-config

[root@server17
kernel]# tar zxf nagios-plugins-1.4.16.tar.gz

[root@server17
kernel]# cd nagios-plugins-1.4.16

[root@server17
nagios-plugins-1.4.16]# yum install openssl-devel -y

[root@server17
nagios-plugins-1.4.16]# ./configure --enable-extra-opts
--enable-perl-modules --enable-libtap --with-nagios-user=nagios
--with-nagios-group=nagios

[root@server17
nagios-plugins-1.4.16]# make && make install

[root@server17
nagios-plugins-1.4.16]# chown nagios.nagios /usr/local/nagios/ -R

[root@server17
nagios-plugins-1.4.16]# /etc/init.d/nagios start

#安装perl
fcgi
模块

FCGI-0.74.tar.gz

[root@server17
kernel]# tar zxf FCGI-0.74.tar.gz

[root@server17
kernel]# cd FCGI-0.74

[root@server17
FCGI-0.74]# perl Makefile.PL

[root@server17
FCGI-0.74]# make && make install

FCGI-ProcManager-0.24.tar.gz

[root@server17
kernel]# tar zxf FCGI-ProcManager-0.24.tar.gz

[root@server17
kernel]# cd FCGI-ProcManager-0.24

[root@server17
FCGI-ProcManager-0.24]# perl Makefile.PL

[root@server17
FCGI-ProcManager-0.24]# make && make install

[root@server17
kernel]# yum install perl-ExtUtils-CBuilder.x86_64 -y

ExtUtils-Constant-0.23.tar.gz

[root@server17
kernel]# tar zxf ExtUtils-Constant-0.23.tar.gz

[root@server17
kernel]# cd ExtUtils-Constant-0.23

[root@server17
ExtUtils-Constant-0.23]# perl Makefile.PL

[root@server17
ExtUtils-Constant-0.23]# make && make install

Socket-2.001.tar.gz

[root@server17
kernel]# tar zxf Socket-2.001.tar.gz

[root@server17
kernel]# cd Socket-2.001

[root@server17
Socket-2.001]# perl Makefile.PL

[root@server17
Socket-2.001]# make && make install

#启动perl
fcgi

[root@server17
kernel]# mv fastcgi-wrapper.pl /usr/bin/

[root@server17
kernel]# chmod +x /usr/bin/fastcgi-wrapper.pl

[root@server17
kernel]# fastcgi-wrapper.pl

[root@server17
kernel]# netstat -antple | grep 8999

tcp
0 0 127.0.0.1:8999 0.0.0.0:*
LISTEN 0 49676 26855/perl

端口说明perl
fcgi启动成功.

#配置nginx发布nagios监控页面

[root@server17
kernel]# vim /usr/local/lnmp/nginx/conf/nginx.conf

server {

listen 80;

charset utf-8;
#默认字符集,解决页面乱码

server_name
nagios.westos.org;

root
/usr/local/nagios/share;

index index.php
index.html;

auth_basic "nagios
access"; #nagios认证

auth_basic_user_file
/usr/local/nagios/etc/htpasswd.users;

location /nagios {

alias
/usr/local/nagios/share;

}

location ~ \.php$ {

fastcgi_pass
127.0.0.1:9000;

include fastcgi.conf;

}

location ~
^/nagios/cgi-bin/ {

root
/usr/local/nagios/sbin/;

rewrite
^/nagios/cgi-bin/(.*)\.cgi /$1.cgi break;

include fastcgi.conf;

fastcgi_param
AUTH_USER $remote_user; #nagios认证

fastcgi_param
REMOTE_USER $remote_user;

fastcgi_pass
127.0.0.1:8999;

}

}

[root@server17
kernel]# yum install httpd-tools -y

[root@server17
kernel]# htpasswd -m /usr/local/nagios/etc/htpasswd.users nagiosadmin
(修改nagiosadmin密码)

[root@server17
kernel]# nginx -s reload

访问nagios.westos.org并登录(用户名为nagiosadmin),出现如下页面为成功.(注:记得IP和域名的解析)

此时如果访问拓扑图在终端中会出现以下报错:

/usr/local/nagios/sbin/statusmap.cgi: error while loading shared libraries: libiconv.so.2: cannot open shared object file: No such file or directory

解决方法如下:

[root@server17 kernel]# vim /etc/ld.so.conf

include ld.so.conf.d/*.conf

/usr/local/lnmp/mysql/lib

/usr/local/lib64

[root@server17 kernel]# ldconfig

[root@server17 kernel]# yum localinstall rrdtool-perl-1.3.8-6.el6.x86_64.rpm -y

[root@server17
kernel]# yum install cjkuni-uming-fonts -y #中文字体

#配置nagios监控本机

[root@server17
~]# cd /usr/local/nagios/etc/

[root@server17
etc]# vim nagios.cfg

#cfg_file=/usr/local/nagios/etc/objects/localhost.cfg

cfg_file=/usr/local/nagios/etc/objects/hosts.cfg

cfg_file=/usr/local/nagios/etc/objects/services.cfg

[root@server17
etc]# cd objects/

[root@server17
objects]# cp -p localhost.cfg hosts.cfg

[root@server17
objects]# vim hosts.cfg

define
host{

use
linux-server

host_name
server17.example.com

alias
Nagios
server

address
192.168.122.117

icon_image
switch.gif

statusmap_image
switch.gd2

2d_coords
100,200

3d_coords
100,200,100

}

define
hostgroup{

hostgroup_name
linux-servers ;

alias
Linux Servers ;

members *
;

}

[root@server17
objects]# cp -p localhost.cfg services.cfg

[root@server17
objects]# vim services.cfg

define
servicegroup{

servicegroup_name
系统负荷检查

alias 负荷检查

members
server17.example.com,进程总数,server17.example.com,登录用户数,server17.example.com,根分区,server17.example.com,交换空间利用率

}

define
service{

use
local-service ;

host_name
*

service_description
PING

check_command
check_ping!100.0,20%!500.0,60%

}

define
service{

use
local-service ;

host_name
server17.example.com

service_description
根分区

check_command
check_local_disk!20%!10%!/

}

define
service{

use
local-service ;

host_name
server17.example.com

service_description
登录用户数

check_command
check_local_users!20!50

}

define
service{

use
local-service ;

host_name
server17.example.com

service_description
进程总数

check_command
check_local_procs!250!400!RSZDT

}

define
service{

use
local-service ;

host_name
server17.example.com

service_description
系统负荷

check_command
check_local_load!5.0,4.0,3.0!10.0,6.0,4.0

}

define
service{

use
local-service ;

host_name
server17.example.com

service_description
交换空间利用率

check_command
check_local_swap!20!10

}

define
service{

use
local-service ;

host_name
server17.example.com

service_description
SSH

check_command
check_tcp!22!1.0!10.0

notifications_enabled
0

}

define
service{

use
local-service ;

host_name
server17.example.com

service_description
NGINX

check_command
check_http

notifications_enabled
0

}

[root@server17
objects]# /usr/local/nagios/bin/nagios -v
/usr/local/nagios/etc/nagios.cfg
(检测配置是否有错误)

[root@server17
objects]# /etc/init.d/nagios reload

访问nagios.westos.org:

#配置飞信并与nagios整合

[root@server17 kernel]# mv fetion /usr/local/nagios/libexec/

[root@server17 kernel]# chmod +x /usr/local/nagios/libexec/fetion

[root@server17 kernel]# chown nagios.nagios /usr/local/nagios/libexec/fetion

[root@server17 kernel]# tar zxf linuxso_20101113.tar.gz -C /lib

[root@server17 kernel]# su - nagios

[nagios@server17 ~]$ /usr/local/nagios/libexec/fetion

此时会出现如下错误:

(1)/usr/local/nagios/libexec/fetion: error while loading shared libraries: libstdc++.so.6: cannot open shared object file: No such file or directory

(2)/usr/local/nagios/libexec/fetion: error while loading shared libraries: libgssapi_krb5.so.2: cannot open shared object file: No such file or directory

(3)/usr/local/nagios/libexec/fetion: error while loading shared libraries: libz.so.1: cannot open shared object file: No such file or directory

解决方法如下:

(1)[root@server17
kernel]# yum install libstdc++.so.6 -y

(2)[root@server17
kernel]# yum install libgssapi_krb5.so.2 -y

(3)[root@server17
kernel]# yum install libz.so.1 -y

注:出现以上输出为正常

测试:[nagios@server17 ~]$ /usr/local/nagios/libexec/fetion --mobile=15905986853 --pwd=lmx15905986853 --to=15905986853 --msg-utf8='Good Luck!'

图形验证码跟你的fetion脚本在同一个目录下

[root@server17 ~]# su - nagios

[nagios@server17 ~]$ cd /usr/local/nagios/libexec/

[nagios@server17 libexec]$ vim fetion.sh

/usr/local/nagios/libexec/fetion --mobile=15905986853 --pwd=lmx15905986853 --to="$1" –msg-utf8="$2"

[nagios@server17 libexec]$ chmod +x fetion.sh

测试: [nagios@server17 libexec]$ /usr/local/nagios/libexec/fetion.sh 15905986853 "hello world"

[nagios@server17 libexec]$ cd /usr/local/nagios/etc/objects/

[nagios@server17 objects]$ vim commands.cfg

# 'notify-host-by-fetion' command definition

define command{

command_name notify-host-by-fetion

command_line $USER1$/fetion.sh $CONTACTPAGER$ "$NOTIFICATIONTYPE$ Host Alert: $HOSTNAME$ is $HOSTSTATE$"

}

#
'notify-service-by-fetion'
command definition

define
command{

command_name
notify-service-by-fetion

command_line
$USER1$/fetion.sh
$CONTACTPAGER$ "$NOTIFICATIONTYPE$ Service Alert:
$HOSTALIAS$/$SERVICEDESC$ is $SERVICESTATE$"

}

[nagios@server17
objects]$ vim templates.cfg

define
contact{

name
generic-contact ;

service_notification_period
24x7 ;

host_notification_period
24x7 ;

service_notification_options
w,u,c,r,f,s ;

host_notification_options
d,u,r,f,s ;

service_notification_commands
notify-service-by-email,notify-service-by-fetion
;

host_notification_commands
notify-host-by-email,notify-host-by-fetion
;

register
0 ;

}

[nagios@server17
objects]$ vim contacts.cfg

define
contact{

contact_name
nagiosadmin ;

use
generic-contact ;

alias
Nagios Admin ;

email
nagios@localhost ;

pager
15905986853 ;

}

[nagios@server17
objects]$ /etc/init.d/nagios reload

测试:[root@server17
~]# /etc/init.d/sshd stop

如果一段时候后收到短信说明配置成功

#配置nagios监控远程主机上的服务(mysql为例)

以下步骤在server85上实施:

[root@server85
libexec]# mysql

mysql>
create database nagios;

mysql>
grant select on nagios.* to nagios@'192.168.122.117';

mysql>
quit

测试:server17上执行/usr/local/nagios/libexec/check_mysql
-H 192.168.122.185 -u nagios ,
若出现类似如下输出说明正常:

Uptime:
300 Threads: 1 Questions: 11 Slow queries: 0 Opens: 70 Flush
tables: 1 Open tables: 63 Queries per second avg: 0.036

以下步骤在server17上实施:

先将
nagios-cn-3.2.3.tar.bz2
nagios-plugins-1.4.16.tar.gz装上

[root@server17
~]# cd /usr/local/nagios/etc/objects/

[root@server17
objects]# vim commands.cfg

#
'check_mysql'
command definition

define
command{

command_name
check_mysql

command_line
$USER1$/check_mysql
-H $HOSTADDRESS$ -u $ARG1$ -d $ARG2$

}

[root@server17
objects]# vim hosts.cfg

define
host{

use
linux-server

host_name
server85.example.com

alias
Mysql
server

address
192.168.122.185

}

[root@server17
objects]# vim services.cfg

define
service{

use
generic-service

host_name
server85.example.com

service_description
MYSQL

check_command
check_mysql!nagios!nagios

}

[root@server17
objects]# /etc/init.d/nagios reload

访问nagios.westos.org查看如下图说明配置成功

#配置nagios监控远程主机

以下步骤在server85上实施:

先将nagios-plugins-1.4.16.tar.gz装上

[root@server85 kernel]# yum install xinetd -y

[root@server85 kernel]# tar zxf nrpe-2.14.tar.gz

[root@server85 kernel]# cd nrpe-2.14

[root@server85 nrpe-2.14]# ./configure

[root@server85 nrpe-2.14]# useradd nagios

[root@server85 nrpe-2.14]# chown nagios.nagios /usr/local/nagios/ -R

[root@server85 nrpe-2.14]# make all

[root@server85 nrpe-2.14]# make install-plugin

[root@server85 nrpe-2.14]# make install-daemon

[root@server85 nrpe-2.14]# make install-daemon-config

[root@server85 nrpe-2.14]# make install-xinetd

[root@server85 nrpe-2.14]# vim /etc/xinetd.d/nrpe

# default: on

# description: NRPE (Nagios Remote Plugin Executor)

service nrpe

{

flags = REUSE

socket_type = stream

port = 5666

wait = no

user = nagios

group = nagios

server = /usr/local/nagios/bin/nrpe

server_args = -c /usr/local/nagios/etc/nrpe.cfg --inetd

log_on_failure += USERID

disable = no

only_from = 192.168.122.117

}

[root@server85 nrpe-2.14]# vim /etc/services

nrpe 5666/tcp #NRPE

[root@server85 nrpe-2.14]# vim /usr/local/nagios/etc/nrpe.cfg

command[check_users]=/usr/local/nagios/libexec/check_users -w 5 -c 10

command[check_load]=/usr/local/nagios/libexec/check_load -w 15,10,5 -c 30,25,20

command[check_disk]=/usr/local/nagios/libexec/check_disk -w 20% -c 10% -p /

command[check_zombie_procs]=/usr/local/nagios/libexec/check_procs -w 5 -c 10 -s Z

command[check_total_procs]=/usr/local/nagios/libexec/check_procs -w 150 -c 200

[root@server85 nrpe-2.14]# /etc/init.d/xinetd restart

[root@server85 nrpe-2.14]# netstat -antple

tcp 0 0 :::5666 :::* LISTEN 0 40011 1407/xinetd

端口

以下步骤在server17上实施:

[root@server17
kernel]# tar zxf nrpe-2.14.tar.gz

[root@server17
kernel]# cd nrpe-2.14

[root@server17
nrpe-2.14]# ./configure

[root@server17
nrpe-2.14]# make all

[root@server17
nrpe-2.14]# make install-plugin

测试:执行/usr/local/nagios/libexec/check_nrpe
-H 192.168.122.185 -c check_disk
若出现如下输出为正常:

DISK
OK - free space: / 1581 MB (36% inode=76%);|
/=2761MB;3659;4116;0;4574

[root@server17
nrpe-2.14]# cd /usr/local/nagios/etc/objects/

[root@server17
objects]# vim commands.cfg

#
'check_nrpe' command definition

define
command{

command_name
check_nrpe

command_line
$USER1$/check_nrpe -H $HOSTADDRESS$ -c
$ARG1$

}

[root@server17
objects]# vim services.cfg

define
service{

use
local-service

host_name
server85.example.com

service_description
根分区

check_command
check_nrpe!check_disk

}

define
service{

use
local-service

host_name
server85.example.com

service_description
系统负荷

check_command
check_nrpe!check_load

}

[root@server17
objects]# /usr/local/nagios/bin/nagios -v
/usr/local/nagios/etc/nagios.cfg
(检测配置是否有错误)

[root@server17
objects]# /etc/init.d/nagios reload

访问nagios.westos.org查看如下图说明配置成功

至此nagios的安装及配置完毕!!!

3.安装与配置ganglia

[root@server17 kernel]# yum install rpm-build -y

[root@server17 kernel]# rpmbuild -tb ganglia-3.4.0.tar.gz

此时会出现如下错误:

error: Failed build dependencies:

libart_lgpl-devel is needed by ganglia-3.4.0-1.x86_64

python-devel is needed by ganglia-3.4.0-1.x86_64

libconfuse-devel is needed by ganglia-3.4.0-1.x86_64

expat-devel is needed by ganglia-3.4.0-1.x86_64

rrdtool-devel is needed by ganglia-3.4.0-1.x86_64

apr-devel > 1 is needed by ganglia-3.4.0-1.x86_64

解决方法如下:

[root@server17 kernel]# yum install libart_lgpl-devel python-devel expat-devel apr-devel -y

[root@server17 kernel]# rpm -ivh rrdtool-devel-1.3.8-6.el6.x86_64.rpm

[root@server17 kernel]# rpm -ivh libconfuse-*

中由于对服务的管理机制不一样(由systemv到systemd),所以在直接进行编译(rpmbuild -tb ganglia-3.6.0.tar.gz)时会出现如下错误:

make[2]: *** No rule to make target `gmetad.service.in', needed by `gmetad.service'. Stop.

make[2]: Leaving directory `/root/rpmbuild/BUILD/ganglia-3.6.0/gmetad'

make[1]: *** [all-recursive] Error 1

make[1]: Leaving directory `/root/rpmbuild/BUILD/ganglia-3.6.0'

make: *** [all] Error 2

error: Bad exit status from /var/tmp/rpm-tmp.J7WIYv (%build)

RPM
build errors:

bogus date in %changelog:
Thu Mar 28 2008 Brad Nicholes <bnicholes@novell.com>

bogus date in %changelog:
Wed Jul 10 2007 Bernard Li <bernard@vanhpc.org>

bogus date in %changelog:
Wed Jul 3 2007 Brad Nicholes <bnicholes@novell.com>

bogus date in %changelog:
Wed Jun 14 2007 Brad Nicholes <bnicholes@novell.com>

bogus date in %changelog:
Fri Feb 25 2006 Bernard Li <bli@bcgsc.ca>

Bad exit status from
/var/tmp/rpm-tmp.J7WIYv (%build)

解决方法如下:

[root@server17
kernel]# tar zxf ganglia-3.6.0.tar.gz

[root@server17
kernel]# cd ganglia-3.6.0

[root@server17
ganglia-3.6.0]# vim ganglia.spec (/files)

%files
gmetad

%defattr(-,root,root)

%attr(0755,nobody,nobody)/var/lib/ganglia/

%{_sbindir}/gmetad

/etc/init.d/gmetad

/usr/lib/systemd/system/gmetad.service

%config(noreplace)
/etc/sysconfig/gmetad

%{_mandir}/man1/gmetad*1*

%config(noreplace)
%{conf_dir}/gmetad.conf

%files
gmond

%defattr(-,root,root)

%{_bindir}/gmetric

%{_bindir}/gstat

%{_sbindir}/gmond

/etc/init.d/gmond

/usr/lib/systemd/system/gmond.service

%{_mandir}/man1/gmetric.1*

%{_mandir}/man1/gmond.1*

%{_mandir}/man1/gstat.1*

%{_mandir}/man5/gmond.conf.5*

[root@server17
ganglia-3.6.0]# cd gmetad

[root@server17
gmetad]# vim gmetad.service.in

[Unit]

Description=Ganglia
Meta Daemon

After=network.target

[Service]

Type=forking

PIDFile=/run/gmetad.pid

ExecStart=/usr/sbin/gmetad
--pid-file=/run/gmetad.pid

#EnvironmentFile=-/etc/sysconfig/gmetad

[Install]

WantedBy=multi-user.target

[root@server17
gmetad]# cd ../gmond/

[root@server17
gmond]# vim gmond.service.in

[Unit]

Description=Ganglia
Monitor Daemon

After=network.target

[Service]

Type=forking

PIDFile=/run/gmond.pid

ExecStart=/usr/sbin/gmond
--pid-file=/run/gmond.pid

[Install]

WantedBy=multi-user.target

[root@server17
gmond]# cd /root/kernel

[root@server17
kernel]# rm -rf ganglia-3.6.0.tar.gz

[root@server17
kernel]# tar zcvf ganglia-3.6.0.tar.gz ganglia-3.6.0/ (重新打包)

[root@server17
kernel]# rpmbuild -tb ganglia-3.6.0.tar.gz

[root@server17
kernel]# cd ~/rpmbuild/RPMS/x86_64/

[root@server17
x86_64]# rpm -ivh *

[root@server17
x86_64]# vim /etc/ganglia/gmond.conf

cluster
{

name
= "my
cluster"

owner = "unspecified"

latlong = "unspecified"

url = "unspecified"

}

[root@server17
x86_64]# /etc/init.d/gmetad start

[root@server17
x86_64]# /etc/init.d/gmond start

若配置成功在/var/lib/ganglia/rrds/会自动建立my
cluster和__SummaryInfo__两个文件夹,采集到的信息存储在my
cluster中.

#ganglia以网页的形式发布

[root@server17
kernel]# tar zxf ganglia-web-3.5.2.tar.gz

[root@server17
kernel]# cd ganglia-web-3.5.2

[root@server17
ganglia-web-3.5.2]# vim Makefile

#
Location where gweb should be installed to

GDESTDIR
= /usr/local/lnmp/nginx/html/ganglia

APACHE_USER
= nginx

[root@server17
ganglia-web-3.5.2]# make install

此时会出现如下错误:

rsync
--exclude "rpmbuild" --exclude "*.gz" --exclude
"Makefile" --exclude "*debian*" --exclude
"ganglia-web-3.5.2" --exclude ".git*" --exclude
"*.in" --exclude "*~" --exclude "#*#"
--exclude "ganglia-web.spec" -a . ganglia-web-3.5.2

/bin/sh:
rsync: command not found

make:
*** [dist-dir] Error 127

解决方法如下:

[root@server17
ganglia-web-3.5.2]# yum install rsync -y

访问server17.example.com/ganglia出现下面页面说明配置成功.

#配置ganglia监控远程主机并进行分组监控

以下步骤在server17上实施:

[root@server17 ~]# cd ~/rpmbuild/RPMS/x86_64/

[root@server17 x86_64]# scp ganglia-gmond-* ganglia-devel-3.4.0-1.x86_64.rpm libganglia-3.4.0-1.x86_64.rpm root@192.168.122.185:~/kernel/

[root@server17 x86_64]# vim /etc/ganglia/gmetad.conf

# data_source "my cluster" 10 localhost my.machine.edu:8649 1.2.3.5:8655

# data_source "my grid" 50 1.3.4.7:8655 grid.org:8651 grid-backup.org:8651

# data_source "another source" 1.3.4.7:8655 1.3.4.8

data_source
"webcluster" localhost:8680
192.168.122.185:8680

[root@server17
x86_64]# vim /etc/ganglia/gmond.conf

cluster
{

name = "webcluster"

owner = "unspecified"

latlong = "unspecified"

url = "unspecified"

}

udp_send_channel
{

#bind_hostname = yes # Highly recommended, soon to be default.

# This option tells gmond to use a source
address

# that resolves to the machine's hostname.
Without

# this, the metrics may appear to come from any

# interface and the DNS names associated with

# those IPs will be used to create the RRDs.

mcast_join = 239.2.11.71

port = 8680

ttl = 1

}

udp_recv_channel
{

mcast_join = 239.2.11.71

port = 8680

bind = 239.2.11.71

retry_bind = true

# Size of the UDP buffer. If you are handling lots of metrics you
really

# should bump it up to e.g. 10MB or even higher.

# buffer = 10485760

}

tcp_accept_channel
{

port = 8680

# If you want to gzip XML output

gzip_output = no

}

以下步骤在server85上实施:

[root@server85
~]# cd ~/kernel/

[root@server85
kernel]# rpm -ivh ganglia-gmond-*

此时会出现如下错误:

error:
Failed dependencies:

libapr-1.so.0()(64bit)
is needed by ganglia-gmond-3.4.0-1.x86_64

libconfuse.so.0()(64bit)
is needed by ganglia-gmond-3.4.0-1.x86_64

libganglia-3.4.0.so.0()(64bit)
is needed by ganglia-gmond-3.4.0-1.x86_64

libapr-1.so.0()(64bit)
is needed by ganglia-gmond-modules-python-3.4.0-1.x86_64

libconfuse.so.0()(64bit)
is needed by ganglia-gmond-modules-python-3.4.0-1.x86_64

解决方法如下:

[root@server85
kernel]# yum install apr-devel expat-devel -y

[root@server85
kernel]# rpm -ivh libconfuse-*

[root@server85
kernel]# rpm -ivh libganglia-3.4.0-1.x86_64.rpm

[root@server85
kernel]# rpm -ivh ganglia-devel-3.4.0-1.x86_64.rpm

[root@server85
kernel]# vim /etc/ganglia/gmond.conf

cluster
{

name = "webcluster"

owner = "unspecified"

latlong = "unspecified"

url = "unspecified"

}

udp_send_channel
{

#bind_hostname = yes # Highly recommended, soon to be default.

# This option tells gmond to use a source
address

# that resolves to the machine's hostname.
Without

# this, the metrics may appear to come from any

# interface and the DNS names associated with

# those IPs will be used to create the RRDs.

mcast_join = 239.2.11.71

port = 8680

ttl = 1

}

udp_recv_channel
{

mcast_join = 239.2.11.71

port = 8680

bind = 239.2.11.71

retry_bind = true

# Size of the UDP buffer. If you are handling lots of metrics you
really

# should bump it up to e.g. 10MB or even higher.

# buffer = 10485760

}

tcp_accept_channel
{

port = 8680

# If you want to gzip XML output

gzip_output = no

}

[root@server85
kernel]# /etc/init.d/gmond start

若在server17的/var/lib/ganglia/rrds/my\
cluster/ 下出现server85.example.com的目录说明配置成功

注:数据存储在/var/lib/ganglia/rrds中,如果重新配置了组名等信息,需要先暂停gmetad和gmond服务,将/var/lib/ganglia/rrds中的文件全部清空,然后启动服务,让服务自动重新建立数据文件。

至此ganglia的安装及配置完毕!!!

4.nagiosganglia整合

[root@server17
~]# find / -name check_ganglia.py

[root@server17
~]# cp /root/rpmbuild/BUILD/ganglia-3.4.0/contrib/check_ganglia.py
/usr/local/nagios/libexec/

[root@server17
~]# chmod +x /usr/local/nagios/libexec/check_ganglia.py

[root@server17
~]# chown nagios.nagios /usr/local/nagios/libexec/check_ganglia.py

[root@server17
~]# vim /usr/local/nagios/libexec/check_ganglia.py

if
critical > warning:

if value >= critical:

print "CHECKGANGLIA
CRITICAL: %s is %.2f" % (metric, value)

sys.exit(2)

elif value >= warning:

print
"CHECKGANGLIA WARNING: %s is %.2f" % (metric, value)

sys.exit(1)

else:

print "CHECKGANGLIA
OK: %s is %.2f" % (metric, value)

sys.exit(0)

else:

if critical
>= value:

print "CHECKGANGLIA
CRITICAL: %s is %.2f" % (metric, value)

sys.exit(2)

elif warning
>= value:

print "CHECKGANGLIA
WARNING: %s is %.2f" % (metric, value)

sys.exit(1)

else:

print "CHECKGANGLIA
OK: %s is %.2f" % (metric, value)

sys.exit(0)

测试:

/usr/local/nagios/libexec/check_ganglia.py
-h server85.example.com -m disk_free_percent_rootfs -w 20 -c 10

CHECKGANGLIA
OK:
disk_free_percent_rootfs is 34.17

/usr/local/nagios/libexec/check_ganglia.py
-h server85.example.com -m disk_free_percent_rootfs -w 40 -c 30

CHECKGANGLIA
WARNING: disk_free_percent_rootfs is
34.17

/usr/local/nagios/libexec/check_ganglia.py
-h server85.example.com -m disk_free_percent_rootfs -w 40 -c 35

CHECKGANGLIA
CRITICAL: disk_free_percent_rootfs is
34.17

注:-h后所指定的主机名或IP需要与/var/lib/ganglia/rrds/my
cluster/
中的文件夹名称对应

[root@server17
~]# cd /usr/local/nagios/etc/objects/

[root@server17
objects]# vim commands.cfg

#
'check_ganglia'
command definition

define
command{

command_name
check_ganglia

command_line
$USER1$/check_ganglia.py
-h $HOSTNAME$ -m $ARG1$ -w $ARG2$ -c $ARG3$

}

[root@server17
objects]# vim hosts.cfg

define
host{

use
linux-server

host_name
server85.example.com

alias
ganglia
and mysql client

address
192.168.122.185

}

define
hostgroup {

hostgroup_name
ganglia-servers

alias
ganglia-servers

members
server85.example.com

}

[root@server17
objects]# vim templates.cfg

define
service {

use generic-service

name ganglia-service

hostgroup_name
ganglia-servers

service_groups
ganglia-metrics

}

[root@server17
objects]# vim services.cfg

define
servicegroup {

servicegroup_name
ganglia-metrics

alias
ganglia-metrics

}

define
service{

use ganglia-service

service_description
根空闲

check_command
check_ganglia!disk_free_percent_rootfs!20!10

}

define
service{

use ganglia-service

service_description
内存空间

check_command
check_ganglia!mem_free!50000!30000(少于50M警告,少于30M紧急)

}

[root@server17
objects]# /usr/local/nagios/bin/nagios -v
/usr/local/nagios/etc/nagios.cfg (检测配置是否有错误)

[root@server17
objects]# /etc/init.d/nagios reload

访问nagios.westos.org出现如下页面说明配置成功.

至此nagiosganglia整合完毕!!!

5.nagioscacti整合

可参考: https://trac.assembla.com/npc

首先确保你的php支持pdo和json模块

[root@server17 kernel]# tar zxf npc-2.0.4.tar.gz -C /usr/local/lnmp/nginx/html/cacti/plugins

启动npc插件

启动时会出现如下图的错误,可忽略,重启nginx即可.

选择Setting

选择NPC

如上图配置并保存

[root@server17 kernel]# vim /usr/local/nagios/etc/nagios.cfg

broker_module=/usr/local/nagios/bin/ndomod.o config_file=/usr/local/nagios/etc/ndomod.cfg

[root@server17 kernel]# tar zxf ndoutils-1.4b9.tar.gz (ndoutils负责将nagios采集到的数据存到数据库中,通过rrdtool进行绘图)

[root@server17 kernel]# yum remove mysql-libs -y

[root@server17 kernel]# cp /etc/my.cnf.rpmsave /etc/my.cnf

[root@server17 kernel]# ln -s /usr/local/lnmp/mysql/include/ /usr/include/mysql

[root@server17 kernel]# ln -s /usr/local/lnmp/mysql/lib /usr/lib64/mysql

[root@server17 kernel]# cd ndoutils-1.4b9

[root@server17 ndoutils-1.4b9]# ./configure –enable-mysql

[root@server17 ndoutils-1.4b9]# make

[root@server17 ndoutils-1.4b9]# cd src/

[root@server17 src]# cp ndomod-3x.o /usr/local/nagios/bin/ndomod.o

[root@server17 src]# cp ndo2db-3x /usr/local/nagios/bin/ndo2db

[root@server17 src]# cd ../config

[root@server17 config]# cp ndomod.cfg-sample /usr/local/nagios/etc/ndomod.cfg

[root@server17 config]# cp ndo2db.cfg-sample /usr/local/nagios/etc/ndo2db.cfg

[root@server17 config]# chown nagios.nagios /usr/local/nagios/bin/ -R

[root@server17 config]# chown nagios.nagios /usr/local/nagios/etc/ -R

[root@server17 config]# cd /usr/local/nagios/etc/

[root@server17 etc]# vim ndo2db.cfg

ndo2db_user=nagios

ndo2db_group=nagios

#socket_type=unix

socket_type=tcp

socket_name=/usr/local/nagios/var/ndo.sock

tcp_port=5668

db_servertype=mysql

db_host=localhost

db_port=3306

db_name=cacti

db_prefix=npc_

db_user=cacti

db_pass=cacti

max_timedevents_age=1440

max_systemcommands_age=10080

max_servicechecks_age=10080

max_hostchecks_age=10080

max_eventhandlers_age=44640

max_externalcommands_age=44640

debug_level=1

debug_verbosity=1

debug_file=/usr/local/nagios/var/ndo2db.debug

max_debug_file_size=1000000

[root@server17 etc]# vim ndomod.cfg

instance_name=default

output_type=tcpsocket

#output_type=unixsocket

output=127.0.0.1

#output=/usr/local/nagios/var/ndo.sock

tcp_port=5668

output_buffer_items=5000

buffer_file=/usr/local/nagios/var/ndomod.tmp

file_rotation_interval=14400

file_rotation_timeout=60

reconnect_interval=15

reconnect_warning_interval=15

data_processing_options=-1

config_output_options=2

[root@server17 etc]# /etc/init.d/nagios reload

[root@server17 etc]# /usr/local/nagios/bin/ndo2db -c /usr/local/nagios/etc/ndo2db.cfg

[root@server17 etc]# ps ax

28802 ? Ss 0:00 /usr/local/nagios/bin/ndo2db -c /usr/local/nagios/etc

查看到类似如上进程为正常

访问server17.example.com/cacti可在npc下看到如下页面

此时执行cat /var/log/messages可看到如下报错:

Jul 13 15:02:25 server17 ndo2db: mysql_error: 'Unknown column 'long_output' in 'field list''

解决方法如下:

当使用的npc插件版本较低时使用如下sql语句向数据库中添加字段:

[root@server17 kernel]# mysql cacti < add-old.sql

add-old.sql中的内容为:

ALTER TABLE `npc_hostchecks` ADD COLUMN `long_output` varchar(8192) NOT NULL default '' AFTER `output`;

ALTER TABLE `npc_hoststatus` ADD COLUMN `long_output` varchar(8192) NOT NULL default '' AFTER `output`;

ALTER TABLE `npc_servicechecks` ADD COLUMN `long_output` varchar(8192) NOT NULL default '' AFTER `output`;

ALTER TABLE `npc_servicestatus` ADD COLUMN `long_output` varchar(8192) NOT NULL default '' AFTER `output`;

ALTER TABLE `npc_statehistory` ADD COLUMN `long_output` varchar(8192) NOT NULL default '' AFTER `output`;

ALTER TABLE `npc_eventhandlers` ADD COLUMN `long_output` varchar(8192) NOT NULL default '' AFTER `output`;

ALTER TABLE `npc_systemcommands` ADD COLUMN `long_output` varchar(8192) NOT NULL default '' AFTER `output`;

ALTER TABLE `npc_notifications` ADD COLUMN `long_output` varchar(8192) NOT NULL default '' AFTER `output`;

当使用的npc插件版本较高时使用如下sql语句向数据库中添加字段:

[root@server17
kernel]# mysql cacti < add-new.sql

add-new.sql中的内容为:

CREATE
TABLE IF NOT EXISTS `npc_service_parentservices` (

`service_parentservice_id`
int(11) NOT NULL auto_increment,

`instance_id` smallint(6)
NOT NULL default '0',

`service_id` int(11) NOT
NULL default '0',

`parent_service_object_id`
int(11) NOT NULL default '0',

PRIMARY KEY
(`service_parentservice_id`),

UNIQUE KEY `instance_id`
(`service_id`,`parent_service_object_id`)

)
ENGINE=MyISAM COMMENT='Parent services';

ALTER
TABLE `npc_hostchecks` ADD COLUMN `long_output` varchar(8192) NOT
NULL default '' AFTER `output`;

ALTER
TABLE `npc_hoststatus` ADD COLUMN `long_output` varchar(8192) NOT
NULL default '' AFTER `output`;

ALTER
TABLE `npc_servicechecks` ADD COLUMN `long_output` varchar(8192) NOT
NULL default '' AFTER `output`;

ALTER
TABLE `npc_servicestatus` ADD COLUMN `long_output` varchar(8192) NOT
NULL default '' AFTER `output`;

ALTER
TABLE `npc_statehistory` ADD COLUMN `long_output` varchar(8192) NOT
NULL default '' AFTER `output`;

ALTER
TABLE `npc_eventhandlers` ADD COLUMN `long_output` varchar(8192) NOT
NULL default '' AFTER `output`;

ALTER
TABLE `npc_systemcommands` ADD COLUMN `long_output` varchar(8192) NOT
NULL default '' AFTER `output`;

ALTER
TABLE `npc_notifications` ADD COLUMN `long_output` varchar(8192) NOT
NULL default '' AFTER `output`;

ALTER
TABLE `npc_services` ADD COLUMN `importance` varchar(8192) NOT NULL
default '' AFTER `icon_image_alt`;

ALTER
TABLE `npc_contacts` ADD COLUMN `minimum_importance` varchar(8192)
NOT NULL default '' AFTER `notify_host_downtime`;

ALTER
TABLE `npc_hosts` ADD COLUMN `importance` varchar(8192) NOT NULL
default '' AFTER `z_3d`;

[root@server17
kernel]# tar zxf PDO_MYSQL-1.0.2.tgz

[root@server17
kernel]# cd PDO_MYSQL-1.0.2

[root@server17
PDO_MYSQL-1.0.2]# phpize

[root@server17
PDO_MYSQL-1.0.2]# ln -s /usr/local/lnmp/mysql/include/*
/usr/local/include/

[root@server17
PDO_MYSQL-1.0.2]# ./configure
--with-php-config=/usr/local/lnmp/php/bin/php-config
–with-pdo-mysql=/usr/local/lnmp/mysql/

[root@server17
PDO_MYSQL-1.0.2]# make

[root@server17
PDO_MYSQL-1.0.2]# make install

[root@server17
PDO_MYSQL-1.0.2]# vim /usr/local/lnmp/php/etc/php.ini

extension=pdo_mysql.so

[root@server17
PDO_MYSQL-1.0.2]# /etc/init.d/php-fpm reload

访问server17.example.com/index.php能看到pdo_mysql模块加载成功

访问server17.example.com/cacti能看到如下页面说明配置成功.

至此nagioscacti整合完毕!!!

监控系统配置完毕!!!

Rhel6-cacti+nagios+ganglia(nginx)配置文档的更多相关文章

  1. Rhel6-cacti+nagios+ganglia(apache)配置文档

    (lamp平台) 系统环境: rhel6 x86_64 iptables and selinux disabled 主机: 192.168.122.119 server19.example.com 1 ...

  2. 史上最全的Nginx配置文档

    Nginx是一个异步框架的Web服务器,也可以用作反向代理,负载平衡器 和 HTTP缓存.该软件由Igor Sysoev 创建,并于2004年首次公开发布.同名公司成立于2011年,以提供支持.Ngi ...

  3. Nginx配置文档具体解释

    Nginx的配置文档具体解释.在这儿做个总结,以便以后使用的时间查看. 下面大部分自己整理.部分来自參考 #设置用户 #user  nobody; #启动进程数(一般和server的CPU同样) #能 ...

  4. Cacti+nagios 整合监控部署文档

    目录 Cacti+nagios监控部署步骤... 2 一.Cacti安装... 2 1需要安装的依赖软件包:... 2 2安装rrdtool 2 3启动数据库和httpd服务... 3 4将serve ...

  5. Nginx配置文档

    转https://www.cnblogs.com/hunttown/p/5759959.html

  6. nginx 安全配置文档

    1.配置文档中有多处明确写出了nginx的配置文件路径,该路径是测试环境中的路径,线上系统的nginx配置文件与文档中所写的路径可能不一样,在进行相关配置时,应以线上配置文件的实际路径为准. 线上系统 ...

  7. (转)nginx 安全配置文档

    原文:https://www.cnblogs.com/heaven-xi/p/9961357.html#top 1.配置文档中有多处明确写出了nginx的配置文件路径,该路径是测试环境中的路径,线上系 ...

  8. elk实战分析nginx日志文档

    elk实战分析nginx日志文档 架构: kibana <--- es-cluster <--- logstash <--- filebeat 环境准备:192.168.3.1 no ...

  9. tomcat 安全配置文档

    1.配置文档中使用$CATALINA_HOME变量声明为tomcat的安装目录并明确写出了tomcat的配置文件路径,此路径为测试环境的路径,线上系统对应配置文件的路径可能不一样,在进行相关配置时,应 ...

随机推荐

  1. reqiurejs学习

    RequireJS 优化 Web 应用: http://www.ibm.com/developerworks/cn/web/1209_shiwei_requirejs/ 1.模块之间的依赖关系 2.如 ...

  2. cnblogs 主题 summerGarden redesign

    Intro cnblogs 的 summerGarden 主题是一个宽屏版的,而且设计虽然很Qzone风格,不过我个人喜欢「简单,扁平」的设计风格,所以就修改了一下样式. before after r ...

  3. master page

    <?xml version="1.0"?><configuration>  <system.web>    <pages clientID ...

  4. MVC模型的理解

  5. JSON 格式说明

    一维json { "sn" : "CS20160918095444121640", "suitstypes_id" : "47&q ...

  6. php 全角半角转换

    <?phpheader("Content-type: text/html; charset=utf-8");// 第一个参数:传入要转换的字符串// 第二个参数:取0,半角转 ...

  7. find函数

    Python find() 方法检测字符串中是否包含子字符串 str ,如果指定 beg(开始) 和 end(结束) 范围,则检查是否包含在指定范围内,如果包含子字符串返回开始的索引值,否则返回-1. ...

  8. GATT两个角色 服务器与客户端

    两个设备应用数据的通信是通过协议栈的GATT层实现的. 从GATT角度来看,当两个设备建立连接后,他们处于以下两种角色之一: GATT服务器: 它是为GATT客户端提供数据服务的设备 GATT客户端: ...

  9. Oracle使用经验总结

    oracle数据库是一种大型数据库系统,一般应用于商业,政府部门,它的功能很强大,能够处理大批量的数据,在网络方面也用的非常多.Oracle数据库管理系统是一个以关系型和面向对象为中心管理数据的数据库 ...

  10. hdu 4358 Boring counting dfs序+莫队+离散化

    Boring counting Time Limit: 6000/3000 MS (Java/Others)    Memory Limit: 98304/98304 K (Java/Others) ...