因个人站点所在服务器安装了nginx,并没有安装apache,所以想在nginx上实现nagios迁移,那就要实现nginx 下的perl支持,先下载软件
- wget http://prdownloads.sourceforge.net/sourceforge/nagios/nagios-3.2.0.tar.gz
- wget http://prdownloads.sourceforge.net/sourceforge/nagiosplug/nagios-plugins...
[root@webserver src]# useradd nagios 添加nagios用户,centos版本添加用户也就把组添加了,其他linux根本版本看。这里需要注意哈,如果你的nginx运行用户是别的比如nginx,那里这里还就要添加一个用户组groupadd nagcmd usermod -g nagcmd nagios usermod -g nagcmd www 这样!本文中我nginx用的是www运行的所以这一部可以忽略啦!
- [root@webserver src]# passwd nagios 设置个密码
- [root@webserver src]#tar -zxvf nagios-3.2.0.tar.gz
- [root@webserver src]#cd nagios-3.2.0
- [root@webserver nagios-3.2.0]# ./configure --with-group=nagios --with-user=nagios --with-command-group=nagcmd --with-gd-lib=/usr/lib --with-gd-inc=/usr/include 具体看help
- [root@webserver nagios-3.2.0]#make all
- [root@webserver nagios-3.2.0]# make install
- [root@webserver nagios-3.2.0]#make install-init
- [root@webserver nagios-3.2.0]#make install-config
- [root@webserver nagios-3.2.0]#make install-commandmode
现在还不能启动Nagios-还有一些要做的…
配置文件默认安装在这个目录下/usr/local/nagios/etc,这些样例文件可以配置Nagios使之正常运行,只需要做一个简单的修改…
用你擅长的编辑器软件来编辑这个/usr/local/nagios/etc/objects/contacts.cfg配置文件,更改email地址nagiosadmin的联系人定义信息中的EMail信息为你的EMail信息以接收报警内容。
创建一个nagiosadmin的用户用于Nagios的WEB接口登录。记下你所设置的登录口令,一会儿你会用到它
这里要借助于apche的htpasswd,在有apache机器上执行下列命令
- /usr/local/apache2/bin/htpasswd -c /usr/local/server/nginx/conf/htppasswd nagiosadmin
这里就这样,下来装nagios插件。
- [root@webserver nagios]# tar -zxvf nagios-plugins-1.4.14
- [root@webserver nagios]# ./configure –with-nagios-user=nagios –with-nagios-group=nagios
- [root@webserver nagios]# make & make install
启动nagios chkconfig –add nagios 添加到service 中,chkconfig nagios on设置成开机启动
[root@webserver nagios]#service nagios start 启动服务 这里要关掉selinux要么会出错,一会访问的时候。
安装perl fcgi模块
[quote]
[/quote]
这里基本上nagios就装完了,下来就是nginx的配置了!
http://www.nginx.eu/nginx-fcgi.html 这里nginx cgi的配置方法,也可以参照官方的http://wiki.nginx.org/NginxSimpleCGI 这里讲的很明白了,如果用
http://www.nginx.eu/nginx-fcgi.html 这里面的,默认是不许root用户运行的,修改源码注销掉
if ( $> == “0″ ) {
print “\n\tERROR\tRunning as a root!\n”;
print “\tSuggested not to do so !!!\n\n”;
exit 1;
} 注销这几句话。要么root执行报错! 我用的是这个脚本。复制刚才那个脚本到nginx/sbin/下,给与x权限。
/usr/local/server/nginx/sbin/nginx-fcgi -l /var/log/nginx/nginx-fcgi.log -pid /var/run/nginx-fcgi.pid -S /var/run/nginx-fcgi.sock 创建fastcgi_pass 接口。
chmod 777 /var/run/nginx-fcgi.sock 修改权限给与执行权限。OK!
下来vi nginx.conf
我的把我的贴出来,我用的是nginx虚拟主机。
[quote]
这里基本上就成功了,图片倒是显示正常,但监控页面页面不对,css路径需要做好链接。
- server
- {
- listen 80;
- server_name mon.freebsdsystem.org;
- root /usr/local/nagios/share;
- index index.php;
- location ~ .*\.(php|php5)?$
- {
- #root /usr/local/nagios/share;
- fastcgi_pass unix:/tmp/php-cgi.sock;
- fastcgi_index index.php;
- fastcgi_param SCRIPT_FILENAME /scripts$fastcgi_script_name;
- fastcgi_param HTTP_ACCEPT_LANGUAGE zh-cn;
- include fcgi.conf;
- auth_basic "Nagios Login pain";
- auth_basic_user_file /usr/local/webserver/nginx/conf/htpasswd;
- }
- location ~ .*\.cgi$ {
- root /usr/local/nagios/sbin;
- rewrite ^/nagios/cgi-bin/(.*)\.cgi /$1.cgi break;
- fastcgi_pass unix:/var/run/nginx-fcgi.sock;
- fastcgi_index index.cgi;
- fastcgi_param SCRIPT_FILENAME /usr/local/nagios/sbin/$fastcgi_script_name;
- fastcgi_param HTTP_ACCEPT_LANGUAGE zh-cn;
- include fcgi.conf;
- auth_basic "Nagios Login pain";
- auth_basic_user_file /usr/local/webserver/nginx/conf/htpasswd;
- }
- location /nagios {
- alias /usr/local/nagios/share/;
- #index index.html index.htm index.php;
- #auth_basic "Nagios Login pain";
- #auth_basic_user_file /usr/local/webserver/nginx/conf/htpasswd;
- }
- wget http://www.cpan.org/modules/by-module/FCGI/FCGI-0.67.tar.gz
- tar -zxvf FCGI-0.67.tar.gz
- cd FCGI-0.67
- perl Makefile.PL
- make && make install
- 安装FCGI-ProcManager:
- wget http://search.cpan.org/CPAN/authors/id/G/GB/GBJK/FCGI-ProcManager-0.18.tar.gz
- tar -xzxf FCGI-ProcManager-0.18.tar.gz
- cd FCGI-ProcManager-0.18
- perl Makefile.PL
- make && make install
- mkdir -p /usr/local/nagios/share/nagios
- ln -s /usr/local/nagios/share/p_w_picpaths /usr/local/nagios/share/nagios/p_w_picpaths
- ln -s /usr/local/nagios/share/stylesheets /usr/local/nagios/share/nagios/stylesheets
[/quote]
参考文章 http://linux.chinaunix.net/bbs/viewt
http://www.lazysa.com/2009/05/392.htmlhread.php?tid=1138138
http://hi.baidu.com/shengit/blog/item/4a7fcb08491ef72c6b60fb83.html