海运的博客

Nagios之web界面管理工具Nagiosql安装

发布时间:June 4, 2012 // 分类:Nagios // No Comments

NagiosQL是一个基于Web界面的Nagios配置管理工具,极大方便Nagios的使用、管理。
下载安装Nagiosql:

cd /var/www/html/
wget http://nchc.dl.sourceforge.net/project/nagiosql/nagiosql/NagiosQL%203.2.0/nagiosql_320.tar.gz
tar zxvf nagiosql_320.tar.gz 
mv nagiosql32/ nagiosql
chmod -R 777 /var/www/html/nagiosql/config/

目录权限配置:

mkdir -p /etc/nagiosql/backup/hosts
mkdir -p /etc/nagiosql/backup/services
mkdir -p /etc/nagiosql/hosts
mkdir -p /etc/nagiosql/services
chown -R nagios:apache /etc/nagiosql/
chown -R nagios:apache /usr/local/nagios/etc/
chown nagios:apache /usr/local/nagios/bin/nagios
chown nagios:apache /usr/local/nagios/var/rw/nagios.cmd
chown -R nagios:apache /usr/local/nagios/var/spool/checkresults

编辑nagios配置文件,注释以cfg开头的配置,并添加:

vim /usr/local/nagios/etc/nagios.cfg
## Timeperiods
cfg_file=/etc/nagiosql/timeperiods.cfg
## Commands
cfg_file=/etc/nagiosql/commands.cfg
## Contacts
cfg_file=/etc/nagiosql/contacts.cfg
cfg_file=/etc/nagiosql/contactgroups.cfg
cfg_file=/etc/nagiosql/contacttemplates.cfg
## Hosts
cfg_dir=/etc/nagiosql/hosts
cfg_file=/etc/nagiosql/hosttemplates.cfg
cfg_file=/etc/nagiosql/hostgroups.cfg
cfg_file=/etc/nagiosql/hostextinfo.cfg
cfg_file=/etc/nagiosql/hostescalations.cfg
cfg_file=/etc/nagiosql/hostdependencies.cfg
## Services
cfg_dir=/etc/nagiosql/services
cfg_file=/etc/nagiosql/servicetemplates.cfg
cfg_file=/etc/nagiosql/servicegroups.cfg
cfg_file=/etc/nagiosql/serviceextinfo.cfg
cfg_file=/etc/nagiosql/serviceescalations.cfg
cfg_file=/etc/nagiosql/servicedependencies.cfg

访问www.haiyun.me/nagiosql/install进入安装界面,可选中文语言:
nagiosql安装.png
当前环境检测,全绿为通过:
nagiosql安装环境检测.png
填写配置信息:
nagiosql安装数据库配置.png
不出意外会提示安装成功,删除安装文件,进入登录界面:
nagiosql登录界面.png
配置nagios相关目录,界面——管理——Config targets——localhost——编辑:
nagiosql目标配置.png
导入nagios配置:
nagiosql导入配置.png
写入数据:
nagiosql写入配置.png

Nagios配置pnp4nagios支持图表显示

发布时间:June 3, 2012 // 分类:Nagios // No Comments

Nagios配合pnp4nagios可实现类似Cacti的图表显示,便于管理和分析服务器运行状况。
Nagios安装请参考:https://www.haiyun.me/archives/centos-install-nagios.html
安装rrdtool,需安装epel源

#https://www.haiyun.me
yum install rrdtools perl-rrdtool perl-Time-HiRes

安装php4nagios:

wget http://nchc.dl.sourceforge.net/project/pnp4nagios/PNP-0.6/pnp4nagios-0.6.17.tar.gz
tar zxvf pnp4nagios-0.6.17.tar.gz 
cd pnp4nagios-0.6.17
./configure --with-nagios-user=nagios --with-nagios-group=nagios
make all
make install
make install-webconf
make install-config
make install-init
#make fullinstall #相当于上面3个指令

配置php4nagios:

#https://www.haiyun.me
cd /usr/local/pnp4nagios/etc/
mv misccommands.cfg-sample misccommands.cfg
mv rra.cfg-sample rra.cfg
mv nagios.cfg-sample nagios.cfg
cd pages/
mv web_traffic.cfg-sample web_traffic.cfg
cd ../check_commands/
mv check_all_local_disks.cfg-sample check_all_local_disks.cfg
mv check_nrpe.cfg-sample check_nrpe.cfg
mv check_nwstat.cfg-sample check_nwstat.cfg
/etc/init.d/npcd start
chkconfig npcd on

