penguin23
作者penguin23·2017-09-09 22:33
系统运维工程师·广州佳杰科技有限公司

nagios install

字数 6477阅读 1475评论 0赞 5

编译apache
./configure --prefix=/usr/local/apache
make
make install

编译libxml2
./configure make && make install

编译php(结合apache)
./configure --prefix=/usr/local/php --with-apxs2=/usr/local/apache/bin/apxs
make
make install

测试页面(确认防火墙可通):
<?php
phpinfo();
?>
(apache需要往页面目录中放一个图像文件)

编译nagios:
./configure --with-command-group=nagcmd
make all == cd ./base && make
make install-init
chkconfig --add nagios
chkconfig --levels 345 nagios on
passwd nagios(系统用户)
./htpasswd -c /usr/local/nagios/etc/.htpasswd.users nagios

修改nagios.cfg(主配置文件)
cfg_file=/usr/local/nagios/etc/commands.cfg
cfg_file=/usr/local/nagios/etc/contacts.cfg
cfg_file=/usr/local/nagios/etc/contactgroups.cfg
cfg_file=/usr/local/nagios/etc/hosts.cfg
cfg_file=/usr/local/nagios/etc/hostgroups.cfg
cfg_file=/usr/local/nagios/etc/services.cfg
cfg_file=/usr/local/nagios/etc/timeperiods.cfg
cfg_file=/usr/local/nagios/etc/templates.cfg
cfg_file=/usr/local/nagios/etc/escalations.cfg

编译nagios-plugins
[root@nagios nagios-plugins-1.4.15]# ./configure --with-nagios-user=nagios --with-nagios-group=nagios
(./configure --with-nagios-user=nagios --with-nagios-group=nagios --prefix=/usr/local/nagios --with-mysql=/usr/local/mysql)

[root@nagios nagios-plugins-1.4.15]#make && make install

为nagios用户赋权限(这样才能看到监控信息)
vi /usr/local/nagios/etc/cgi.cfg
authorized_for_system_information=nagios
authorized_for_configuration_information=nagios
authorized_for_system_commands=nagios
authorized_for_all_services=nagios
authorized_for_all_hosts=nagios
authorized_for_all_service_commands=nagios
authorized_for_all_host_commands=nagios

编译安装nrpe
在nagios监控机,安装nrpe
[root@nagios nrpe-2.12]# ./configure --prefix=/usr/local/nagios
[root@nagios nrpe-2.12]# make all
[root@nagios nrpe-2.12]# make install-plugin
cd ./src/ && make install-plugin
make[1]: Entering directory `/soft/nrpe-2.12/src'
/usr/bin/install -c -m 775 -o nagios -g nagios -d /usr/local/nagios/libexec
/usr/bin/install -c -m 775 -o nagios -g nagios check_nrpe /usr/local/nagios/libexec
make[1]: Leaving directory `/soft/nrpe-2.12/src'

在nrpe01被监控机,安装nagios-plugin、nrpe。
安装mysql应用
yum install mysql
yum install mysql-server

groupadd nagios
useradd -g nagios -d /usr/local/nagios -s /sbin/nologin nagios
./configure --with-nagios-user=nagios --with-nagios-group=nagios --prefix=/usr/local/nagios --with-ping-command="/bin/ping" --with-mysql=/opt/mysql
make
make install

./configure --prefix=/usr/local/nagios
make all
make install-plugin
make install-daemon
make install-daemon-config
chown -R nagios:nagios /usr/local/nagios

echo 'nrpe:192.168.0.10' >> /etc/hosts.allow
[root@nrpe01 etc]# /usr/local/nagios/bin/nrpe -c /usr/local/nagios/etc/nrpe.cfg -d

[root@nagios etc]# /usr/local/nagios/libexec/check_nrpe -H 192.168.0.11
NRPE v2.12

添加check_mysql插件
./configure --with-nagios-user=nagios --with-nagios-group=nagios --prefix=/usr/local/nagios --with-perl --with-statefiles-dir=/usr/local/nagios/libexec
make
make install
./check_mysql_health -hostname 192.168.0.11 -port 3306 -username root -password 1q2w3e -mode threadcache-hitrate

CRITICAL - cannot connect to information_schema. Can't locate DBI.pm in @INC (@INC contains: . /usr/lib/perl5/site_perl/5.8.8/i386-linux-thread-multi /usr/lib/perl5/site_perl/5.8.8 /usr/lib/perl5/site_perl /usr/lib/perl5/vendor_perl/5.8.8/i386-linux-thread-multi /usr/lib/perl5/vendor_perl/5.8.8 /usr/lib/perl5/vendor_perl /usr/lib/perl5/5.8.8/i386-linux-thread-multi /usr/lib/perl5/5.8.8) at ./check_mysql_health line 1500.

check_mysql_health --hostname 192.168.0.11 --username root --password 1q2w3e -mode connection-time

define service{
hostgroup_name web1,web2
service_description PING
max_check_attempts 3
normal_check_interval 3
retry_check_interval 2
notification_interval 5
check_period 24x7
notification_period 24x7
notification_options w,u,c,r
contact_groups nagiosadmingroup
check_command check_ping!100.0,20%!500.0,60%
}
define service{
hostgroup_name web1,web2
service_description Check Partition
max_check_attempts 3
normal_check_interval 3
retry_check_interval 2
notification_interval 5
check_period 24x7
notification_period 24x7
notification_options w,u,c,r
contact_groups nagiosadmingroup
check_command check_nrpe!check_df
}
define service{
hostgroup_name web1,web2
service_description Current Users
max_check_attempts 3
normal_check_interval 3
retry_check_interval 2
notification_interval 5
check_period 24x7
notification_period 24x7
notification_options w,u,c,r
contact_groups nagiosadmingroup
check_command check_nrpe!check_users
}
define service{
hostgroup_name web1,web2
service_description Total Processes
max_check_attempts 3
normal_check_interval 3
retry_check_interval 2
notification_interval 5
check_period 24x7
notification_period 24x7
notification_options w,u,c,r
contact_groups nagiosadmingroup
check_command check_nrpe!check_total_procs

Linux host definition template - This is NOT a real host, just a template!

define host{

    name                            linux-server   
    use                             generic-host    #又引用generic-host参数模板
    check_period                    24x7            
    check_interval                  5              
    retry_interval                  1               
    max_check_attempts              10              
    check_command                   check-host-alive 
    notification_period             workhours       
                                                    
    notification_interval           120             
    notification_options            d,u,r
    contact_groups                  admins          
    register                        0               
    }

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               nagios
    alias                   nagios-server
    address                 127.0.0.1
    }

[root@nagios /]# wget http://www.it-adv.net/fetion/downng/fetion20090406003-linux.tar.gz

   [root@nagios /]# tar zxvf fetion20090406003-linux.tar.gz
   [root@nagios /]# mkdir /usr/local/fetion
      [root@nagios /]# cp -R install/* /usr/local/fetion

[root@nagios /]# /usr/local/fetion/fetion --mobile=15915968917 --pwd=penguin00273 --to=15915776153 --msg-utf8=test

如果觉得我的文章对您有用,请点赞。您的支持将鼓励我继续创作!

5

添加新评论0 条评论

Ctrl+Enter 发表

作者其他文章

X社区推广