nagios+nginx+php配置监控平台
Nagios是一款非常流程的监控系统,不但可以监控系统的基本情况,也可以监控应用的情况,我假设你已经安装了nginx和php。并且php也安装了gd支持。
本文中涉及的文件都已经在附件中了。
nagios依赖php和perl,所以先装下perl环境
1.安装fcgi模块
tar -zxvf FCGI-0.73.tar.gzcd FCGI-0.73perl Makefile.PLmakemake install
tar -zxvf FCGI-ProcManager-0.19.tar.gzcd FCGI-ProcManager-0.19perl Makefile.PLmakemake install
tar -zxvf IO-1.25.tar.gzcd IO-1.25perl Makefile.PLmakemake install
tar -zxvf IO-All-0.41.tar.gzcd IO-All-0.41perl Makefile.PLmakemake install
unzip perl-fcgi.zip
chmod 755 /etc/nginx/conf/perl-fcgi.pl
vi /etc/nginx/conf/start_perl_cgi.sh#!/bin/bash#set -x#此处需要根据实际情况进行修改dir=/etc/nginx/ stop (){#pkill -f $dir/perl-fcgi.plkill $(cat $dir/logs/perl-fcgi.pid)rm $dir/logs/perl-fcgi.pid 2>/dev/nullrm $dir/logs/perl-fcgi.sock 2>/dev/nullecho "stop perl-fcgi done"} start (){rm $dir/now_start_perl_fcgi.sh 2>/dev/null chown nginx.nginx $dir/logsecho "$dir/perl-fcgi.pl -l $dir/logs/perl-fcgi.log -pid $dir/logs/perl-fcgi.pid -S $dir/logs/perl-fcgi.sock" >>$dir/now_start_perl_fcgi.sh chown nginx.nginx $dir/now_start_perl_fcgi.shchmod u+x $dir/now_start_perl_fcgi.sh sudo -u nginx $dir/now_start_perl_fcgi.shecho "start perl-fcgi done"} case $1 instop)stop;;start)start;;restart)stopstart;;esac
chmod 755 /etc/nginx/conf/start_perl_cgi.sh
/etc/nginx/conf/start_perl_cgi.sh start
/usr/sbin/useradd -m -s /sbin/nologin nagios
groupadd nagcmdusermod -a -G nagcmd nagiosusermod -a -G nagcmd nginx
tar zxvf nagios-3.2.3.tar.gzcd nagios-3.2.3./configure --with-command-group=nagcmdmakemake allmake installmake install-initmake install-configmake install-commandmode
htpasswd -c /usr/local/nagios/etc/nagiospasswd frady
tar zxvf nagios-plugins-1.4.15.tar.gzcd nagios-plugins-1.4.15./configure --with-nagios-user=nagios --with-nagios-group=nagiosmakemake install 验证Nagios插件是否正确安装
tar zxvf nrpe-2.12.tar.gzcd nrpe-2.12./configuremake allmake install-pluginmake install-daemonmake install-daemon-config
server{listen 80;server_name nagios.frady.info;root /usr/local/nagios/share/;#设置网站根目录auth_basic " 119 Nagios Access";auth_basic_user_file /usr/local/nagios/etc/nagiospasswd;location / {index index.Html index.html index.htm index.php;}location ~ \.php$ {root /usr/local/nagios/share;#include fastcgi_params;#fastcgi.conffastcgi_pass 127.0.0.1:9000;fastcgi_index index.php;include fastcgi.conf;#fastcgi_param SCRIPT_FILENAME /web/mantis$fastcgi_script_name;}location ~ .*\.(cgi|pl)?${gzip off;root /usr/local/nagios/sbin;rewrite ^/nagios/cgi-bin/(.*)\.cgi /$1.cgi break;fastcgi_pass unix:/etc/nginx/logs/perl-fcgi.sock;fastcgi_param SCRIPT_FILENAME /usr/local/nagios/sbin$fastcgi_script_name;fastcgi_index index.cgi;fastcgi_read_timeout 60;fastcgi_param REMOTE_USER $remote_user;include fastcgi.conf;auth_basic "Nagios Access";auth_basic_user_file /usr/local/nagios/etc/nagiospasswd;fastcgi_param REMOTE_USER $remote_user;}location /nagios{alias /usr/local/nagios/share;auth_basic "Nagios Access";auth_basic_user_file /usr/local/nagios/etc/nagiospasswd;}location ~ .*\.(gif|jpg|jpeg|png|bmp|swf)$ { rewrite ^/nagios/images/(.*) /images/$1 break; expires 30d; } location ~ .*\.(js|css)?$ { rewrite ^/nagios/stylesheets/(.*) /stylesheets/$1 break;expires 1h; } }