配置Nagios数据输出接口:

vim /usr/local/nagios/etc/nagios.cfg 
process_performance_data=1 #默认为0,修改为1
host_perfdata_command=process-host-perfdata #注释开头#号
service_perfdata_command=process-service-perfdata #注释开头#号

替换commands.cfg命令process-service-perfdata为以下内容:

vim /usr/local/nagios/etc/objects/commands.cfg 
# 'process-host-perfdata' command definition
define command{
        command_name    process-host-perfdata
        command_line    /usr/local/pnp4nagios/libexec/process_perfdata.pl -d HOSTPERFDATA 
        }
# 'process-service-perfdata' command definition
define command{
        command_name    process-service-perfdata
        command_line    /usr/local/pnp4nagios/libexec/process_perfdata.pl
        }                              

在模板配置文件中添加图表图标模板:

#https://www.haiyun.me
 vim /usr/local/nagios/etc/objects/templates.cfg 
define host {
name          host-pnp
action_url    /pnp4nagios/index.php/graph?host=$HOSTNAME$&srv=_HOST_' class='tips' rel='/pnp4nagios/index.php/popup?host=$HOSTNAME$&srv=_HOST_
register   0
}
define service {
name         service-pnp
action_url   /pnp4nagios/index.php/graph?host=$HOSTNAME$&srv=$SERVICEDESC$' class='tips' rel='/pnp4nagios/index.php/popup?host=$HOSTNAME$&srv=$SERVICEDESC$
register   0
}

复制鼠标悬停图标显示文件:

