

Nagios是一个用来监控主机、服务和网络的开放源码软件,很多大的公司或组织都在使用它。
参考资料: http://yahoon.blog.51cto.com/13184/41300 http://bbs.linuxtone.org/thread-1281-1-1.html http://bbs.linuxtone.org/thread-2269-1-1.html nagios官方文档 http://www.nagios.org/docs/ nagios中文文档 http://www.itnms.net/docs/nagios/cn/build/html/ nagios中文相关讨论区 http://bbs.linuxtone.org/forum-20-1.html http://www.itnms.net/discuz/forumdisplay.php?fid=10&pageD1
nagios下载地址: http://www.nagios.org/download/
这里选用 nagios-3.0.6.tar.gz nagios-plugins-1.4.13.tar.gz nrpe2.12 wget http://downloads.sourceforge.net/sourceforge/nagios/nagios-3.0.6.tar.gz?use_mirror=nchc wget http://downloads.sourceforge.net/sourceforge/nagiosplug/nagios-plugins-1.4.13.tar.gz?use_mirror=nchc wget http://nchc.dl.sourceforge.net/sourceforge/nagios/nrpe-2.12.tar.gz
安装nagios 系统为as4
1.创建用户和用户组
#创建用户和用户组 useradd -m nagios
-s /sbin/nologin 禁止登录,运行命令时可能会有限制,也可以不加本限制
groupadd nagcmd usermod -G nagcmd nagios #将nginx或apache运行用户加入组中 usermod -G nagcmd nobody
2.安装nagios
tar zxvf nagios-3.0.6.tar.gz cd nagios-3.0.6 #gd默认安装路径 #./configure –with-command-group=nagcmd –prefix=/usr/local/nagios –with-gd-lib=/usr/lib64/ –with-gd-inc=/usr/include
./configure –with-command-group=nagcmd –prefix=/usr/local/nagios –with-gd-lib=/usr/local/gd2/lib –with-gd-inc=/usr/local/gd2/include #以下为编译结果
Configuration summary for nagios 3.0.6 12-01-2008 :
General Options:
Nagios executable: nagios Nagios user/group: nagios,nagios Command user/group: nagios,nagcmd Embedded Perl: no Event Broker: yes Install ${prefix}: /usr/local/nagios Lock file: ${prefix}/var/nagios.lock Check result directory: ${prefix}/var/spool/checkresults Init directory: /etc/rc.d/init.d Apache conf.d directory: /etc/httpd/conf.d Mail program: /bin/mail Host OS: linux-gnu
Web Interface Options:
HTML URL: http://localhost/nagios/ CGI URL: http://localhost/nagios/cgi-bin/ Traceroute (used by WAP): /bin/traceroute
Review the options above for accuracy. If they look okay, type ‘make all’ to compile the main program and CGIs.
make all make install make install-init make install-config make install-commandmode
3.安装nagios-plugins
tar zxvf nagios-plugins-1.4.13.tar.gz cd nagios-plugins-1.4.13 ./configure –with-nagios-user=nagios –with-nagios-group=nagios –prefix=/usr/local/nagios
checking for ping6… /bin/ping6 checking for ICMP ping syntax… 到这里就停住了,应该是ipv6问题,加上–with-ping-command参数编译
参考下面地址: http://www.linuxquestions.org/questions/linux-software-2/.configure-script-hangs-at-checking-for-icmp-ping-syntax…l-499235/ http://bbs.bitscn.com/195707 ./configure –with-nagios-user=nagios –with-nagios-group=nagios –prefix=/usr/local/nagios –with-ping-command=”/bin/ping” –enable-perl-modules –with-mysql=/opt/mysql make
–with-apt-get-command: –with-ping6-command: /bin/ping6 -n -U -w %d -c %d %s –with-ping-command: /bin/ping –with-ipv6: yes –with-mysql: /opt/mysql/bin/mysql_config –with-openssl: yes –with-gnutls: no –enable-extra-opts: no –with-perl: /usr/bin/perl –enable-perl-modules: yes –with-cgiurl: /nagios/cgi-bin –with-trusted-path: /bin:/sbin:/usr/bin:/usr/sbin如果没有mysql关联,libexec目录不会产生check_mysql,utils.pm等文件
make install #查看播件文件是否已安装在这个目录 ls /usr/local/nagios/libexec 4.配置nginx的web口 如果使用apache可以在安装nagios时使用make install-webconf,不需要下面的配置 我的web server是nginx ,编辑nginx.conf location ~ \.cgi$ { root /usr/local/nagios/sbin; allow 192.168.54.83; #充许访问的客户端ip deny all; auth_basic “Restricted”; auth_basic_user_file nagios; rewrite ^/nagios/cgi-bin/(.*)\.cgi /$1.cgi break; fastcgi_index index.cgi; fastcgi_pass unix:/dev/shm/perl_cgi-dispatch.sock; fastcgi_param HTTP_ACCEPT_ENCODING gzip,deflate; fastcgi_param SCRIPT_FILENAME /usr/local/nagios/sbin$fastcgi_script_name; include fcgi.conf; } location /nagios/ { alias /usr/local/nagios/share/; allow 192.168.54.83; deny all; auth_basic “Restricted”; auth_basic_user_file nagios; } 5.使用apache的htpasswd生成用户和口令 /opt/apache/bin/htpasswd -c /opt/nginx/conf/nagios nagiosadmin 6.修改nagios配置文件 修改etc/cgi.cfg中的用户为nagiosadmin authorized_for_system_information=nagiosadmin authorized_for_configuration_information=nagiosadmin authorized_for_system_commands=nagiosadmin//多个用户之间用逗号隔开 authorized_for_all_services=nagiosadmin authorized_for_all_hosts=nagiosadmin authorized_for_all_service_commands=nagiosadmin authorized_for_all_host_commands=nagiosadmin 测试时可以将use_authentication=0 修改etc/objects/contacts.cfg联系人 define contact{ contact_name nagiosadmin ; Short name of user use generic-contact ; Inherit default values from generic-contact template (defined above) alias Nagios Admin ; Full name of user email nagios@localhost ; <<***** CHANGE THIS TO YOUR EMAIL ADDRESS ****** } 修改本机配置etc/objects/localhost.cfg 上传配置文件 检查配置文件 /usr/local/nagios/bin/nagios -v /usr/local/nagios/etc/nagios.cfg 7.启动nagios #启动 /etc/rc.d/init.d/nagios start #手工启动 /usr/local/nagios/bin/nagios -d /usr/local/nagios/etc/nagios.cfg #重启 /etc/rc.d/init.d/nagios reload 8.reload nginx server /opt/nginx/sbin/nginx -t kill -HUP `cat /opt/nginx/logs/nginx.pid` nagios安装完成 访问http://localhost/nagios/就可以看到了 安装内存监控插件 wget “http://www.nagiosexchange.org/cgi-bin/jump.cgi?ID=1789&view=File1;d=1” mv jump.cgi\?ID\=1789\&view\=File1\;d\=1 check_mem.pl.gz gunzip check_mem.pl.gz mv check_mem.pl /usr/local/nagios/libexec/check_mem chown nagios:nagios check_mem chmod 0755 check_mem ./check_mem -w 95,60 -c 120,80 #测试结果 OK: Memory Usage (W> 95, C> 120): 83% Swap Usage (W> 60, C> 80): 3%|MemUsed=83%;95;120 SwapUsed=3%;60;80 commands.cfg增加 define command{ command_name check_mem command_line $USER1$/check_mem -w $ARG1$ -c $ARG2$ } 监控对像文件localhost.cfg添加 define service{ use local-service ; Name of service template to use host_name localhost service_description memory check_command check_mem!110,50!150,80 notifications_enabled 0 } 重新加载文件 /etc/init.d/nagios reload 访问http://localhost/nagios/ 输入口令后就可以看到界面了
- libgd
- libgd-devel
- libpng
- libpng-devel
- libjpeg
- libjpeg-devel
- zlib
- zlib-devel
你好。
在进行nginx配置是11行的配置是什么意思?
11.fastcgi_pass unix:/dev/shm/perl_cgi-dispatch.sock;
我的电脑上面没有:/dev/shm/perl_cgi-dispatch.sock文件。
我用的是redhat Enterprise 4.4
是不是需要安装什么东西了?
我的web server是nginx,apache不需要这步
这个是fastcgi的UNIX sockets 路径
如果是IP sockets那可能是”127.0.0.1:8999″
取决于你的fastcgi配置
您好
请教个问题 我也是nginx+nagios 用的是perl fastcgi
状况是 nagios 能够访问 但是web访问超级慢 打开一个页面大概需要1分钟
我的fastcgi 是wiki 里下的 地址为 http://wiki.nginx.org//NginxSimpleCGI
解答下
我的nginx配置可以参见这里
http://blog.c1gstudio.com/archives/152