海运的博客

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下关闭SELinux的方法

发布时间:June 3, 2012 // 分类:Linux基础 // No Comments

查看SELinux状态:

getenforce 

临时关闭SELinux:

setenforce 0

CentOS下永久关闭SELinux:

sed -i 's/SELINUX=enforcing/SELINUX=disabled/g' /etc/selinux/config

或在引导时关闭SELinux,编辑grub配置添加:

selinux=0

Nginx设置防止恶意域名指向IP

发布时间:June 2, 2012 // 分类:Nginx // No Comments

Nginx默认虚拟主机在用户通过IP访问,或者通过未设置的域名访问(比如有人把他自己的域名指向了你的ip)的时候生效,默认为第一个Server段的虚拟主机,可通过设置指定默认虚拟主机:

server {
listen     80 default; #default表示默认虚拟主机,未知域名或通过IP访问 
rewrite ^(.*) https://www.haiyun.me permanent; #301重定向到自己的网站
#return 404; #返回相应的状态码
#return 403;
#return 500;
}

Nginx根据来路、UA和访客IP做访问控制

发布时间:June 2, 2012 // 分类:Nginx // No Comments

Nginx配置判断来路referer如果为*.www.haiyun.me返回403:

if ($http_referer ~* .*\.www.haiyun.me){
return 403;
}

判断用户user_agent如果为NSPlayer返回403:

if ($http_user_agent ~* NSPlayer.*){
return 403;
}

根据访客IP做限制:

if ($remote_addr != "192.168.1.5"){
    return 403;
}   

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
分类
最新文章
最近回复
  • 海运: 恩山有很多。
  • swsend: 大佬可以分享一下固件吗,谢谢。
  • 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 论坛没找到好方法,博...