温馨提示×

温馨提示×

您好,登录后才能下订单哦!

密码登录×
登录注册×
其他方式登录
点击 登录注册 即表示同意《亿速云用户服务条款》

rhel下安装配置nagios和cacti

发布时间:2020-07-14 22:33:10 来源:网络 阅读:341 作者:yincg 栏目:移动开发

 nagios安装指南
环境:rhel6.2 
软件:nagios-3.3.1.tar.gz


1、最小化安装系统
2、安装缺失插件
yum install -y httpd http-devel mysql mysql-devel mysql-server gcc glibc glibc-common gd gd-devel php  make php-devel php-gd ntp make  net-snmp net-snmp-devel 
3、创建nagios用户并创建nagcmd组,允许用户在web上执行命令.
useradd -m nagios  
  


groupadd nagcmd  
usermod -a -G nagcmd nagios  
usermod -a -G nagcmd apache 
3、编译安装nagios
./configure  --with-gd-lib=/usr/local/lib  --with-command-group=nagcmd  --prefix=/var/www/html/nagios
make all 
make install
make install-init  
make install-config  
make install-commandmode
4、修改发信邮箱、修改apache配置文件
vi  /var/www/html/nagios/etc/objects/contacts.cfg
nagios-3.2.3/sample-config/httpd.conf中的片段拷贝到/etc/httpd/conf/httpd.conf中
5、添加登录认证文件
htpasswd -c  /var/www/html//nagios/etc/htpasswd.users nagiosadmin  
6、安装nagios-plugins插件
tar -zvxf nagios-plugins-1.4.15.tar.gz 
cd nagios-plugins-1.4.15 
./configure --with-nagios-user=nagios --with-nagios-group=nagios  --prefix=/var/www/html/nagios
make && make install
7、nagios 测试
chown nagios:nagios /var/www/html/nagios/ -R 
/etc/init.d/httpd restart  
chkconfig httpd on   
/etc/init.d/nagios start 
8、安装nrpe
tar xzvf nrpe-2.12.tar.gz  
cd nrpe-2.12  


./configure  
make all    
make install-plugin  
make install-daemon  
make install-daemon-config  
make install-xinetd  
9、修改nrpe配置
编辑/etc/xinetd.d/nrpe 
only_from = 127.0.0.1 #这里只能加一个IP
编辑/etc/services,在最后一行加上 
nrpe 5666/tcp # NRPE


在监控主机上编辑 /var/www/html/nagios/etc/objects/commands.cfg,加入下面的command。
[plain] view plaincopy
define command{  
        command_name  check_nrpe  
        command_line  $USER1$/check_nrpe -H $HOSTADDRESS$ -c $ARG1$  
}  
10、配置snmp服务
yum install net-snmp net-snmp-devel net-snmp-libs net-snmp-utils
chkconfig –level 35 snmpd on
service snmpd start
vi /etc/snmp/snmpd.conf
修改com2sec notConfigUser  default       public
为:com2sec notConfigUser  127.0.0.1       public
修改access  notConfigGroup ""      any       noauth    exact  systemview none none
为access  notConfigGroup ""      any       noauth    exact  all  none none
并启用view all    included  .1                               80此行;


11、解压移动cacti
tar xvf cacti-0.8.7g.tar.gz
mv cacti-0.8.7g /var/www/html/cacti


12、安装rrdtool
tar xzf rrdtool-1.4.5.tar.gz   ;
cd rrdtool-1.4.5  ; 
./configure –-prefix=/usr/local/rrdtool/  ;
make  &&make install

ln -s /usr/local/rrdtool/bin/* /usr/local/bin/

或者执行:

yum install rrdtool* 



13、配置cacti数据库
mysql -uroot –p ##输入你的密码进入数据库,然后创建数据库:
create database cacti;   ## 创建库
grant all on cacti.* to  cacti@’localhost’   identified by  ’123456′; ##创建用户并授权
flush privileges; ##刷新权限
mysql配置完毕后,把cacti数据导入cacti数据库里面:
mysql -ucacti  -p cacti </var/www/html/cacti/cacti.sql
回车输入cacti用户的密码123456即可。
需要在修改/var/www/html/cacti/include/config.php ;

$database_type = "mysql";
$database_default = "cacti";
$database_hostname = "localhost";
$database_username = "cacti";
$database_password = "123456";
$database_port = "3306";
改成相应的数据即可;


配置完mysql后,我们需要设置cacti rra、log 目录的权限,这里设置为777 :
chmod -R  777  /var/www/html/cacti/rra/
chmod -R  777  /var/www/html/cacti/log/


为了绘制图表,需要手动添加以下任务
* /5  * * * * php /var/www/html/cacti/poller.php
14、浏览器中打开:
http://localhost:/cacti
执行install安装即可;

向AI问一下细节

免责声明:本站发布的内容(图片、视频和文字)以原创、转载和分享为主,文章观点不代表本网站立场,如果涉及侵权请联系站长邮箱:is@yisu.com进行举报,并提供相关证据,一经查实,将立刻删除涉嫌侵权内容。

AI