cp /usr/local/pnp4nagios/contrib/ssi/* /usr/local/nagios/share/ssi/ 

在监控主机或服务中调用图表模板:

define host{
        use                     linux-server,host-pnp                             
        host_name               localhost
        alias                   localhost
        address                 127.0.0.1
        }
define service{
        use                             local-service,service-pnp
        host_name                       localhost
        service_description             PING
    check_command            check_ping!100.0,20%!500.0,60%
        }
define service{
        use                             local-service,service-pnp
        host_name                       localhost
        service_description             Root Partition
    check_command            check_local_disk!20%!10%!/
        }

重启nagios,访问nagios界面即可看到图表小图标:
nagios图表图标.png
点击图标会显示pnp4nagios测试页面:
pnp4nagios测试页面.png
全是绿色代表配置正常,然后移除或修改install.php文件:

rm -rf /usr/local/pnp4nagios/share/install.php

再次点击图标就会显示当前监控服务由pnp4nagios生成的图表了:
nagios图表pnp4nagios.png

Linux/Centos安装nagios监控服务器

发布时间:June 3, 2012 // 分类:Nagios // No Comments

CentOS安装LAMP及编译环境:

yum -y install httpd httpd-devel mysql mysql-server mysql-devel php php-devel php-common php-gd \
php-mysql php-mbstring php-mcrypt php-xml php-snmp gcc make automake autoconf
/etc/init.d/httpd start
/etc/init.d/mysqld start
/usr/bin/mysqladmin -u root password "password"
chkconfig httpd on
chkconfig mysqld on

安装Nagios

#https://www.haiyun.me
useradd nagios
groupadd nagcmd
usermod -G nagcmd nagios
usermod -G nagcmd apache
cd /usr/local/src/
#安装主程序
wget http://prdownloads.sourceforge.net/sourceforge/nagios/nagios-3.4.1.tar.gz
tar zxvf nagios-3.4.1.tar.gz 
cd nagios
./configure --with-command-group=nagcmd --prefix=/usr/local/nagios --with-nagios-user=nagios --with-nagios-group=nagios 
make all
make install
#安装主程序
make install-init
#安装init管理脚本
make install-config
#安装示例配置文件
make install-commandmode
#配置目录权限
make install-webconf
#安装Apache配置文件
#make install-exfoliation
#安装简洁白色主题,此为默认
make install-classicui
安装经典黑色主题
cd ../
#安装插件
wget http://prdownloads.sourceforge.net/sourceforge/nagiosplug/nagios-plugins-1.4.15.tar.gz
tar zxvf nagios-plugins-1.4.15.tar.gz
cd nagios-plugins
./configure --with-nagios-user=nagios --with-nagios-group=nagios --prefix=/usr/local/nagios
make
make install
htpasswd -c /usr/local/nagios/etc/htpasswd.users nagiosadmin
#生成nagiosadmin验证密码,用于web界面验证。
/etc/init.d/httpd restart
/etc/init.d/nagios start
chkconfig nagios on
setsebool -P httpd_disable_trans 1
#关闭selinux对httpd的防护,不然会出现权限问题

安装完成,访问www.haiyun.me/nagios即可。
nagios管理界面.png

Centos下Nginx环境安装Nagios

发布时间:June 1, 2012 // 分类:Nagios // No Comments

首先Nginx需添加perl-fastcgi支持,请参考:https://www.haiyun.me/archives/nginx-perl-fastcgi.html
安装Nagios

#https://www.haiyun.me
useradd nagios
groupadd nagcmd
usermod -G nagcmd nagios
usermod -G nagcmd www
cd /usr/local/src/
wget http://prdownloads.sourceforge.net/sourceforge/nagios/nagios-3.4.1.tar.gz
tar zxvf nagios-3.4.1.tar.gz 
cd nagios
./configure --with-command-group=nagcmd --prefix=/usr/local/nagios --with-nagios-user=nagios --with-nagios-group=nagios 
make all
make install
make install-init
make install-config
make install-commandmode
cd ../
wget http://prdownloads.sourceforge.net/sourceforge/nagiosplug/nagios-plugins-1.4.15.tar.gz
tar zxvf nagios-plugins-1.4.15.tar.gz
cd nagios-plugins
./configure --with-nagios-user=nagios --with-nagios-group=nagios --prefix=/usr/local/nagios
make
make install
ln -s  /usr/local/nagios/share/  /home/wwwroot/nagios.www.haiyun.me
/etc/init.d/nagios start

Nginx配置:

server
    {
        listen       80;
        server_name nagios.www.haiyun.me;
        root  /home/wwwroot/nagios.www.haiyun.me;
                index index.php;
 
                auth_basic "Login";
                auth_basic_user_file /home/wwwroot/nagios.www.haiyun.me/passwd;
                location ~ .*\.cgi?$
                {
                root /usr/local/nagios/sbin;
                rewrite ^/nagios/cgi-bin/(.*)\.cgi /$1.cgi break;
                fastcgi_pass  unix:/tmp/perl-fastcgi.sock;
                fastcgi_index index.cgi;
                fastcgi_param   SCRIPT_FILENAME  $document_root$fastcgi_script_name;  
                include         fastcgi_params;  
                }
                location ~ .*\.(php|php5)?$
                        {
                                fastcgi_pass  unix:/tmp/php-cgi.sock;
                                fastcgi_index index.php;
                                include fcgi.conf;
                        }
                access_log none;
}

配置Nginx验证:

perl -e 'print crypt($ARGV[0], "pwdsalt")' passwd;echo
#生成passwd加密字符,将结果以user:passwd的方式填入/home/wwwroot/nagios.www.haiyun.me/passwd
分类
最新文章
最近回复
  • Jimmy: 方法一 nghtp3步骤需要改成如下才能编译成功: git clone https://git...
  • 海运: 地址格式和udpxy一样,udpxy和msd_lite能用这个就能用。
  • 1: 怎么用 编译后的程序在家里路由器内任意一台设备上运行就可以吗?比如笔记本电脑 m参数是笔记本的...
  • 孤狼: ups_status_set: seems that UPS [BK650M2-CH] is ...
  • 孤狼: 擦。。。。apcupsd会失联 nut在冲到到100的时候会ONBATT进入关机状态,我想想办...
  • 海运: 网络,找到相应的url编辑重发请求,firefox有此功能,其它未知。
  • knetxp: 用浏览器F12网络拦截或监听后编辑重发请求,修改url中的set为set_super,将POS...
  • Albert: 啊啊啊啊啊啊啊啊啊 我太激动了,终于好了英文区搜索了半天,翻遍了 pve 论坛没找到好方法,博...
  • jiangker: good, very helpful to me
  • fengfeng: N1 armbian 能有编译下内核吗。。我要开启can 不懂怎么操作